svn commit: r574702 [3/6] - in /lenya/branches/revolution/1.3.x: ./ lib/ src/java/org/apache/lenya/ac/ src/java/org/apache/lenya/ac/file/ src/java/org/apache/lenya/ac/impl/ src/java/org/apache/lenya/cms/ac/ src/java/org/apache/lenya/cms/ac/cocoon/ src/...

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ac/cocoon/PolicyHelper.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ac/cocoon/PolicyHelper.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ac/cocoon/PolicyHelper.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ac/cocoon/PolicyHelper.java Tue Sep 11 14:39:37 2007
@@ -14,16 +14,13 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.ac.cocoon;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-
 import org.apache.avalon.framework.component.ComponentManager;
 import org.apache.avalon.framework.component.ComponentSelector;
 import org.apache.cocoon.ProcessingException;
@@ -49,54 +46,45 @@
  * Helper class for the policy GUI.
  */
 public class PolicyHelper {
-
     /**
      * Ctor.
      */
     public PolicyHelper() {
     }
-
     private DefaultAccessController accessController;
     private ComponentSelector selector;
     private AccessControllerResolver resolver;
     private InheritingPolicyManager policyManager;
     private ComponentManager manager;
     private String url;
-
     /**
      * Initializes this helper.
-     * @param objectModel The Cocoon object model.
-     * @param manager The component manager.
-     * @param area The selected area.
-     * @throws ProcessingException when something went wrong.
+     * 
+     * @param objectModel
+     *            The Cocoon object model.
+     * @param manager
+     *            The component manager.
+     * @param area
+     *            The selected area.
+     * @throws ProcessingException
+     *             when something went wrong.
      */
-    public void setup(Map objectModel, ComponentManager manager, String area)
-        throws ProcessingException {
-
+    public void setup(Map objectModel, ComponentManager manager, String area) throws ProcessingException {
         this.manager = manager;
-
         accessController = null;
         selector = null;
         resolver = null;
         policyManager = null;
-
         url = computeUrl(objectModel, area);
-
         try {
-            selector =
-                (ComponentSelector) manager.lookup(AccessControllerResolver.ROLE + "Selector");
-            resolver =
-                (AccessControllerResolver) selector.select(
-                    AccessControllerResolver.DEFAULT_RESOLVER);
-
+            selector = (ComponentSelector) manager.lookup(AccessControllerResolver.ROLE + "Selector");
+            resolver = (AccessControllerResolver) selector.select(AccessControllerResolver.DEFAULT_RESOLVER);
             accessController = (DefaultAccessController) resolver.resolveAccessController(url);
-
             policyManager = (InheritingPolicyManager) accessController.getPolicyManager();
         } catch (Exception e) {
             throw new ProcessingException("Obtaining credentials failed: ", e);
         }
     }
-
     /**
      * Releases all obtained components.
      */
@@ -111,37 +99,39 @@
             manager.release(selector);
         }
     }
-
     /**
      * Returns the URI credential wrappers for the request of this object model.
+     * 
      * @return An array of CredentialWrappers.
-     * @throws ProcessingException when something went wrong.
+     * @throws ProcessingException
+     *             when something went wrong.
      */
     public CredentialWrapper[] getURICredentials() throws ProcessingException {
         return getCredentials(true);
     }
-
     /**
-     * Returns the credential wrappers for the parent URI of the URL
-     * belonging to the request of this object model.
+     * Returns the credential wrappers for the parent URI of the URL belonging
+     * to the request of this object model.
+     * 
      * @return An array of CredentialWrappers.
-     * @throws ProcessingException when something went wrong.
+     * @throws ProcessingException
+     *             when something went wrong.
      */
     public CredentialWrapper[] getParentCredentials() throws ProcessingException {
         return getCredentials(false);
     }
-
     /**
      * Returns the credentials of the policy of the selected URL.
-     * @param urlOnly If true, the URL policy credentials are returned.
-     * If false, the credentials of all ancestor policies are returned.
+     * 
+     * @param urlOnly
+     *            If true, the URL policy credentials are returned. If false,
+     *            the credentials of all ancestor policies are returned.
      * @return An array of CredentialWrappers.
-     * @throws ProcessingException when something went wrong.
+     * @throws ProcessingException
+     *             when something went wrong.
      */
     public CredentialWrapper[] getCredentials(boolean urlOnly) throws ProcessingException {
-
         List credentials = new ArrayList();
-
         DefaultPolicy policies[] = getPolicies(urlOnly);
         List policyCredentials = new ArrayList();
         for (int i = 0; i < policies.length; i++) {
@@ -160,14 +150,17 @@
         }
         return (CredentialWrapper[]) credentials.toArray(new CredentialWrapper[credentials.size()]);
     }
-
     /**
-     * Computes the webapp URL belonging to an object model with respect to the selected
-     * area.
-     * @param objectModel The Cocoon object model.
-     * @param area The selected area.
+     * Computes the webapp URL belonging to an object model with respect to the
+     * selected area.
+     * 
+     * @param objectModel
+     *            The Cocoon object model.
+     * @param area
+     *            The selected area.
      * @return A string.
-     * @throws ProcessingException when something went wrong.
+     * @throws ProcessingException
+     *             when something went wrong.
      */
     private static String computeUrl(Map objectModel, String area) throws ProcessingException {
         PageEnvelope envelope;
@@ -176,22 +169,21 @@
         } catch (PageEnvelopeException e) {
             throw new ProcessingException(e);
         }
-        String url =
-            "/" + envelope.getPublication().getId() + "/" + area + envelope.getDocument().getId();
+        String url = "/" + envelope.getPublication().getId() + "/" + area + envelope.getDocument().getId();
         return url;
     }
-
     /**
      * Returns the policies for a certain URL.
-     * @param onlyUrl If true, only the URL policies are returned.
-     * Otherwise, all ancestor policies are returned.
+     * 
+     * @param onlyUrl
+     *            If true, only the URL policies are returned. Otherwise, all
+     *            ancestor policies are returned.
      * @return An array of DefaultPolicy objects.
-     * @throws ProcessingException when something went wrong.
+     * @throws ProcessingException
+     *             when something went wrong.
      */
     protected DefaultPolicy[] getPolicies(boolean onlyUrl) throws ProcessingException {
-
         DefaultPolicy[] policies;
-
         try {
             if (onlyUrl) {
                 policies = new DefaultPolicy[1];
@@ -199,63 +191,55 @@
                 policies[0] = policyManager.buildSubtreePolicy(manager, url);
             } else {
                 String ancestorUrl = "";
-                
                 String currentUrl = url;
                 if (currentUrl.endsWith("/")) {
                     currentUrl = currentUrl.substring(0, currentUrl.length() - 1);
                 }
-                
                 int lastSlashIndex = currentUrl.lastIndexOf("/");
                 if (lastSlashIndex != -1) {
                     ancestorUrl = currentUrl.substring(0, lastSlashIndex);
                 }
-                policies =
-                    policyManager.getPolicies(
-                        accessController.getAccreditableManager(),
-                        ancestorUrl);
+                policies = policyManager.getPolicies(accessController.getAccreditableManager(), ancestorUrl);
             }
         } catch (AccessControlException e) {
             throw new ProcessingException(e);
         }
-
         return policies;
     }
-
     public static final String ADD = "add";
     public static final String DELETE = "delete";
-
     /**
      * Changes a credential by adding or deleting an item for a role.
-     * @param item The item to add or delete.
-     * @param role The role.
-     * @param operation The operation, either {@link #ADD} or {@link #DELETE}.
-     * @throws ProcessingException when something went wrong.
+     * 
+     * @param item
+     *            The item to add or delete.
+     * @param role
+     *            The role.
+     * @param operation
+     *            The operation, either {@link #ADD} or {@link #DELETE}.
+     * @throws ProcessingException
+     *             when something went wrong.
      */
-    public void manipulateCredential(Item item, Role role, String operation)
-        throws ProcessingException {
-
+    public void manipulateCredential(Item item, Role role, String operation) throws ProcessingException {
         try {
-            DefaultPolicy policy =
-                policyManager.buildSubtreePolicy(accessController.getAccreditableManager(), url);
+            DefaultPolicy policy = policyManager.buildSubtreePolicy(accessController.getAccreditableManager(), url);
             Accreditable accreditable = (Accreditable) item;
-
             if (operation.equals(ADD)) {
                 policy.addRole(accreditable, role);
             } else if (operation.equals(DELETE)) {
                 policy.removeRole(accreditable, role);
             }
-
             policyManager.saveSubtreePolicy(url, policy);
-
         } catch (Exception e) {
             throw new ProcessingException("Manipulating credential failed: ", e);
         }
     }
-
     /**
      * Returns if one of the ancestors of this URL is SSL protected.
+     * 
      * @return A boolean value.
-     * @throws ProcessingException when something went wrong.
+     * @throws ProcessingException
+     *             when something went wrong.
      */
     public boolean isAncestorSSLProtected() throws ProcessingException {
         boolean ssl;
@@ -265,59 +249,60 @@
             if (lastSlashIndex != -1) {
                 ancestorUrl = url.substring(0, lastSlashIndex);
             }
-            Policy policy =
-                policyManager.getPolicy(accessController.getAccreditableManager(), ancestorUrl);
+            Policy policy = policyManager.getPolicy(accessController.getAccreditableManager(), ancestorUrl);
             ssl = policy.isSSLProtected();
         } catch (AccessControlException e) {
             throw new ProcessingException("Resolving policy failed: ", e);
         }
         return ssl;
     }
-
     /**
      * Returns if this URL is SSL protected.
+     * 
      * @return A boolean value.
-     * @throws ProcessingException when something went wrong.
+     * @throws ProcessingException
+     *             when something went wrong.
      */
     public boolean isUrlSSLProtected() throws ProcessingException {
         boolean ssl;
         try {
-            DefaultPolicy policy =
-                policyManager.buildSubtreePolicy(accessController.getAccreditableManager(), url);
+            DefaultPolicy policy = policyManager.buildSubtreePolicy(accessController.getAccreditableManager(), url);
             ssl = policy.isSSLProtected();
         } catch (AccessControlException e) {
             throw new ProcessingException("Resolving policy failed: ", e);
         }
         return ssl;
     }
-
     /**
      * Sets if this URL is SSL protected.
-     * @param ssl A boolean value.
-     * @throws ProcessingException when something went wrong.
+     * 
+     * @param ssl
+     *            A boolean value.
+     * @throws ProcessingException
+     *             when something went wrong.
      */
     public void setUrlSSLProtected(boolean ssl) throws ProcessingException {
         try {
-            DefaultPolicy policy =
-                policyManager.buildSubtreePolicy(accessController.getAccreditableManager(), url);
+            DefaultPolicy policy = policyManager.buildSubtreePolicy(accessController.getAccreditableManager(), url);
             policy.setSSL(ssl);
             policyManager.saveSubtreePolicy(url, policy);
         } catch (AccessControlException e) {
             throw new ProcessingException("Resolving policy failed: ", e);
         }
     }
-
     /**
      * Returns the users with a certain role on the current URL.
-     * @param roleId The role ID.
+     * 
+     * @param roleId
+     *            The role ID.
      * @return An array of users.
-     * @throws ProcessingException when something went wrong.
+     * @throws ProcessingException
+     *             when something went wrong.
      */
     public User[] getUsersWithRole(String roleId) throws ProcessingException {
         List users = new ArrayList();
         try {
-            Policy policy =
-                policyManager.getPolicy(accessController.getAccreditableManager(), getUrl());
+            Policy policy = policyManager.getPolicy(accessController.getAccreditableManager(), getUrl());
             UserManager userManager = accessController.getAccreditableManager().getUserManager();
             User[] userArray = userManager.getUsers();
             for (int i = 0; i < userArray.length; i++) {
@@ -335,13 +320,12 @@
         }
         return (User[]) users.toArray(new User[users.size()]);
     }
-
     /**
      * Returns the URL.
+     * 
      * @return A string.
      */
     public String getUrl() {
         return url;
     }
-
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ac/usecase/UsecaseRolesBuilder.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ac/usecase/UsecaseRolesBuilder.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ac/usecase/UsecaseRolesBuilder.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ac/usecase/UsecaseRolesBuilder.java Tue Sep 11 14:39:37 2007
@@ -14,15 +14,12 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.ac.usecase;
 
 import java.io.InputStream;
 import java.util.HashSet;
 import java.util.Set;
-
 import org.apache.lenya.ac.AccessController;
 import org.apache.lenya.ac.cache.BuildException;
 import org.apache.lenya.ac.cache.InputStreamBuilder;
@@ -32,35 +29,25 @@
 import org.w3c.dom.Element;
 
 public class UsecaseRolesBuilder implements InputStreamBuilder {
-
     protected static final String USECASES_ELEMENT = "usecases";
     protected static final String USECASE_ELEMENT = "usecase";
     protected static final String ROLE_ELEMENT = "role";
     protected static final String ID_ATTRIBUTE = "id";
-
     /**
      * @see org.apache.lenya.ac.cache.InputStreamBuilder#build(java.io.InputStream)
      */
     public Object build(InputStream stream) throws BuildException {
-
         UsecaseRoles usecaseRoles = new UsecaseRoles();
-
         Document document;
         try {
             document = DocumentHelper.readDocument(stream);
         } catch (Exception e) {
             throw new BuildException(e);
         }
-        assert document.getDocumentElement().getLocalName().equals(USECASES_ELEMENT);
-
-        NamespaceHelper helper =
-            new NamespaceHelper(
-                AccessController.NAMESPACE,
-                AccessController.DEFAULT_PREFIX,
-                document);
-
-        Element[] usecaseElements =
-            helper.getChildren(document.getDocumentElement(), USECASE_ELEMENT);
+        // assert
+        // document.getDocumentElement().getLocalName().equals(USECASES_ELEMENT);
+        NamespaceHelper helper = new NamespaceHelper(AccessController.NAMESPACE, AccessController.DEFAULT_PREFIX, document);
+        Element[] usecaseElements = helper.getChildren(document.getDocumentElement(), USECASE_ELEMENT);
         for (int i = 0; i < usecaseElements.length; i++) {
             String usecaseId = usecaseElements[i].getAttribute(ID_ATTRIBUTE);
             Element[] roleElements = helper.getChildren(usecaseElements[i], ROLE_ELEMENT);
@@ -74,5 +61,4 @@
         }
         return usecaseRoles;
     }
-
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ant/PublicationTask.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ant/PublicationTask.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ant/PublicationTask.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ant/PublicationTask.java Tue Sep 11 14:39:37 2007
@@ -14,14 +14,11 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.ant;
 
 import java.io.File;
 import java.io.IOException;
-
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
 import org.apache.lenya.cms.publication.PublicationFactory;
@@ -30,32 +27,29 @@
 import org.apache.tools.ant.Task;
 
 /**
- * Abstract base class for publication-dependent Ant tasks.
- * It requires some project parameters that are set by the AntTask.
+ * Abstract base class for publication-dependent Ant tasks. It requires some
+ * project parameters that are set by the AntTask.
  */
 public abstract class PublicationTask extends Task {
     /** Creates a new instance of PublicationTask */
-    public PublicationTask() {}
-
+    public PublicationTask() {
+    }
     /**
      * Returns the publication directory.
      * 
      * @return a the path to the publication directory as a <code>File</code>
      */
     protected File getPublicationDirectory() {
-        return new File(
-            getProject().getProperty(AntTask.PUBLICATION_DIRECTORY));
+        return new File(getProject().getProperty(AntTask.PUBLICATION_DIRECTORY));
     }
-    
     /**
      * Return the context prefix.
      * 
      * @return the context-prefix
      */
     protected String getContextPrefix() {
-    	return getProject().getProperty(AntTask.CONTEXT_PREFIX);
+        return getProject().getProperty(AntTask.CONTEXT_PREFIX);
     }
-
     /**
      * Returns the publication ID.
      * 
@@ -64,7 +58,6 @@
     protected String getPublicationId() {
         return getProject().getProperty(AntTask.PUBLICATION_ID);
     }
-
     /**
      * Returns the servlet context (e.g., <code>tomcat/webapp/lenya</code>)
      * 
@@ -73,32 +66,30 @@
     protected File getServletContext() {
         return new File(getProject().getProperty(AntTask.SERVLET_CONTEXT_PATH));
     }
-
     /**
      * Get the publication
      * 
      * @return the publication
-     *  
-     * @throws BuildException if the publication could not be found
+     * 
+     * @throws BuildException
+     *             if the publication could not be found
      */
     protected Publication getPublication() throws BuildException {
         try {
-            return PublicationFactory.getPublication(
-                getPublicationId(),
-                getServletContext().getCanonicalPath());
+            return PublicationFactory.getPublication(getPublicationId(), getServletContext().getCanonicalPath());
         } catch (IOException e) {
             throw new BuildException(e);
         } catch (PublicationException e) {
             throw new BuildException(e);
         }
     }
-
     /**
      * Utility method for assertion that a string is != null and != ""
      * 
-     * @param string the string to check
+     * @param string
+     *            the string to check
      */
     protected void assertString(String string) {
-        assert(string != null) && !string.equals("");
+        // assert(string != null) && !string.equals("");
     }
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ant/SetIdentifier.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ant/SetIdentifier.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ant/SetIdentifier.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/ant/SetIdentifier.java Tue Sep 11 14:39:37 2007
@@ -14,9 +14,7 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.ant;
 
 import org.apache.lenya.cms.publication.Document;
@@ -32,114 +30,99 @@
 import org.apache.tools.ant.BuildException;
 
 /**
- * anttask to set the document-id in the dc:identifier of all existing files corresponding to this
- * document-id
+ * anttask to set the document-id in the dc:identifier of all existing files
+ * corresponding to this document-id
  */
 public class SetIdentifier extends PublicationTask {
-
-	private String area;
-	private String documentid;
-
-	/**
-	 *  
-	 */
-	public SetIdentifier() {
-		super();
-	}
-
-	/**
-	 * @return String The area.
-	 */
-	public String getArea() {
-		return area;
-	}
-
-	/**
-	 * @return String The document-id.
-	 */
-	public String getDocumentid() {
-		return documentid;
-	}
-
-	/**
-	 * @param string
-	 *            The area.
-	 */
-	public void setArea(String string) {
-		area = string;
-	}
-
-	/**
-	 * @param string
-	 *            The document-id.
-	 */
-	public void setDocumentid(String string) {
-		documentid = string;
-	}
-
-	/**
-	 * write the document id in the DC Identifier of a document corresponding to this url
-	 * 
-	 * @param publication
-	 *            The publication the document belongs to.
-	 * @param url
-	 *            The URL of the form /{publication-id}/...
-	 * @throws DocumentBuildException
-	 *             when something went wrong when building the cms document.
-	 * @throws DocumentException
-	 *             when something went wrong when getting the DublinCore.
-	 */
-	public void writeDCIdentifier(Publication publication, String url)
-		throws DocumentBuildException, DocumentException {
-		assert url != null;
-
-		Document document = null;
-		document = publication.getDocumentBuilder().buildDocument(publication, url);
-		DublinCore dublincore = document.getDublinCore();
+    private String area;
+    private String documentid;
+    /**
+     * 
+     */
+    public SetIdentifier() {
+        super();
+    }
+    /**
+     * @return String The area.
+     */
+    public String getArea() {
+        return area;
+    }
+    /**
+     * @return String The document-id.
+     */
+    public String getDocumentid() {
+        return documentid;
+    }
+    /**
+     * @param string
+     *            The area.
+     */
+    public void setArea(String string) {
+        area = string;
+    }
+    /**
+     * @param string
+     *            The document-id.
+     */
+    public void setDocumentid(String string) {
+        documentid = string;
+    }
+    /**
+     * write the document id in the DC Identifier of a document corresponding to
+     * this url
+     * 
+     * @param publication
+     *            The publication the document belongs to.
+     * @param url
+     *            The URL of the form /{publication-id}/...
+     * @throws DocumentBuildException
+     *             when something went wrong when building the cms document.
+     * @throws DocumentException
+     *             when something went wrong when getting the DublinCore.
+     */
+    public void writeDCIdentifier(Publication publication, String url) throws DocumentBuildException, DocumentException {
+        // assert url != null;
+        Document document = null;
+        document = publication.getDocumentBuilder().buildDocument(publication, url);
+        DublinCore dublincore = document.getDublinCore();
         dublincore.setValue("identifier", documentid);
-		dublincore.save();
-	}
-
-	/**
-	 * @see org.apache.tools.ant.Task#execute()
-	 */
-	public void execute() throws BuildException {
-		log("document-id " + this.getDocumentid());
-		log("area " + this.getArea());
-
-		Publication publication = getPublication();
-
-		String language = null;
-		String url = null;
-		SiteTree tree;
-
-		try {
-			tree = publication.getTree(area);
-		} catch (SiteTreeException e) {
-			throw new BuildException(e);
-		}
-		SiteTreeNode node = tree.getNode(documentid);
-		Label[] labels = node.getLabels();
-
-		DocumentBuilder builder = publication.getDocumentBuilder();
-
-		try {
-			if (labels.length < 1) {
-				log("no languages found for the node with id : " + node.getId());
-				url = builder.buildCanonicalUrl(publication, area, documentid);
-				writeDCIdentifier(publication, url);
-			} else {
-				for (int i = 0; i < labels.length; i++) {
-					language = labels[i].getLanguage();
-					url = builder.buildCanonicalUrl(publication, area, documentid, language);
-					writeDCIdentifier(publication, url);
-				}
-			}
-		} catch (DocumentException e1) {
-			throw new BuildException(e1);
-		} catch (DocumentBuildException e2) {
-			throw new BuildException(e2);
-		}
-	}
-
+        dublincore.save();
+    }
+    /**
+     * @see org.apache.tools.ant.Task#execute()
+     */
+    public void execute() throws BuildException {
+        log("document-id " + this.getDocumentid());
+        log("area " + this.getArea());
+        Publication publication = getPublication();
+        String language = null;
+        String url = null;
+        SiteTree tree;
+        try {
+            tree = publication.getTree(area);
+        } catch (SiteTreeException e) {
+            throw new BuildException(e);
+        }
+        SiteTreeNode node = tree.getNode(documentid);
+        Label[] labels = node.getLabels();
+        DocumentBuilder builder = publication.getDocumentBuilder();
+        try {
+            if (labels.length < 1) {
+                log("no languages found for the node with id : " + node.getId());
+                url = builder.buildCanonicalUrl(publication, area, documentid);
+                writeDCIdentifier(publication, url);
+            } else {
+                for (int i = 0; i < labels.length; i++) {
+                    language = labels[i].getLanguage();
+                    url = builder.buildCanonicalUrl(publication, area, documentid, language);
+                    writeDCIdentifier(publication, url);
+                }
+            }
+        } catch (DocumentException e1) {
+            throw new BuildException(e1);
+        } catch (DocumentBuildException e2) {
+            throw new BuildException(e2);
+        }
+    }
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java Tue Sep 11 14:39:37 2007
@@ -14,9 +14,7 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.cocoon.acting;
 
 import java.io.File;
@@ -28,11 +26,9 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
-
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
-
 import org.apache.commons.io.FilenameUtils;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.acting.AbstractConfigurableAction;
@@ -50,72 +46,62 @@
 import org.w3c.dom.Element;
 
 /**
- * The class <code>UploadAction</code> implements an action that allows for asset and content
- * upload. An upload consists of a file upload plus optionally a file creation for the meta data of
- * the asset.
+ * The class <code>UploadAction</code> implements an action that allows for
+ * asset and content upload. An upload consists of a file upload plus optionally
+ * a file creation for the meta data of the asset.
  * 
  * Also see org.apache.lenya.cms.authoring.UploadHelper
  */
 public class UploadAction extends AbstractConfigurableAction {
-
     private Document document;
     private PageEnvelope pageEnvelope;
-
     public static final String UPLOADASSET_PARAM_NAME = "properties.asset.data";
     public static final String UPLOADASSET_PARAM_PREFIX = "properties.asset.";
-
     public static final String UPLOADASSET_RETURN_FILESIZE = "file-size";
     public static final String UPLOADASSET_RETURN_MIMETYPE = "mime-type";
-
     public static final String CONTENT_PREFIX = "content";
-
     public static final String FILE_NAME_REGEXP = "[-a-zA-Z0-9_.]+";
-
     // optional parameters for meta data according to dublin core
-    public static final String[] DUBLIN_CORE_PARAMETERS = { "title", "creator", "subject",
-            "description", "publisher", "contributor", "date", "type", "format", "identifier",
-            "source", "language", "relation", "coverage", "rights" };
-
+    public static final String[] DUBLIN_CORE_PARAMETERS = { "title", "creator", "subject", "description", "publisher", "contributor", "date", "type", "format", "identifier", "source", "language", "relation", "coverage", "rights" };
     /**
-     * Retrieve the file from the request and store it in the corresponding directory, optionally
-     * create a meta file and optionally insert an image tag in the requesting document.
+     * Retrieve the file from the request and store it in the corresponding
+     * directory, optionally create a meta file and optionally insert an image
+     * tag in the requesting document.
      * 
-     * @param redirector a <code>Redirector</code> value
-     * @param resolver a <code>SourceResolver</code> value
-     * @param objectModel a <code>Map</code> value
-     * @param source a <code>String</code> value
-     * @param parameters a <code>Parameters</code> value
+     * @param redirector
+     *            a <code>Redirector</code> value
+     * @param resolver
+     *            a <code>SourceResolver</code> value
+     * @param objectModel
+     *            a <code>Map</code> value
+     * @param source
+     *            a <code>String</code> value
+     * @param parameters
+     *            a <code>Parameters</code> value
      * 
-     * @return a <code>Map</code> containing the referer or null if the name of the file to be
-     *         uploaded contains characters that are not allowed (@see FILE_NAME_REGEXP).
+     * @return a <code>Map</code> containing the referer or null if the name
+     *         of the file to be uploaded contains characters that are not
+     *         allowed (@see FILE_NAME_REGEXP).
      * 
-     * @exception Exception if an error occurs
+     * @exception Exception
+     *                if an error occurs
      */
-    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source,
-            Parameters parameters) throws Exception {
-
+    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception {
         Map results = new HashMap();
         Request request = ObjectModelHelper.getRequest(objectModel);
         pageEnvelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
         document = pageEnvelope.getDocument();
-
         File assetFile;
-
         logRequestParameters(request);
-
         // determine if the upload is an asset or a content upload
         String uploadType = request.getParameter("uploadtype");
-
         // make asset upload the default if it is not specified
         if (uploadType == null) {
             uploadType = "asset";
         }
-
         Map dublinCoreParams = getDublinCoreParameters(request);
-
         // upload the file to the uploadDir
         Part part = (Part) request.get(UPLOADASSET_PARAM_NAME);
-
         String fileName = part.getFileName();
         if (!fileName.matches(FILE_NAME_REGEXP) || FilenameUtils.getExtension(fileName).equals("")) {
             // the file name contains characters which mean trouble
@@ -127,44 +113,38 @@
         fileName = fileName.replace(' ', '_');
         String mimeType = part.getMimeType();
         int fileSize = part.getSize();
-
         results.put(UPLOADASSET_RETURN_MIMETYPE, mimeType);
         results.put(UPLOADASSET_RETURN_FILESIZE, new Integer(fileSize));
-
         dublinCoreParams.put("format", mimeType);
         dublinCoreParams.put("extent", Integer.toString(fileSize));
-
         if (uploadType.equals("asset")) {
             ResourcesManager resourcesMgr = new ResourcesManager(document);
             assetFile = new File(resourcesMgr.getPath(), fileName);
-
             if (!resourcesMgr.getPath().exists()) {
                 resourcesMgr.getPath().mkdirs();
             }
-
             // create an extra file containing the meta description for
             // the asset.
             File metaDataFile = new File(resourcesMgr.getPath(), fileName + ".meta");
             createMetaData(metaDataFile, dublinCoreParams);
-
         }
         // must be a content upload then
         else {
             assetFile = new File(document.getFile().getParent(), fileName);
             getLogger().debug("assetFile: " + assetFile);
         }
-
         saveAsset(assetFile, part);
-
         return Collections.unmodifiableMap(results);
     }
-
     /**
      * Saves the asset to a file.
      * 
-     * @param assetFile The asset file.
-     * @param part The part of the multipart request.
-     * @throws Exception if an error occurs.
+     * @param assetFile
+     *            The asset file.
+     * @param part
+     *            The part of the multipart request.
+     * @throws Exception
+     *             if an error occurs.
      */
     protected void saveAsset(File assetFile, Part part) throws Exception {
         if (!assetFile.exists()) {
@@ -172,14 +152,12 @@
             if (!created) {
                 throw new RuntimeException("The file [" + assetFile + "] could not be created.");
             }
-	}
-
+        }
         byte[] buf = new byte[4096];
         FileOutputStream out = new FileOutputStream(assetFile);
         try {
             InputStream in = part.getInputStream();
             int read = in.read(buf);
-
             while (read > 0) {
                 out.write(buf, 0, read);
                 read = in.read(buf);
@@ -188,77 +166,69 @@
             out.close();
         }
     }
-
     /**
      * Logs the request parameters.
-     * @param request The request.
+     * 
+     * @param request
+     *            The request.
      */
     protected void logRequestParameters(Request request) {
         for (Enumeration myenum = request.getParameterNames(); myenum.hasMoreElements();) {
             String param = (String) myenum.nextElement();
-            getLogger().debug(
-                    param + ": " + request.getParameter(param) + " [" + request.get(param) + "]");
+            getLogger().debug(param + ": " + request.getParameter(param) + " [" + request.get(param) + "]");
         }
     }
-
     /**
-     * Retrieves optional parameters for the meta file which contains dublin core information from
-     * the request.
-     * @param request The request.
+     * Retrieves optional parameters for the meta file which contains dublin
+     * core information from the request.
+     * 
+     * @param request
+     *            The request.
      * @return A map.
      */
     protected Map getDublinCoreParameters(Request request) {
         HashMap dublinCoreParams = new HashMap();
-
         for (int i = 0; i < DUBLIN_CORE_PARAMETERS.length; i++) {
             String paramName = DUBLIN_CORE_PARAMETERS[i];
             String paramValue = request.getParameter(UPLOADASSET_PARAM_PREFIX + paramName);
-
             if (paramValue == null) {
                 paramValue = "";
             }
-
             dublinCoreParams.put(paramName, paramValue);
         }
-        
         Iterator iter = dublinCoreParams.keySet().iterator();
         while (iter.hasNext()) {
             String paramName = (String) iter.next();
             getLogger().debug(paramName + ": " + dublinCoreParams.get(paramName));
         }
-        
         return dublinCoreParams;
     }
-
     /**
      * Create the meta data file given the dublin core parameters.
      * 
-     * @param metaDataFile the file where the meta data file is to be created
-     * @param dublinCoreParams a <code>Map</code> containing the dublin core values
-     * @throws TransformerConfigurationException if an error occurs.
-     * @throws TransformerException if an error occurs.
-     * @throws IOException if an error occurs
-     * @throws ParserConfigurationException if an error occurs.
+     * @param metaDataFile
+     *            the file where the meta data file is to be created
+     * @param dublinCoreParams
+     *            a <code>Map</code> containing the dublin core values
+     * @throws TransformerConfigurationException
+     *             if an error occurs.
+     * @throws TransformerException
+     *             if an error occurs.
+     * @throws IOException
+     *             if an error occurs
+     * @throws ParserConfigurationException
+     *             if an error occurs.
      */
-    protected void createMetaData(File metaDataFile, Map dublinCoreParams)
-            throws TransformerConfigurationException, TransformerException, IOException,
-            ParserConfigurationException {
-
-        assert (metaDataFile.getParentFile().exists());
-
-        NamespaceHelper helper = new NamespaceHelper("http://purl.org/dc/elements/1.1/", "dc",
-                "metadata");
-
+    protected void createMetaData(File metaDataFile, Map dublinCoreParams) throws TransformerConfigurationException, TransformerException, IOException, ParserConfigurationException {
+        // assert (metaDataFile.getParentFile().exists());
+        NamespaceHelper helper = new NamespaceHelper("http://purl.org/dc/elements/1.1/", "dc", "metadata");
         Element root = helper.getDocument().getDocumentElement();
-
         Iterator iter = dublinCoreParams.keySet().iterator();
-
         while (iter.hasNext()) {
             String tagName = (String) iter.next();
             String tagValue = (String) dublinCoreParams.get(tagName);
             root.appendChild(helper.createElement(tagName, tagValue));
         }
-
         DocumentHelper.writeDocument(helper.getDocument(), metaDataFile);
     }
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java Tue Sep 11 14:39:37 2007
@@ -14,14 +14,11 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.cocoon.acting;
 
 import java.util.Collections;
 import java.util.Map;
-
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.acting.AbstractAction;
 import org.apache.cocoon.environment.Redirector;
@@ -38,38 +35,30 @@
 import org.apache.lenya.workflow.SynchronizedWorkflowInstances;
 
 /**
- * Action to invoke a workflow transition independently from the request document URL.
- * Parameters:
+ * Action to invoke a workflow transition independently from the request
+ * document URL. Parameters:
  * <ul>
- *   <li><strong>area:</strong> The area.</li>
- *   <li><strong>document-id:</strong> The document id.</li>
- *   <li><strong>language:</strong> The language.</li>
- *   <li><strong>event:</strong> The event to invoke.</li>
+ * <li><strong>area:</strong> The area.</li>
+ * <li><strong>document-id:</strong> The document id.</li>
+ * <li><strong>language:</strong> The language.</li>
+ * <li><strong>event:</strong> The event to invoke.</li>
  * </ul>
  */
 public class WorkflowInvokerAction extends AbstractAction {
-
     public static final String AREA = "area";
     public static final String DOCUMENT_ID = "document-id";
     public static final String LANGUAGE = "language";
     public static final String EVENT = "event";
-
     /**
-     * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
+     * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector,
+     *      org.apache.cocoon.environment.SourceResolver, java.util.Map,
+     *      java.lang.String, org.apache.avalon.framework.parameters.Parameters)
      */
-    public Map act(
-        Redirector redirector,
-        SourceResolver resolver,
-        Map objectModel,
-        String source,
-        Parameters parameters)
-        throws Exception {
-
+    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception {
         String area = parameters.getParameter(AREA);
         String documentId = parameters.getParameter(DOCUMENT_ID);
         String language = parameters.getParameter(LANGUAGE);
         String eventName = parameters.getParameter(EVENT);
-
         if (getLogger().isDebugEnabled()) {
             getLogger().debug(getClass().getName() + " invoked.");
             getLogger().debug("    Area:        [" + area + "]");
@@ -77,41 +66,32 @@
             getLogger().debug("    Language:    [" + language + "]");
             getLogger().debug("    Event:       [" + eventName + "]");
         }
-
         PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
         Publication publication = envelope.getPublication();
         DocumentBuilder builder = publication.getDocumentBuilder();
         String url = builder.buildCanonicalUrl(publication, area, documentId, language);
         Document document = builder.buildDocument(publication, url);
-
         WorkflowFactory factory = WorkflowFactory.newInstance();
-
         if (factory.hasWorkflow(document)) {
-
             if (getLogger().isDebugEnabled()) {
                 getLogger().debug("    Invoking workflow event");
             }
-
             SynchronizedWorkflowInstances instance = factory.buildSynchronizedInstance(document);
             Situation situation = WorkflowHelper.buildSituation(objectModel);
             Event[] events = instance.getExecutableEvents(situation);
             Event event = null;
-
             for (int i = 0; i < events.length; i++) {
                 if (events[i].getName().equals(eventName)) {
                     event = events[i];
                 }
             }
-
-            assert event != null;
+            // assert event != null;
             instance.invoke(situation, event);
         } else {
             if (getLogger().isDebugEnabled()) {
                 getLogger().debug("    Document has no workflow.");
             }
         }
-
         return Collections.EMPTY_MAP;
     }
-
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java Tue Sep 11 14:39:37 2007
@@ -2,236 +2,222 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.net.URI;
 import java.net.MalformedURLException;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 import java.util.StringTokenizer;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceFactory;
-import org.apache.excalibur.source.URIAbsolutizer;
-import org.apache.excalibur.source.impl.FileSource;
+import org.apache.avalon.framework.component.Component;
 import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.components.CocoonComponentManager;
 import org.apache.cocoon.components.ContextHelper;
-import org.apache.excalibur.source.SourceUtil;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceFactory;
 import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceUtil;
+import org.apache.excalibur.source.URIAbsolutizer;
 import org.apache.lenya.cms.content.Content;
-import org.apache.lenya.cms.publication.Modules;
+import org.apache.lenya.cms.content.Resource;
 import org.apache.lenya.cms.publication.PageEnvelope;
-import org.apache.lenya.cms.publication.PageEnvelopeException;
 import org.apache.lenya.cms.publication.PageEnvelopeFactory;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationFactory;
-
-import org.apache.lenya.cms.content.Resource;
 import org.w3c.dom.Document;
 
-
 /**
- * Implements content: protocol.
- * This should call the Content API that calls a Content Impl.
- * 
- * == Content API ==
- * Source getResourceByUNID(String unid, String translation, String revision)
- * Source getResourceByID(String structure, String id, String translation, String revision)
- * 
- * == Content Impls ==
- * ContentHierarchical (Lenya 1.2)
- * ContentFlat (Lenya 1.3)
+ * Implements content: protocol. This should call the Content API that calls a
+ * Content Impl.
+ *  == Content API == Source getResourceByUNID(String unid, String translation,
+ * String revision) Source getResourceByID(String structure, String id, String
+ * translation, String revision)
+ *  == Content Impls == ContentHierarchical (Lenya 1.2) ContentFlat (Lenya 1.3)
  */
-
-
-public class ContentSourceFactory
-    implements SourceFactory, ThreadSafe, URIAbsolutizer, Contextualizable {
-
+public class ContentSourceFactory implements SourceFactory, ThreadSafe, URIAbsolutizer, Contextualizable {
     private static final int REQUEST_DATA = 0;
     private static final int REQUEST_META = 1;
     private static final int REQUEST_INFO = 2;
-
     protected org.apache.avalon.framework.context.Context context;
     private String servletContextPath;
     String pubsPrefix;
     DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
     SourceResolver resolver = null;
-
-    public void contextualize(org.apache.avalon.framework.context.Context context)
-    throws ContextException {
+    public void contextualize(org.apache.avalon.framework.context.Context context) throws ContextException {
         this.context = context;
     }
-
     public Source getSource(String plocation, Map parameters) throws IOException, MalformedURLException {
-       String location = plocation;
-       int pos;
-       Map contextmap = ContextHelper.getObjectModel(context);
-       org.apache.cocoon.environment.http.HttpContext httpcontext = 
-             (org.apache.cocoon.environment.http.HttpContext) contextmap.get("context");
-       servletContextPath = httpcontext.getRealPath("");
-//TODO: Move resolver, pubsPrefix and other init out of getSource().  Make static?
+        String location = plocation;
+        int pos;
+        Map contextmap = ContextHelper.getObjectModel(context);
+        org.apache.cocoon.environment.http.HttpContext httpcontext = (org.apache.cocoon.environment.http.HttpContext) contextmap.get("context");
+        servletContextPath = httpcontext.getRealPath("");
+        // TODO: Move resolver, pubsPrefix and other init out of getSource(). Make
+        // static?
         ComponentManager manager = CocoonComponentManager.getSitemapComponentManager();
-        try{
-           resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
-        }catch(org.apache.avalon.framework.component.ComponentException ce){
+        try {
+            resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+        } catch (org.apache.avalon.framework.component.ComponentException ce) {
         }
-        if(null == resolver){
-           throw new SourceNotFoundException("No Resolver: " + plocation);
+        if (null == resolver) {
+            throw new SourceNotFoundException("No Resolver: " + plocation);
         }
         String uri = resolver.resolveURI("").getURI();
         pos = uri.indexOf("/pubs/");
-        if(pos > 0){
-           pubsPrefix = uri.substring(0, pos + 6);
-        }else{
-           pos = uri.indexOf("/modules/");
-           if(pos > 0){
-              pubsPrefix = uri.substring(0, pos) + "/pubs/";
-           }
-        }
-       String publication;
-       String contentpath;
-       Publication pub;
-       Content content;
-       try{
-            PageEnvelope envelope = 
-                  PageEnvelopeFactory.getInstance().getPageEnvelope(ContextHelper.getObjectModel(context));
+        if (pos > 0) {
+            pubsPrefix = uri.substring(0, pos + 6);
+        } else {
+            pos = uri.indexOf("/modules/");
+            if (pos > 0) {
+                pubsPrefix = uri.substring(0, pos) + "/pubs/";
+            }
+        }
+        String publication;
+        String contentpath;
+        Publication pub;
+        Content content;
+        try {
+            PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(ContextHelper.getObjectModel(context));
             pub = envelope.getPublication();
             publication = pub.getId();
             content = pub.getContent();
             contentpath = pub.getContentDirectory().getAbsolutePath() + File.separator;
-        }catch(org.apache.lenya.cms.publication.PageEnvelopeException pee){
+        } catch (org.apache.lenya.cms.publication.PageEnvelopeException pee) {
             throw new MalformedURLException("Could not get Publication ID.");
         }
-
-       //Revision
-       String revision = "live";
-       pos = location.lastIndexOf("!");
-       if(pos != -1){
-          revision = location.substring(pos + 1);
-          location = location.substring(0, pos);
-       }
-       //Language
-       String language = "";
-       pos = location.lastIndexOf("_");
-       if(pos != -1){
-          language = location.substring(pos + 1);
-          location = location.substring(0, pos);
-       }
-//TODO: Set language to document or publication's default if not specified.
-
-//System.out.println("LOC="+location);
-       // Decide Usage
-       StringTokenizer tokens = new StringTokenizer(location, "/:", true);
-       if(!tokens.hasMoreTokens()) throw new MalformedURLException("Nothing specified.");
-       String token = tokens.nextToken();
-       if(location.indexOf(":") > 0) token = tokens.nextToken();  //Remove protocol
-       int colonCount = 0;
-       while(token.equals(":")){
-         colonCount++;
-         token = tokens.nextToken();
-       }
-       int slashCount = 0;
-       while(token.equals("/")){
-         slashCount++;
-         token = tokens.nextToken();
-       }
-       int requestType = colonCount - 1;
-       boolean isFormat2 = false;
-       if(token.equals("DATA")){
-          requestType = REQUEST_DATA;
-          isFormat2 = true;
-       }else if(token.equals("META")){
-          requestType = REQUEST_META;
-          isFormat2 = true;
-       }else if(token.equals("INFO")){
-          requestType = REQUEST_INFO;
-          isFormat2 = true;
-       }
-       if(isFormat2){
-          token = tokens.nextToken();
-          int slashCount2 = 0;
-          while(token.equals("/")){
-             slashCount2++;
-             token = tokens.nextToken();
-          }
-          slashCount = (slashCount > slashCount2 ? slashCount : slashCount2);
-       }
-//System.out.println("SL=" + slashCount + "TOK=" + token);
-       String structure = "";
-       String unid = "";
-       String fullid = "";
-       if(slashCount == 1){
-          if(tokens.hasMoreTokens()){
-             slashCount = 0;
-          }else unid = token;
-       }
-       if((slashCount == 0) || (slashCount == 2)){
-          structure = token;
-       }
-       if((slashCount == 0) || (slashCount == 2)|| (slashCount == 3)){
-          StringBuffer buffer = new StringBuffer();
-          while(tokens.hasMoreTokens()) buffer.append(tokens.nextToken());
-          fullid = buffer.toString();
-       }
-       // Convert fullid to unid
-       if(unid.length() < 1){
-          unid = content.getUNID(structure, fullid);
-       }
-       // Defaults
-       if(language.length() < 1){
-          Resource resource = content.getResource(unid);
-          if(resource != null) language = resource.getDefaultLanguage();
-       }
-       if(language.length() < 1) language = pub.getDefaultLanguage();
-
-       /********** Get Source (uses Content) *************/
-       Source source;
-       if(REQUEST_INFO == requestType){
-//TODO: Catch errors
-          Resource resource = content.getResource(unid);
-if(resource == null) System.out.println("NO RESOURCE");
-          Document doc = resource.getInfoDocument();
-if(doc == null) System.out.println("NO DOC");
-          source = new StringSource(manager, doc);
-if(source == null) System.out.println("NO SOURCE");
-          return source;
-       }
-       if(REQUEST_META == requestType){
-          source = resolver.resolveURI(content.getMetaURI(unid, language, revision));
-          if(source.exists()){
-             if (resolver != null) manager.release(resolver);
-             return source;
-          }
-       }
-//System.out.println("CSF UNID=" + unid + " LANG=" + language + "  REV=" + revision);
-      
-       String curi = content.getURI(unid, language, revision);
-//System.out.println("CSF CURI=" + curi);
-       source = resolver.resolveURI(curi);
-       if(source.exists()){
-          if (resolver != null) manager.release(resolver);
-          return source;
-       }
-       if (resolver != null) manager.release(resolver);
-       throw new SourceNotFoundException("Not found: " + plocation + " (" + curi + ")");
+        // Revision
+        String revision = "live";
+        pos = location.lastIndexOf("!");
+        if (pos != -1) {
+            revision = location.substring(pos + 1);
+            location = location.substring(0, pos);
+        }
+        // Language
+        String language = "";
+        pos = location.lastIndexOf("_");
+        if (pos != -1) {
+            language = location.substring(pos + 1);
+            location = location.substring(0, pos);
+        }
+        // TODO: Set language to document or publication's default if not specified.
+        // System.out.println("LOC="+location);
+        // Decide Usage
+        StringTokenizer tokens = new StringTokenizer(location, "/:", true);
+        if (!tokens.hasMoreTokens())
+            throw new MalformedURLException("Nothing specified.");
+        String token = tokens.nextToken();
+        if (location.indexOf(":") > 0)
+            token = tokens.nextToken(); // Remove
+        // protocol
+        int colonCount = 0;
+        while (token.equals(":")) {
+            colonCount++;
+            token = tokens.nextToken();
+        }
+        int slashCount = 0;
+        while (token.equals("/")) {
+            slashCount++;
+            token = tokens.nextToken();
+        }
+        int requestType = colonCount - 1;
+        boolean isFormat2 = false;
+        if (token.equals("DATA")) {
+            requestType = REQUEST_DATA;
+            isFormat2 = true;
+        } else if (token.equals("META")) {
+            requestType = REQUEST_META;
+            isFormat2 = true;
+        } else if (token.equals("INFO")) {
+            requestType = REQUEST_INFO;
+            isFormat2 = true;
+        }
+        if (isFormat2) {
+            token = tokens.nextToken();
+            int slashCount2 = 0;
+            while (token.equals("/")) {
+                slashCount2++;
+                token = tokens.nextToken();
+            }
+            slashCount = (slashCount > slashCount2 ? slashCount : slashCount2);
+        }
+        // System.out.println("SL=" + slashCount + "TOK=" + token);
+        String structure = "";
+        String unid = "";
+        String fullid = "";
+        if (slashCount == 1) {
+            if (tokens.hasMoreTokens()) {
+                slashCount = 0;
+            } else unid = token;
+        }
+        if ((slashCount == 0) || (slashCount == 2)) {
+            structure = token;
+        }
+        if ((slashCount == 0) || (slashCount == 2) || (slashCount == 3)) {
+            StringBuffer buffer = new StringBuffer();
+            while (tokens.hasMoreTokens())
+                buffer.append(tokens.nextToken());
+            fullid = buffer.toString();
+        }
+        // Convert fullid to unid
+        if (unid.length() < 1) {
+            unid = content.getUNID(structure, fullid);
+        }
+        // Defaults
+        if (language.length() < 1) {
+            Resource resource = content.getResource(unid);
+            if (resource != null)
+                language = resource.getDefaultLanguage();
+        }
+        if (language.length() < 1)
+            language = pub.getDefaultLanguage();
+        /** ******** Get Source (uses Content) ************ */
+        Source source;
+        if (REQUEST_INFO == requestType) {
+            // TODO: Catch errors
+            Resource resource = content.getResource(unid);
+            if (resource == null)
+                System.out.println("NO RESOURCE");
+            Document doc = resource.getInfoDocument();
+            if (doc == null)
+                System.out.println("NO DOC");
+            source = new StringSource(manager, doc);
+            if (source == null)
+                System.out.println("NO SOURCE");
+            return source;
+        }
+        if (REQUEST_META == requestType) {
+            source = resolver.resolveURI(content.getMetaURI(unid, language, revision));
+            if (source.exists()) {
+                if (resolver != null)
+                    manager.release((Component) resolver);
+                return source;
+            }
+        }
+        // System.out.println("CSF UNID=" + unid + " LANG=" + language + " REV=" +
+        // revision);
+        String curi = content.getURI(unid, language, revision);
+        // System.out.println("CSF CURI=" + curi);
+        source = resolver.resolveURI(curi);
+        if (source.exists()) {
+            if (resolver != null)
+                manager.release((Component) resolver);
+            return source;
+        }
+        if (resolver != null)
+            manager.release((Component) resolver);
+        throw new SourceNotFoundException("Not found: " + plocation + " (" + curi + ")");
     }
     public void release(Source source1) {
     }
     public String absolutize(String baseURI, String location) {
         return SourceUtil.absolutize(baseURI, location, false, false);
     }
-    private Publication getPublication(String publication){
-      try{
-         return PublicationFactory.getPublication(publication, servletContextPath);
-      }catch(org.apache.lenya.cms.publication.PublicationException pe){
-         return (Publication) null;
-      }
+    private Publication getPublication(String publication) {
+        try {
+            return PublicationFactory.getPublication(publication, servletContextPath);
+        } catch (org.apache.lenya.cms.publication.PublicationException pe) {
+            return (Publication) null;
+        }
     }
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java Tue Sep 11 14:39:37 2007
@@ -8,272 +8,266 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
-
-import org.apache.cocoon.components.CocoonComponentManager;
-import org.apache.cocoon.components.ContextHelper;
-
+import org.apache.avalon.framework.component.Component;
 import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.Contextualizable;
 import org.apache.avalon.framework.thread.ThreadSafe;
-
-import org.apache.excalibur.source.impl.FileSource;
+import org.apache.cocoon.components.CocoonComponentManager;
+import org.apache.cocoon.components.ContextHelper;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceFactory;
 import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.excalibur.source.SourceUtil;
 import org.apache.excalibur.source.URIAbsolutizer;
-
+import org.apache.excalibur.source.impl.FileSource;
 import org.apache.lenya.cms.publication.Modules;
 import org.apache.lenya.cms.publication.PageEnvelope;
-import org.apache.lenya.cms.publication.PageEnvelopeException;
 import org.apache.lenya.cms.publication.PageEnvelopeFactory;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationFactory;
 
-public class ModuleSourceFactory
-    implements SourceFactory, ThreadSafe, URIAbsolutizer, Contextualizable {
-
+public class ModuleSourceFactory implements SourceFactory, ThreadSafe, URIAbsolutizer, Contextualizable {
     protected org.apache.avalon.framework.context.Context context;
     private String servletContextPath;
     String pubsPrefix;
     String globalPrefix;
-    private Set publications = new HashSet();   // Publications checked
-    static private Map moduleInheritance = new HashMap();   // Key={publication, module} Value = Next publication
-
-
-    public void contextualize(org.apache.avalon.framework.context.Context context)
-    throws ContextException {
+    private Set publications = new HashSet(); // Publications checked
+    static private Map moduleInheritance = new HashMap(); // Key={publication,
+    // module} Value =
+    // Next publication
+    public void contextualize(org.apache.avalon.framework.context.Context context) throws ContextException {
         this.context = context;
     }
-
     public Source getSource(String location, Map parameters) throws IOException, MalformedURLException {
-//System.out.println("MSF LOC=" + location);
-       int pos;
-       Map contextmap = ContextHelper.getObjectModel(context);
-       org.apache.cocoon.environment.http.HttpContext httpcontext = 
-             (org.apache.cocoon.environment.http.HttpContext) contextmap.get("context");
-       servletContextPath = httpcontext.getRealPath("");
-       SourceResolver resolver = null;
-       ComponentManager manager = CocoonComponentManager.getSitemapComponentManager();
-       try{
-           resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
-       }catch(org.apache.avalon.framework.component.ComponentException ce){
-       }
-       if(null == resolver){
-           System.out.println("ModuleSourceFactory ComponentException");
-           return new FileSource(location);
-       }
-       String uri = resolver.resolveURI("").getURI();
-       StringTokenizer tokens = new StringTokenizer(uri, "/\\:", true);
-       StringBuffer buffer = new StringBuffer();
-       boolean done = false;
-       while(tokens.hasMoreTokens() & !done){
-          String token = tokens.nextToken();
-          if(token.equalsIgnoreCase("pubs") | token.equalsIgnoreCase("modules")){
-             done = true;
-          }else buffer.append(token);
-       }
-       String tmpPrefix = buffer.toString();
-       globalPrefix = tmpPrefix + "modules" + File.separator;
-       pubsPrefix = tmpPrefix + "pubs" + File.separator;
-
-       String publication;
-       Modules modules;
-       publications.clear();
-       try{
-            PageEnvelope envelope = 
-                  PageEnvelopeFactory.getInstance().getPageEnvelope(ContextHelper.getObjectModel(context));
+        // System.out.println("MSF LOC=" + location);
+        int pos;
+        Map contextmap = ContextHelper.getObjectModel(context);
+        org.apache.cocoon.environment.http.HttpContext httpcontext = (org.apache.cocoon.environment.http.HttpContext) contextmap.get("context");
+        servletContextPath = httpcontext.getRealPath("");
+        SourceResolver resolver = null;
+        ComponentManager manager = CocoonComponentManager.getSitemapComponentManager();
+        try {
+            resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+        } catch (org.apache.avalon.framework.component.ComponentException ce) {
+        }
+        if (null == resolver) {
+            System.out.println("ModuleSourceFactory ComponentException");
+            return new FileSource(location);
+        }
+        String uri = resolver.resolveURI("").getURI();
+        StringTokenizer tokens = new StringTokenizer(uri, "/\\:", true);
+        StringBuffer buffer = new StringBuffer();
+        boolean done = false;
+        while (tokens.hasMoreTokens() & !done) {
+            String token = tokens.nextToken();
+            if (token.equalsIgnoreCase("pubs") | token.equalsIgnoreCase("modules")) {
+                done = true;
+            } else buffer.append(token);
+        }
+        String tmpPrefix = buffer.toString();
+        globalPrefix = tmpPrefix + "modules" + File.separator;
+        pubsPrefix = tmpPrefix + "pubs" + File.separator;
+        String publication;
+        Modules modules;
+        publications.clear();
+        try {
+            PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(ContextHelper.getObjectModel(context));
             Publication pub = envelope.getPublication();
             publication = pub.getId();
-		modules = pub.getModules();
-        }catch(org.apache.lenya.cms.publication.PageEnvelopeException pee){
+            modules = pub.getModules();
+        } catch (org.apache.lenya.cms.publication.PageEnvelopeException pee) {
             throw new MalformedURLException("ModuleSourceFactory PageEnvelopeException. Could not get Publication.");
         }
-
-       // Reset moduleInheritance
-       pos = location.indexOf("::");
-       if(pos != -1) moduleInheritance.clear();
-       // Decide Usage
-       pos = location.indexOf(":///");
-       int endpos;
-       String module = getModuleID(uri);
-       // BUG ALERT: 
-       // <map:mount> tries both module://module/filepath and module://module/
-       // If filepath has a default, the second attempt will error.
-       // Not having the default destroys Flow:
-       //    source = resolver.resolveURI("cocoon:/pipeline");
-       //    var is = new Packages.org.xml.sax.InputSource(source.getInputStream());
-       // This errors.
-       // Every Module must have a module.xmap (even if it is empty)!
-//       String filepath = "";
-       String filepath = "module.xmap";
-       if(pos != -1){
-          // module:/filepath/filename.ext
-          //Get current Module ID
-          filepath = location.substring(pos + 4);
-       }else{
-          pos = location.indexOf("://");
-	    if(pos != -1){
-             // module://modulename/filepath/filename.ext
-             pos += 3;
-             endpos = location.indexOf("/", pos + 1);
-             if(endpos > 0){
-                module = location.substring(pos, endpos);
-                filepath = location.substring(endpos + 1);
-//System.out.println("MSF MOD=" + module + "  FIL=" + filepath);
-             }else{
-                module = location.substring(pos);
-//System.out.println("MSF MOD=" + module + "  POS=" + pos);
-             }
-          }else{
-             pos = location.indexOf(":/");
-             if(pos != -1){
-                // module:///publication/modulename/filepath/filename.ext
-                pos += 2;
-                endpos = location.indexOf("/", pos);
-                if(endpos > 0){
-                   publication = location.substring(pos, endpos);
-                   pos = endpos + 1;
-                   endpos = location.indexOf("/", pos);
-                   if(endpos > 0){
-                      module = location.substring(pos, endpos);
-                      filepath = location.substring(endpos + 1);
-                   }else{
-                      module = location.substring(pos);
-                   }
-                }else{
-                   publication = location.substring(pos);
-                }      
-             }else{
-                // /filepath/filename.ext (Default protocol)
-                filepath = location;
-             }
-          }
-       }
-       // Verify
-       if(publication.length() < 1) throw new MalformedURLException("No Publication ID found.");
-       if(module.length() < 1) module = getModuleID(uri);
-       // BUG ALERT: See descrption above about no default 
-       if(filepath.length() < 1) filepath = "module.xmap";
-       //Check current publication
-       if(!modules.isAllowed(module)) 
-             throw new SourceNotFoundException("Not allowed: " + publication + "/" + module + "/" + filepath);
-       /********** Get Source *************/
-       //String newpath;
-       String newlocation = pubsPrefix  + publication + File.separator + "modules" + File.separator + module + File.separator + filepath;
-       // Check if exists locally.  Yes = done.
-       try{
-          Source source = resolver.resolveURI(newlocation);
-          if(source.exists()){
-            if (resolver != null) manager.release(resolver);
-             return source;
-          }
-       }catch(java.net.MalformedURLException mue2){
-       }catch(java.io.IOException ioe1){
-       }
-       publications.add(publication);
-
-       //Check inherited publication(s)
-       if(null != modules){
-          Source ret = getInheritedSource(publication, module, filepath, modules.getTemplates(module), parameters, resolver);
-          if(null != ret){
-            if (resolver != null) manager.release(resolver);
-            return ret;
-          }
-       }
-
-       // Check global
-       newlocation = globalPrefix + module + File.separator + filepath;
-       try{
-          Source source = resolver.resolveURI(newlocation);
-          if(source.exists()){
-             if (resolver != null) manager.release(resolver);
-             return source;
-          }
-       }catch(java.net.MalformedURLException mue2){
-       }catch(java.io.IOException ioe1){
-       }
-       if (resolver != null) manager.release(resolver);
-//System.out.println("Not found: " + publication + "/" + module + "/" + filepath);
-       throw new SourceNotFoundException("Not found: " + publication + "/" + module + "/" + filepath);
+        // Reset moduleInheritance
+        pos = location.indexOf("::");
+        if (pos != -1)
+            moduleInheritance.clear();
+        // Decide Usage
+        pos = location.indexOf(":///");
+        int endpos;
+        String module = getModuleID(uri);
+        // BUG ALERT:
+        // <map:mount> tries both module://module/filepath and module://module/
+        // If filepath has a default, the second attempt will error.
+        // Not having the default destroys Flow:
+        // source = resolver.resolveURI("cocoon:/pipeline");
+        // var is = new
+        // Packages.org.xml.sax.InputSource(source.getInputStream());
+        // This errors.
+        // Every Module must have a module.xmap (even if it is empty)!
+        // String filepath = "";
+        String filepath = "module.xmap";
+        if (pos != -1) {
+            // module:/filepath/filename.ext
+            // Get current Module ID
+            filepath = location.substring(pos + 4);
+        } else {
+            pos = location.indexOf("://");
+            if (pos != -1) {
+                // module://modulename/filepath/filename.ext
+                pos += 3;
+                endpos = location.indexOf("/", pos + 1);
+                if (endpos > 0) {
+                    module = location.substring(pos, endpos);
+                    filepath = location.substring(endpos + 1);
+                    // System.out.println("MSF MOD=" + module + " FIL=" + filepath);
+                } else {
+                    module = location.substring(pos);
+                    // System.out.println("MSF MOD=" + module + " POS=" + pos);
+                }
+            } else {
+                pos = location.indexOf(":/");
+                if (pos != -1) {
+                    // module:///publication/modulename/filepath/filename.ext
+                    pos += 2;
+                    endpos = location.indexOf("/", pos);
+                    if (endpos > 0) {
+                        publication = location.substring(pos, endpos);
+                        pos = endpos + 1;
+                        endpos = location.indexOf("/", pos);
+                        if (endpos > 0) {
+                            module = location.substring(pos, endpos);
+                            filepath = location.substring(endpos + 1);
+                        } else {
+                            module = location.substring(pos);
+                        }
+                    } else {
+                        publication = location.substring(pos);
+                    }
+                } else {
+                    // /filepath/filename.ext (Default protocol)
+                    filepath = location;
+                }
+            }
+        }
+        // Verify
+        if (publication.length() < 1)
+            throw new MalformedURLException("No Publication ID found.");
+        if (module.length() < 1)
+            module = getModuleID(uri);
+        // BUG ALERT: See descrption above about no default
+        if (filepath.length() < 1)
+            filepath = "module.xmap";
+        // Check current publication
+        if (!modules.isAllowed(module))
+            throw new SourceNotFoundException("Not allowed: " + publication + "/" + module + "/" + filepath);
+        /** ******** Get Source ************ */
+        // String newpath;
+        String newlocation = pubsPrefix + publication + File.separator + "modules" + File.separator + module + File.separator + filepath;
+        // Check if exists locally. Yes = done.
+        try {
+            Source source = resolver.resolveURI(newlocation);
+            if (source.exists()) {
+                if (resolver != null)
+                    manager.release((Component) resolver);
+                return source;
+            }
+        } catch (java.net.MalformedURLException mue2) {
+        } catch (java.io.IOException ioe1) {
+        }
+        publications.add(publication);
+        // Check inherited publication(s)
+        if (null != modules) {
+            Source ret = getInheritedSource(publication, module, filepath, modules.getTemplates(module), parameters, resolver);
+            if (null != ret) {
+                if (resolver != null)
+                    manager.release((Component) resolver);
+                return ret;
+            }
+        }
+        // Check global
+        newlocation = globalPrefix + module + File.separator + filepath;
+        try {
+            Source source = resolver.resolveURI(newlocation);
+            if (source.exists()) {
+                if (resolver != null)
+                    manager.release((Component) resolver);
+                return source;
+            }
+        } catch (java.net.MalformedURLException mue2) {
+        } catch (java.io.IOException ioe1) {
+        }
+        if (resolver != null)
+            manager.release((Component) resolver);
+        // System.out.println("Not found: " + publication + "/" + module + "/" +
+        // filepath);
+        throw new SourceNotFoundException("Not found: " + publication + "/" + module + "/" + filepath);
     }
-
     public void release(Source source1) {
     }
-
     public String absolutize(String baseURI, String location) {
         return SourceUtil.absolutize(baseURI, location, false, false);
     }
-   private String getModuleID(String uri) throws MalformedURLException{
+    private String getModuleID(String uri) throws MalformedURLException {
         String module = "";
         int pos = uri.indexOf("modules/");
-        if(pos > -1){
-             pos += "modules/".length();
-             int endpos = uri.indexOf("/", pos);
-             if(endpos > -1){
-               module = uri.substring(pos, endpos);
-             }else module = uri.substring(pos);
+        if (pos > -1) {
+            pos += "modules/".length();
+            int endpos = uri.indexOf("/", pos);
+            if (endpos > -1) {
+                module = uri.substring(pos, endpos);
+            } else module = uri.substring(pos);
         }
         return module;
-   }
-   private Source getInheritedSource(String publication, String modulex, String filepath, String[] templates, Map parameters, SourceResolver resolver){
-       String module = modulex;
-       int i = 0;
-       boolean found = false;
-       Modules modules = (Modules) null;
-       String key = publication + "~" + module;
-       String newpublication = "";
-       if(moduleInheritance.containsKey(key)){
-          newpublication = (String) moduleInheritance.get(key);
-          Publication pub = getPublication(newpublication);
-          modules = pub.getModules();
-          found = true;
-          publications.add(templates[i]);
-       }else{
-          while(!found & (i < templates.length)){
-             newpublication = templates[i];
-             // Do not repeat publication
-             if(!publications.contains(newpublication)){
-                modules = (Modules) null;
-                Publication pub = getPublication(newpublication);
-                if(null != pub){
-                   modules = pub.getModules();
-                   if(modules.isAllowed(module)) found = true;
+    }
+    private Source getInheritedSource(String publication, String modulex, String filepath, String[] templates, Map parameters, SourceResolver resolver) {
+        String module = modulex;
+        int i = 0;
+        boolean found = false;
+        Modules modules = (Modules) null;
+        String key = publication + "~" + module;
+        String newpublication = "";
+        if (moduleInheritance.containsKey(key)) {
+            newpublication = (String) moduleInheritance.get(key);
+            Publication pub = getPublication(newpublication);
+            modules = pub.getModules();
+            found = true;
+            publications.add(templates[i]);
+        } else {
+            while (!found & (i < templates.length)) {
+                newpublication = templates[i];
+                // Do not repeat publication
+                if (!publications.contains(newpublication)) {
+                    modules = (Modules) null;
+                    Publication pub = getPublication(newpublication);
+                    if (null != pub) {
+                        modules = pub.getModules();
+                        if (modules.isAllowed(module))
+                            found = true;
+                    }
+                    publications.add(newpublication);
                 }
-                publications.add(newpublication);
-             }
-             i++;
-          }
-       }
-       if(found){
-          moduleInheritance.put(key , newpublication);
-          String newlocation = pubsPrefix + newpublication + File.separator + "modules" + File.separator+ module + File.separator + filepath;
-          try{
-             Source source = resolver.resolveURI(newlocation);
-             if(source.exists()){
-                return source;
-             }
-          }catch(java.net.MalformedURLException mue2){
-          }catch(java.io.IOException ioe1){
-          }
-          if(null != modules){
-             //First check if module name was overridden
-             Source ret = getInheritedSource(newpublication, modules.getInheritedModule(module), 
-                   filepath, modules.getTemplates(module), parameters, resolver);
-             if(null != ret) return ret;
-             return getInheritedSource(newpublication, module, filepath, modules.getTemplates(module), parameters, resolver);
-          }
-       }
-       return (Source) null;
-   }
-   private Publication getPublication(String publication){
-      try{
-         return PublicationFactory.getPublication(publication, servletContextPath);
-      }catch(org.apache.lenya.cms.publication.PublicationException pe){
-         return (Publication) null;
-      }
-   }
+                i++;
+            }
+        }
+        if (found) {
+            moduleInheritance.put(key, newpublication);
+            String newlocation = pubsPrefix + newpublication + File.separator + "modules" + File.separator + module + File.separator + filepath;
+            try {
+                Source source = resolver.resolveURI(newlocation);
+                if (source.exists()) {
+                    return source;
+                }
+            } catch (java.net.MalformedURLException mue2) {
+            } catch (java.io.IOException ioe1) {
+            }
+            if (null != modules) {
+                // First check if module name was overridden
+                Source ret = getInheritedSource(newpublication, modules.getInheritedModule(module), filepath, modules.getTemplates(module), parameters, resolver);
+                if (null != ret)
+                    return ret;
+                return getInheritedSource(newpublication, module, filepath, modules.getTemplates(module), parameters, resolver);
+            }
+        }
+        return (Source) null;
+    }
+    private Publication getPublication(String publication) {
+        try {
+            return PublicationFactory.getPublication(publication, servletContextPath);
+        } catch (org.apache.lenya.cms.publication.PublicationException pe) {
+            return (Publication) null;
+        }
+    }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.