You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2003/11/13 17:08:50 UTC
cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting RevisionControllerAction.java XopusHandlerAction.java BitfluxAction.java AccessControlAction.java UserAuthenticatorAction.java PMLAuthorizerAction.java IMLAuthenticatorAction.java
andreas 2003/11/13 08:08:50
Modified: src/java/org/apache/lenya/cms/cocoon/acting
RevisionControllerAction.java
XopusHandlerAction.java BitfluxAction.java
AccessControlAction.java
Removed: src/java/org/apache/lenya/cms/cocoon/acting
UserAuthenticatorAction.java
PMLAuthorizerAction.java
IMLAuthenticatorAction.java
Log:
- refactoring access control package structure
- removed obsolete actions
Revision Changes Path
1.28 +162 -175 cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java
Index: RevisionControllerAction.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- RevisionControllerAction.java 21 Oct 2003 09:51:54 -0000 1.27
+++ RevisionControllerAction.java 13 Nov 2003 16:08:49 -0000 1.28
@@ -64,7 +64,8 @@
import org.apache.cocoon.environment.Session;
import org.apache.cocoon.environment.SourceResolver;
-import org.apache.lenya.cms.ac.Identity;
+import org.apache.lenya.ac.Identity;
+import org.apache.lenya.ac.User;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuilder;
import org.apache.lenya.cms.publication.PageEnvelope;
@@ -84,178 +85,164 @@
* @version 2003.1.5
*/
public class RevisionControllerAction extends AbstractAction {
- private String rcmlDirectory = null;
- private String backupDirectory = null;
- private RevisionController rc = null;
- private String username = null;
- private String filename = null;
-
- /**
- * DOCUMENT ME!
- *
- * @param redirector DOCUMENT ME!
- * @param resolver DOCUMENT ME!
- * @param objectModel DOCUMENT ME!
- * @param src DOCUMENT ME!
- * @param parameters DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws Exception DOCUMENT ME!
- */
- public Map act(
- Redirector redirector,
- SourceResolver resolver,
- Map objectModel,
- String src,
- Parameters parameters)
- throws Exception {
- // Get request object
- Request request = ObjectModelHelper.getRequest(objectModel);
-
- if (request == null) {
- getLogger().error(".act(): No request object");
-
- return null;
- }
-
- PageEnvelope envelope = null;
- Publication publication = null;
- Document document = null;
-
- try {
- envelope =
- PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
- publication = envelope.getPublication();
- document = envelope.getDocument();
- } catch (Exception e) {
- getLogger().error("Resolving page envelope failed: ", e);
- }
-
- //get Parameters for RC
- String publicationPath = publication.getDirectory().getCanonicalPath();
- RCEnvironment rcEnvironment =
- RCEnvironment.getInstance(
- publication.getServletContext().getAbsolutePath());
- rcmlDirectory = rcEnvironment.getRCMLDirectory();
- rcmlDirectory = publicationPath + File.separator + rcmlDirectory;
- backupDirectory = rcEnvironment.getBackupDirectory();
- backupDirectory = publicationPath + File.separator + backupDirectory;
-
- // Initialize Revision Controller
- rc =
- new RevisionController(
- rcmlDirectory,
- backupDirectory,
- publicationPath);
- getLogger().debug("revision controller" + rc);
-
- // /Initialize Revision Controller
- // Get session
- Session session = request.getSession(false);
-
- if (session == null) {
- getLogger().error(".act(): No session object");
-
- return null;
- }
-
- Identity identity =
- (Identity) session.getAttribute("org.apache.lenya.cms.ac.Identity");
- org.apache.lenya.cms.ac2.Identity identityTwo =
- (org.apache.lenya.cms.ac2.Identity) session.getAttribute(
- "org.apache.lenya.cms.ac2.Identity");
- getLogger().debug(".act(): Identity: " + identity);
- getLogger().debug(".act(): Identity: " + identityTwo);
-
- //FIXME: hack because of the uri for the editor bitflux. The filename cannot be get from the page-envelope
-
- String documentid = document.getId();
- int bx = documentid.lastIndexOf("-bxeng");
-
- if (bx > 0) {
- String language = document.getLanguage();
-
- int l = documentid.length();
- int bxLength = "-bxeng".length();
- int lang = documentid.lastIndexOf("_", bx);
- int langLength = bx - lang;
-
- if (bx > 0 && bx + bxLength <= l) {
- documentid =
- documentid.substring(0, bx)
- + documentid.substring(bx + bxLength, l);
-
- if (lang > 0 && langLength + lang < l) {
- language =
- documentid.substring(lang + 1, lang + langLength);
- documentid =
- documentid.substring(0, lang)
- + documentid.substring(
- lang + langLength,
- l - bxLength);
- }
- }
-
- DocumentBuilder builder = publication.getDocumentBuilder();
-
- String srcUrl =
- builder.buildCanonicalUrl(
- publication,
- document.getArea(),
- documentid,
- language);
- Document srcDoc = builder.buildDocument(publication, srcUrl);
- File newFile = srcDoc.getFile();
- filename = newFile.getAbsolutePath();
-
- } else {
- filename = document.getFile().getAbsolutePath();
- }
-
- filename = filename.substring(publicationPath.length());
- getLogger().debug("filename :" + filename);
-
- username = null;
-
- if (identity != null) {
- username = identity.getUsername();
- } else if (identityTwo != null) {
- username = identityTwo.getUser().getId();
- } else {
- getLogger().error(".act(): No identity yet");
- }
-
- getLogger().debug(".act(): Username: " + username);
-
- return null;
- }
-
- /**
- * Get the filename.
- *
- * @return the filename
- */
- protected String getFilename() {
- return filename;
- }
-
- /**
- * Get the revision controller.
- *
- * @return the revision controller
- */
- protected RevisionController getRc() {
- return rc;
- }
-
- /**
- * Get the user name.
- *
- * @return the user name
- */
- protected String getUsername() {
- return username;
- }
+ private String rcmlDirectory = null;
+ private String backupDirectory = null;
+ private RevisionController rc = null;
+ private String username = null;
+ private String filename = null;
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param redirector DOCUMENT ME!
+ * @param resolver DOCUMENT ME!
+ * @param objectModel DOCUMENT ME!
+ * @param src DOCUMENT ME!
+ * @param parameters DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ *
+ * @throws Exception DOCUMENT ME!
+ */
+ public Map act(
+ Redirector redirector,
+ SourceResolver resolver,
+ Map objectModel,
+ String src,
+ Parameters parameters)
+ throws Exception {
+ // Get request object
+ Request request = ObjectModelHelper.getRequest(objectModel);
+
+ if (request == null) {
+ getLogger().error(".act(): No request object");
+
+ return null;
+ }
+
+ PageEnvelope envelope = null;
+ Publication publication = null;
+ Document document = null;
+
+ try {
+ envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
+ publication = envelope.getPublication();
+ document = envelope.getDocument();
+ } catch (Exception e) {
+ getLogger().error("Resolving page envelope failed: ", e);
+ }
+
+ //get Parameters for RC
+ String publicationPath = publication.getDirectory().getCanonicalPath();
+ RCEnvironment rcEnvironment =
+ RCEnvironment.getInstance(publication.getServletContext().getAbsolutePath());
+ rcmlDirectory = rcEnvironment.getRCMLDirectory();
+ rcmlDirectory = publicationPath + File.separator + rcmlDirectory;
+ backupDirectory = rcEnvironment.getBackupDirectory();
+ backupDirectory = publicationPath + File.separator + backupDirectory;
+
+ // Initialize Revision Controller
+ rc = new RevisionController(rcmlDirectory, backupDirectory, publicationPath);
+ getLogger().debug("revision controller" + rc);
+
+ // /Initialize Revision Controller
+ // Get session
+ Session session = request.getSession(false);
+
+ if (session == null) {
+ getLogger().error(".act(): No session object");
+
+ return null;
+ }
+
+ Identity identity = (Identity) session.getAttribute(Identity.class.getName());
+ org.apache.lenya.ac.Identity identityTwo =
+ (org.apache.lenya.ac.Identity) session.getAttribute(Identity.class.getName());
+ getLogger().debug(".act(): Identity: " + identity);
+ getLogger().debug(".act(): Identity: " + identityTwo);
+
+ //FIXME: hack because of the uri for the editor bitflux. The filename cannot be get from the page-envelope
+
+ String documentid = document.getId();
+ int bx = documentid.lastIndexOf("-bxeng");
+
+ if (bx > 0) {
+ String language = document.getLanguage();
+
+ int l = documentid.length();
+ int bxLength = "-bxeng".length();
+ int lang = documentid.lastIndexOf("_", bx);
+ int langLength = bx - lang;
+
+ if (bx > 0 && bx + bxLength <= l) {
+ documentid = documentid.substring(0, bx) + documentid.substring(bx + bxLength, l);
+
+ if (lang > 0 && langLength + lang < l) {
+ language = documentid.substring(lang + 1, lang + langLength);
+ documentid =
+ documentid.substring(0, lang)
+ + documentid.substring(lang + langLength, l - bxLength);
+ }
+ }
+
+ DocumentBuilder builder = publication.getDocumentBuilder();
+
+ String srcUrl =
+ builder.buildCanonicalUrl(publication, document.getArea(), documentid, language);
+ Document srcDoc = builder.buildDocument(publication, srcUrl);
+ File newFile = srcDoc.getFile();
+ filename = newFile.getAbsolutePath();
+
+ } else {
+ filename = document.getFile().getAbsolutePath();
+ }
+
+ filename = filename.substring(publicationPath.length());
+ getLogger().debug("filename :" + filename);
+
+ username = null;
+
+ if (identity != null) {
+ User user = identity.getUser();
+ if (user != null) {
+ username = user.getId();
+ }
+ } else if (identityTwo != null) {
+ username = identityTwo.getUser().getId();
+ } else {
+ getLogger().error(".act(): No identity yet");
+ }
+
+ getLogger().debug(".act(): Username: " + username);
+
+ return null;
+ }
+
+ /**
+ * Get the filename.
+ *
+ * @return the filename
+ */
+ protected String getFilename() {
+ return filename;
+ }
+
+ /**
+ * Get the revision controller.
+ *
+ * @return the revision controller
+ */
+ protected RevisionController getRc() {
+ return rc;
+ }
+
+ /**
+ * Get the user name.
+ *
+ * @return the user name
+ */
+ protected String getUsername() {
+ return username;
+ }
}
1.35 +56 -25 cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/XopusHandlerAction.java
Index: XopusHandlerAction.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/XopusHandlerAction.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- XopusHandlerAction.java 23 Jul 2003 15:32:35 -0000 1.34
+++ XopusHandlerAction.java 13 Nov 2003 16:08:49 -0000 1.35
@@ -74,7 +74,8 @@
import org.apache.excalibur.source.Source;
import org.apache.excalibur.xml.dom.DOMParser;
-import org.apache.lenya.cms.ac.Identity;
+import org.apache.lenya.ac.Identity;
+import org.apache.lenya.ac.User;
import org.apache.lenya.cms.rc.RevisionController;
import org.apache.lenya.xml.DOMParserFactory;
import org.apache.lenya.xml.DOMWriter;
@@ -92,7 +93,6 @@
import java.util.HashMap;
import java.util.Map;
-
/**
* Interfaces with Xopus: handles the requests and replies to them
*
@@ -122,9 +122,19 @@
xslRoot = conf.getChild("xsl").getAttribute("href");
xsdRoot = conf.getChild("xsd").getAttribute("href");
tempRoot = conf.getChild("temp").getAttribute("href");
- getLogger().debug(".configure(): \n" + "Relative XML Root Directory: " + xmlRoot + "\n" +
- "Relative XSL Root Directory: " + xslRoot + "\n" + "Relative XSD Root Directory: " +
- xsdRoot + "\n" + "Relative Temp Directory: " + tempRoot);
+ getLogger().debug(
+ ".configure(): \n"
+ + "Relative XML Root Directory: "
+ + xmlRoot
+ + "\n"
+ + "Relative XSL Root Directory: "
+ + xslRoot
+ + "\n"
+ + "Relative XSD Root Directory: "
+ + xsdRoot
+ + "\n"
+ + "Relative Temp Directory: "
+ + tempRoot);
// Encode File types and their root directories, relative to the sitemap directory
relRootDirs.put("xml", xmlRoot);
@@ -153,8 +163,12 @@
* @throws SAXException DOCUMENT ME!
* @throws ProcessingException DOCUMENT ME!
*/
- public java.util.Map act(Redirector redirector, SourceResolver resolver, Map objectModel,
- String source, Parameters params)
+ public java.util.Map act(
+ Redirector redirector,
+ SourceResolver resolver,
+ Map objectModel,
+ String source,
+ Parameters params)
throws IOException, ComponentException, SAXException, ProcessingException {
// Get absolute path of sitemap directory
Source input_source = resolver.resolveURI("");
@@ -207,8 +221,8 @@
reqContent.close();
// Define Files
- File tempFileDir = new File(sitemapPath + relRootDirs.get("temp") + "/" +
- relRootDirs.get(fileType));
+ File tempFileDir =
+ new File(sitemapPath + relRootDirs.get("temp") + "/" + relRootDirs.get(fileType));
if (!(tempFileDir.exists())) {
tempFileDir.mkdir();
@@ -219,8 +233,13 @@
if (!permFile.exists()) {
getLogger().error(".act(): No such file: " + permFile.getAbsolutePath());
- getLogger().error(".act(): No such file: " + sitemapPath + "::" +
- relRootDirs.get(fileType) + "::" + reqFile);
+ getLogger().error(
+ ".act(): No such file: "
+ + sitemapPath
+ + "::"
+ + relRootDirs.get(fileType)
+ + "::"
+ + reqFile);
return null;
}
@@ -240,11 +259,15 @@
sitemapParams.put("fileType", fileType);
if ("xml".equals(fileType) && ("open".equals(reqType) || "save".equals(reqType))) {
- sitemapParams.put("reqFilePath",
- (String) relRootDirs.get("temp") + "/" + (String) relRootDirs.get(fileType) + "/" +
- reqFile);
- getLogger().debug(".act(): File to be edited (in temp dir): " +
- sitemapParams.get("reqFilePath"));
+ sitemapParams.put(
+ "reqFilePath",
+ (String) relRootDirs.get("temp")
+ + "/"
+ + (String) relRootDirs.get(fileType)
+ + "/"
+ + reqFile);
+ getLogger().debug(
+ ".act(): File to be edited (in temp dir): " + sitemapParams.get("reqFilePath"));
} else {
sitemapParams.put("reqFilePath", (String) relRootDirs.get(fileType) + "/" + reqFile);
}
@@ -264,9 +287,10 @@
// Create a new document, where the actual content starts at the root element, which is the inner part of requestDoc
Document contentDocument = dpf.getDocument();
- contentDocument.appendChild((Element) dpf.cloneNode(contentDocument, contentNode,
- true));
- new DOMWriter(new FileOutputStream(tempFile)).printWithoutFormatting(contentDocument);
+ contentDocument.appendChild(
+ (Element) dpf.cloneNode(contentDocument, contentNode, true));
+ new DOMWriter(new FileOutputStream(tempFile)).printWithoutFormatting(
+ contentDocument);
} catch (Exception e) {
getLogger().error(".act(): Exception during writing to temp file", e);
}
@@ -276,8 +300,11 @@
if ("checkin".equals(reqType)) {
getLogger().debug(".act(): Save to permanent file: " + permFile);
- RevisionController rc = new RevisionController(sitemapPath + rcmlDirectory,
- sitemapPath + backupDirectory, sitemapPath);
+ RevisionController rc =
+ new RevisionController(
+ sitemapPath + rcmlDirectory,
+ sitemapPath + backupDirectory,
+ sitemapPath);
try {
Session session = httpReq.getSession(false);
@@ -286,11 +313,15 @@
throw new Exception("No session");
}
- Identity identity = (Identity) session.getAttribute("org.apache.lenya.cms.ac.Identity");
- org.apache.lenya.cms.ac2.Identity identityTwo = (org.apache.lenya.cms.ac2.Identity) session.getAttribute("org.apache.lenya.cms.ac2.Identity");
+ Identity identity = (Identity) session.getAttribute(Identity.class.getName());
+ org.apache.lenya.ac.Identity identityTwo =
+ (org.apache.lenya.ac.Identity) session.getAttribute(Identity.class.getName());
String username = null;
if (identity != null) {
- username = identity.getUsername();
+ User user = identity.getUser();
+ if (user != null) {
+ username = user.getId();
+ }
} else if (identityTwo != null) {
username = identityTwo.getUser().getId();
} else {
1.17 +46 -20 cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/BitfluxAction.java
Index: BitfluxAction.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/BitfluxAction.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- BitfluxAction.java 23 Jul 2003 13:21:31 -0000 1.16
+++ BitfluxAction.java 13 Nov 2003 16:08:49 -0000 1.17
@@ -77,7 +77,8 @@
import org.apache.excalibur.source.Source;
import org.apache.excalibur.xml.dom.DOMParser;
-import org.apache.lenya.cms.ac.Identity;
+import org.apache.lenya.ac.Identity;
+import org.apache.lenya.ac.User;
import org.apache.lenya.cms.rc.RevisionController;
import org.w3c.dom.Document;
@@ -94,7 +95,6 @@
import java.util.HashMap;
import java.util.Map;
-
/**
* Interfaces with Bitflux editor: handles the requests and replies to them
*
@@ -123,9 +123,19 @@
xslRoot = conf.getChild("xsl").getAttribute("href");
xsdRoot = conf.getChild("xsd").getAttribute("href");
tempRoot = conf.getChild("temp").getAttribute("href");
- getLogger().debug("CONFIGURATION:\n" + "Relative XML Root Directory: " + xmlRoot + "\n" +
- "Relative XSL Root Directory: " + xslRoot + "\n" + "Relative XSD Root Directory: " +
- xsdRoot + "\n" + "Relative Temp Directory: " + tempRoot);
+ getLogger().debug(
+ "CONFIGURATION:\n"
+ + "Relative XML Root Directory: "
+ + xmlRoot
+ + "\n"
+ + "Relative XSL Root Directory: "
+ + xslRoot
+ + "\n"
+ + "Relative XSD Root Directory: "
+ + xsdRoot
+ + "\n"
+ + "Relative Temp Directory: "
+ + tempRoot);
// Encode File types and their root directories, relative to the sitemap directory
relRootDirs.put("xml", xmlRoot);
@@ -154,8 +164,12 @@
* @throws SAXException DOCUMENT ME!
* @throws ProcessingException DOCUMENT ME!
*/
- public java.util.Map act(Redirector redirector, SourceResolver resolver, Map objectModel,
- String source, Parameters params)
+ public java.util.Map act(
+ Redirector redirector,
+ SourceResolver resolver,
+ Map objectModel,
+ String source,
+ Parameters params)
throws IOException, ComponentException, SAXException, ProcessingException {
// Get relative filename to save
String relativeFilename = null;
@@ -203,7 +217,6 @@
Element data = (Element) root.getFirstChild();
getLogger().debug("first child element (should be 'data'): " + data.getTagName());
- String reqFile = data.getAttribute("id");
String fileType = data.getAttribute("type");
getLogger().debug("Requested File's Type: " + fileType);
@@ -211,8 +224,8 @@
reqContent.close();
// Define temp dir
- File tempFileDir = new File(sitemapPath + relRootDirs.get("temp") + "/" +
- relRootDirs.get(fileType));
+ File tempFileDir =
+ new File(sitemapPath + relRootDirs.get("temp") + "/" + relRootDirs.get(fileType));
if (!(tempFileDir.exists())) {
tempFileDir.mkdir();
@@ -235,8 +248,8 @@
if ("save".equals(reqType) || "checkin".equals(reqType)) {
//FIXME(): remove hard coding
final OutputStream os = new FileOutputStream(tempFile);
- ComponentSelector selector = (ComponentSelector) super.manager.lookup(Serializer.ROLE +
- "Selector");
+ ComponentSelector selector =
+ (ComponentSelector) super.manager.lookup(Serializer.ROLE + "Selector");
//FIXME: remove hardcoding stuff
Serializer serializer = (Serializer) selector.select("xml");
@@ -258,8 +271,11 @@
if ("checkin".equals(reqType)) {
getLogger().debug(".act(): Save to permanent file: " + permFile);
- RevisionController rc = new RevisionController(sitemapPath + rcmlDirectory,
- sitemapPath + backupDirectory, sitemapPath);
+ RevisionController rc =
+ new RevisionController(
+ sitemapPath + rcmlDirectory,
+ sitemapPath + backupDirectory,
+ sitemapPath);
try {
Session session = httpReq.getSession(false);
@@ -268,14 +284,24 @@
throw new Exception("No session");
}
- Identity identity = (Identity) session.getAttribute(
- "org.apache.lenya.cms.ac.Identity");
- rc.reservedCheckIn(xmlRoot + "/" + relativeFilename, identity.getUsername(), true);
+ Identity identity = (Identity) session.getAttribute(Identity.class.getName());
+ User user = identity.getUser();
+ String userId = "";
+ if (user != null) {
+ userId = user.getId();
+ }
+ rc.reservedCheckIn(xmlRoot + "/" + relativeFilename, userId, true);
FileUtil.copyFile(tempFile, permFile);
} catch (Exception e) {
- getLogger().error(".act(): Exception during checkin of " + xmlRoot + "/" +
- relativeFilename + " (" + e + ")");
+ getLogger().error(
+ ".act(): Exception during checkin of "
+ + xmlRoot
+ + "/"
+ + relativeFilename
+ + " ("
+ + e
+ + ")");
return null;
}
1.7 +3 -3 cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/AccessControlAction.java
Index: AccessControlAction.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/AccessControlAction.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AccessControlAction.java 13 Aug 2003 13:14:00 -0000 1.6
+++ AccessControlAction.java 13 Nov 2003 16:08:49 -0000 1.7
@@ -66,8 +66,8 @@
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
-import org.apache.lenya.cms.ac2.AccessController;
-import org.apache.lenya.cms.ac2.AccessControllerResolver;
+import org.apache.lenya.ac.AccessController;
+import org.apache.lenya.ac.AccessControllerResolver;
import org.apache.lenya.util.ServletHelper;
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org