You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by so...@apache.org on 2008/01/31 08:44:36 UTC

svn commit: r617035 [7/22] - in /lenya/branches/revolution/1.3.x: ./ src/java/org/apache/lenya/ac/ src/java/org/apache/lenya/ac/cache/ src/java/org/apache/lenya/ac/cifs/ src/java/org/apache/lenya/ac/file/ src/java/org/apache/lenya/ac/impl/ src/java/org...

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/hierarchical/HierarchicalContent.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/hierarchical/HierarchicalContent.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/hierarchical/HierarchicalContent.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/hierarchical/HierarchicalContent.java Wed Jan 30 23:44:03 2008
@@ -1,49 +1,50 @@
 package org.apache.lenya.cms.content.hierarchical;
-
 import java.io.File;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.lenya.cms.content.Content;
 import org.apache.lenya.cms.content.Resource;
-import org.apache.lenya.cms.publication.Publication;
-
-public class HierarchicalContent implements Content{
+/**
+ * 
+ * @author solprovider
+ * @since 1.3
+ */
+public class HierarchicalContent implements Content {
    File directory;
-   String[] languages = { "en" };
-
-   public HierarchicalContent(File pdirectory, String[] planguages){
+   String[] languages = {"en"};
+   public HierarchicalContent(File pdirectory, String[] planguages) {
       directory = pdirectory;
       languages = planguages;
    }
-/* Content API */
-   public String getIndexFilename(String indexName, String language){
-     return new File(directory, indexName + File.separator + "sitetree.xml").getPath();
-//WORK?  Filter by language and transform sitetree to index XML.
+   /* Content API */
+   public String getIndexFilename(String indexName, String language) {
+      return new File(directory, indexName + File.separator + "sitetree.xml").getPath();
+      // WORK? Filter by language and transform sitetree to index XML.
    }
-   public String getUNID(String structure, String id){
+   public String getUNID(String structure, String id) {
       return id;
    }
-   public String[] getLanguages(){
+   public String[] getLanguages() {
       return languages;
    }
-   public String getURI(String unid, String language, String revision){
+   public String getURI(String unid, String language, String revision) {
       String area = revision;
-      if(area.equalsIgnoreCase("edit")) area = "authoring";
-      return new File(directory, area + unid + File.separator + "index_" + language +".xml").getPath();
+      if(area.equalsIgnoreCase("edit"))
+         area = "authoring";
+      return new File(directory, area + unid + File.separator + "index_" + language + ".xml").getPath();
    }
-   public String getMetaURI(String unid, String language, String revision){
+   public String getMetaURI(String unid, String language, String revision) {
       String area = revision;
-      if(area.equalsIgnoreCase("edit")) area = "authoring";
-      return new File(directory, area + unid + File.separator + "index_" + language +".xml").getPath();
+      if(area.equalsIgnoreCase("edit"))
+         area = "authoring";
+      return new File(directory, area + unid + File.separator + "index_" + language + ".xml").getPath();
    }
-   public String getNewURI(String unid, String language){
-      return new File(directory, "live" + unid + File.separator + getDateString() + "_" + language +".xml").getPath();
+   public String getNewURI(String unid, String language) {
+      return new File(directory, "live" + unid + File.separator + getDateString() + "_" + language + ".xml").getPath();
    }
-   private String getDateString(){
+   private String getDateString() {
       return Long.toString(new java.util.Date().getTime());
    }
-   public Resource getResource(String unid){
-//TODO: HierarchicalResource
+   public Resource getResource(String unid) {
+      // TODO: HierarchicalResource
       return (Resource) null;
    }
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/mail/MailTask.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/mail/MailTask.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/mail/MailTask.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/mail/MailTask.java Wed Jan 30 23:44:03 2008
@@ -14,166 +14,126 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.mail;
-
-
 import java.io.File;
 import java.net.URL;
 import java.util.Arrays;
-
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.lenya.cms.task.AbstractTask;
 import org.apache.lenya.net.SMTP;
 import org.apache.lenya.xml.DocumentHelper;
 import org.apache.lenya.xml.NamespaceHelper;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.Text;
-
-
 /**
- * A task that sends an e-mail. Each parameter can either be provided as a task parameter or
- * extracted from an XML document. If the parameter "uri" starts with a <code>http://</code> or
- * <code>ftp://</code> prefix, the absolute URI is used. If not, the URI is interpreted as
- * relative to the local publication. <br/
- * ><br/
- * > The task parameters are:<br/
- * ><code><strong>uri</strong></code>: the URI to get the XML file from<br/
- * ><code><strong>server</strong></code>: the SMTP server<br/
- * ><code><strong>from</strong></code>:<br/
- * ><code><strong>to</strong></code>:<br/
- * ><code><strong>cc</strong></code>:<br/
- * ><code><strong>bcc</strong></code>:<br/
- * ><code><strong>subject</strong></code>:<br/
- * ><code><strong>body</strong></code>:<br/
- * ><br/
- * > All parameters are optional. If the uri parameter is provided, the document is fetched from
- * the URI and the parameters are extracted. Task parameters have a higher priority than elements
- * of the document. <br/
- * ><br/
- * > The document has the following form:<br/
- * ><br/
- * ><code> &lt;mail:mail xmlns:mail="http://apache.org/cocoon/lenya/mail/1.0"&gt;<br/
+ * A task that sends an e-mail. Each parameter can either be provided as a task parameter or extracted from an XML document. If the parameter "uri" starts with a <code>http://</code> or <code>ftp://</code> prefix, the absolute URI is used. If not, the URI is interpreted as relative to the local publication. <br/ ><br/ > The task parameters are:<br/ ><code><strong>uri</strong></code>: the URI to get the XML file from<br/ ><code><strong>server</strong></code>: the SMTP server<br/ ><code><strong>from</strong></code>:<br/ ><code><strong>to</strong></code>:<br/ ><code><strong>cc</strong></code>:<br/ ><code><strong>bcc</strong></code>:<br/ ><code><strong>subject</strong></code>:<br/ ><code><strong>body</strong></code>:<br/ ><br/ > All parameters are optional. If the uri parameter is provided, the document is fetched from the URI and the parameters are extracted. Task parameters have a higher priority than elements of the document. <br/ ><br/ >
+ * The document has the following form:<br/ ><br/ ><code> &lt;mail:mail xmlns:mail="http://apache.org/cocoon/lenya/mail/1.0"&gt;<br/
  * > &#160;&#160;&lt;mail:server&gt;mail.yourhost.com&lt;/mail:server&gt;<br/
  * > &#160;&#160;...<br/
  * > &lt;/mail:mail&gt;<br/></code>
  */
 public class MailTask extends AbstractTask {
-    private static Category log = Category.getInstance(MailTask.class);
-    
-    public static final String ELEMENT_TO = "to";
-    public static final String ELEMENT_CC = "cc";
-    public static final String ELEMENT_BCC = "bcc";
-    public static final String ELEMENT_SUBJECT = "subject";
-    public static final String ELEMENT_BODY = "body";
-    public static final String ELEMENT_FROM = "from";
-    public static final String ELEMENT_SERVER = "server";
-    public static final String PARAMETER_URI = "uri";
-    public static final String NAMESPACE_URI = "http://apache.org/cocoon/lenya/mail/1.0";
-
-    /**
-     * DOCUMENT ME!
-     *
-     * @param contextPath DOCUMENT ME!
-     */
-    public void execute(String contextPath) {
-        log.debug("\n---------------------------" + "\n- Sending mail" +
-            "\n---------------------------");
-        try {
-            Parameters taskParameters = new Parameters();
-
-            String uri = getParameters().getParameter(PARAMETER_URI, "");
-            log.debug("\nURI: " + uri);
-
-            if (!uri.equals("")) {
-                // generate absolute URI from relative URI
-                if (!uri.startsWith("http://") && !uri.startsWith("ftp://") &&
-                        !uri.startsWith("file://")) {
-                    String absoluteUri = "http://127.0.0.1";
-                    String serverPort = getParameters().getParameter(PARAMETER_SERVER_PORT, "");
-
-                    if (!serverPort.equals("")) {
-                        absoluteUri += (":" + Integer.parseInt(serverPort));
-                    }
-
-                    absoluteUri += (getParameters().getParameter(PARAMETER_CONTEXT_PREFIX) + File.separator +
-                    getParameters().getParameter(PARAMETER_PUBLICATION_ID) + uri);
-                    uri = absoluteUri;
-                }
-                Document document = DocumentHelper.readDocument(new URL(uri));
-                Element root = document.getDocumentElement();
-
-                NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "mail", document);
-
-                String[] keys = {
-                    ELEMENT_SERVER, ELEMENT_FROM, ELEMENT_TO, ELEMENT_CC, ELEMENT_BCC,
-                    ELEMENT_SUBJECT, ELEMENT_BODY
-                };
-
-                Element[] elements = helper.getChildren(root);
-
-                for (int i = 0; i < elements.length; i++) {
-                    if (elements[i].getChildNodes().getLength() > 0) {
-                        Node firstChild = elements[i].getChildNodes().item(0);
-
-                        if (firstChild instanceof Text) {
-                            Text text = (Text) firstChild;
-                            String key = elements[i].getLocalName();
-
-                            if (Arrays.asList(keys).contains(key)) {
-                                taskParameters.setParameter(key, text.getNodeValue());
-                            }
-                        }
-                    }
-                }
+   private static Logger log = Logger.getLogger(MailTask.class);
+   public static final String ELEMENT_TO = "to";
+   public static final String ELEMENT_CC = "cc";
+   public static final String ELEMENT_BCC = "bcc";
+   public static final String ELEMENT_SUBJECT = "subject";
+   public static final String ELEMENT_BODY = "body";
+   public static final String ELEMENT_FROM = "from";
+   public static final String ELEMENT_SERVER = "server";
+   public static final String PARAMETER_URI = "uri";
+   public static final String NAMESPACE_URI = "http://apache.org/cocoon/lenya/mail/1.0";
+   /**
+    * DOCUMENT ME!
+    * 
+    * @param contextPath
+    *           DOCUMENT ME!
+    */
+   public void execute(String contextPath) {
+      log.debug("\n---------------------------" + "\n- Sending mail" + "\n---------------------------");
+      try{
+         Parameters taskParameters = new Parameters();
+         String uri = getParameters().getParameter(PARAMETER_URI, "");
+         log.debug("\nURI: " + uri);
+         if(!uri.equals("")){
+            // generate absolute URI from relative URI
+            if(!uri.startsWith("http://") && !uri.startsWith("ftp://") && !uri.startsWith("file://")){
+               String absoluteUri = "http://127.0.0.1";
+               String serverPort = getParameters().getParameter(PARAMETER_SERVER_PORT, "");
+               if(!serverPort.equals("")){
+                  absoluteUri += (":" + Integer.parseInt(serverPort));
+               }
+               absoluteUri += (getParameters().getParameter(PARAMETER_CONTEXT_PREFIX) + File.separator + getParameters().getParameter(PARAMETER_PUBLICATION_ID) + uri);
+               uri = absoluteUri;
             }
-
-            // task parameters have a higher priority than XML elements
-            taskParameters = taskParameters.merge(getParameters());
-
-            sendMail(taskParameters.getParameter(ELEMENT_SERVER),
-                taskParameters.getParameter(ELEMENT_FROM), taskParameters.getParameter(ELEMENT_TO),
-                taskParameters.getParameter(ELEMENT_CC, ""),
-                taskParameters.getParameter(ELEMENT_BCC, ""),
-                taskParameters.getParameter(ELEMENT_SUBJECT, ""),
-                taskParameters.getParameter(ELEMENT_BODY, ""));
-        } catch (Exception e) {
-            log.error("Sending mail failed: ", e);
-            throw new RuntimeException (e);
-        }
-    }
-
-    /**
-     * DOCUMENT ME!
-     *
-     * @param host DOCUMENT ME!
-     * @param from DOCUMENT ME!
-     * @param to DOCUMENT ME!
-     * @param cc DOCUMENT ME!
-     * @param bcc DOCUMENT ME!
-     * @param subject DOCUMENT ME!
-     * @param body DOCUMENT ME!
-     */
-    public void sendMail(String host, String from, String to, String cc, String bcc,
-        String subject, String body) {
-        SMTP smtp = new SMTP();
-        smtp.send(from, to, cc, bcc, subject, body);
-    }
-
-    /**
-     * DOCUMENT ME!
-     *
-     * @param host DOCUMENT ME!
-     * @param from DOCUMENT ME!
-     * @param to DOCUMENT ME!
-     * @param cc DOCUMENT ME!
-     * @param bcc DOCUMENT ME!
-     * @param subject DOCUMENT ME!
-     * @param body DOCUMENT ME!
-     */
+            Document document = DocumentHelper.readDocument(new URL(uri));
+            Element root = document.getDocumentElement();
+            NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "mail", document);
+            String[] keys = {ELEMENT_SERVER, ELEMENT_FROM, ELEMENT_TO, ELEMENT_CC, ELEMENT_BCC, ELEMENT_SUBJECT, ELEMENT_BODY};
+            Element[] elements = helper.getChildren(root);
+            for(int i = 0; i < elements.length; i++){
+               if(elements[i].getChildNodes().getLength() > 0){
+                  Node firstChild = elements[i].getChildNodes().item(0);
+                  if(firstChild instanceof Text){
+                     Text text = (Text) firstChild;
+                     String key = elements[i].getLocalName();
+                     if(Arrays.asList(keys).contains(key)){
+                        taskParameters.setParameter(key, text.getNodeValue());
+                     }
+                  }
+               }
+            }
+         }
+         // task parameters have a higher priority than XML elements
+         taskParameters = taskParameters.merge(getParameters());
+         sendMail(taskParameters.getParameter(ELEMENT_SERVER), taskParameters.getParameter(ELEMENT_FROM), taskParameters.getParameter(ELEMENT_TO), taskParameters.getParameter(ELEMENT_CC, ""), taskParameters.getParameter(ELEMENT_BCC, ""), taskParameters.getParameter(ELEMENT_SUBJECT, ""), taskParameters.getParameter(ELEMENT_BODY, ""));
+      }catch(Exception e){
+         log.error("Sending mail failed: ", e);
+         throw new RuntimeException(e);
+      }
+   }
+   /**
+    * DOCUMENT ME!
+    * 
+    * @param host
+    *           DOCUMENT ME!
+    * @param from
+    *           DOCUMENT ME!
+    * @param to
+    *           DOCUMENT ME!
+    * @param cc
+    *           DOCUMENT ME!
+    * @param bcc
+    *           DOCUMENT ME!
+    * @param subject
+    *           DOCUMENT ME!
+    * @param body
+    *           DOCUMENT ME!
+    */
+   public void sendMail(String host, String from, String to, String cc, String bcc, String subject, String body) {
+      SMTP smtp = new SMTP();
+      smtp.send(from, to, cc, bcc, subject, body);
+   }
+   /**
+    * DOCUMENT ME!
+    * 
+    * @param host
+    *           DOCUMENT ME!
+    * @param from
+    *           DOCUMENT ME!
+    * @param to
+    *           DOCUMENT ME!
+    * @param cc
+    *           DOCUMENT ME!
+    * @param bcc
+    *           DOCUMENT ME!
+    * @param subject
+    *           DOCUMENT ME!
+    * @param body
+    *           DOCUMENT ME!
+    */
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Module.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Module.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Module.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Module.java Wed Jan 30 23:44:03 2008
@@ -13,6 +13,10 @@
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.lenya.cms.content.Content;
 import org.xml.sax.SAXException;
+/**
+ * @author solprovider
+ * @since 1.3
+ */
 public abstract class Module {
    public static final String MODULE_XML = "module.xml";
    Map inheritList; // String names of other Modules in this publication.

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleGlobal.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleGlobal.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleGlobal.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleGlobal.java Wed Jan 30 23:44:03 2008
@@ -1,5 +1,10 @@
 package org.apache.lenya.cms.modules;
 import java.io.File;
+/**
+ * 
+ * @author solprovider
+ * @since 1.3
+ */
 public class ModuleGlobal extends Module {
    public ModuleGlobal(File moduleDirectory) {
       super(moduleDirectory, "");

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleInputModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleInputModule.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleInputModule.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleInputModule.java Wed Jan 30 23:44:03 2008
@@ -2,26 +2,25 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.StringTokenizer;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.cocoon.components.modules.input.AbstractPageEnvelopeModule;
 import org.apache.lenya.cms.publication.PageEnvelope;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationModules;
+import org.apache.lenya.util.Globals;
 /**
  * Retrieves Module Variables from publication.xconf and module.xml.
  * 
  * Variables are specified as <module name="modulename"><variable name="{variablename}">{value}</variable></module>
+ * 
+ * @author solprovider
+ * @since 1.3
  */
-public class ModuleInputModule extends AbstractPageEnvelopeModule implements Serviceable, ThreadSafe {
-   private ServiceManager manager;
+public class ModuleInputModule extends AbstractPageEnvelopeModule implements ThreadSafe {
+   // public class ModuleInputModule extends AbstractPageEnvelopeModule implements Serviceable, ThreadSafe {
+   // private ServiceManager manager;
    /**
     * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map)
     */
@@ -30,16 +29,17 @@
       if(getLogger().isDebugEnabled()){
          getLogger().debug("Resolving [" + name + "]");
       }
-      init();
+      // init();
+      moduleId = Globals.getModule();
       // Standard Variables
-      if(name.equalsIgnoreCase("module"))
+      if(name.equalsIgnoreCase("module")){
          return moduleId;
+      }
       // Module Variables
       PageEnvelope pe = getEnvelope(objectModel);
       Publication pub = pe.getPublication();
       PublicationModules modules = pub.getModules();
       return modules.getVariable(moduleId, name);
-//      return Modules.getModule(pub.getId(), moduleId, pub.getContentType()).getVariable(name);
    }
    /**
     * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration, java.util.Map)
@@ -54,12 +54,12 @@
       Object[] objects = {getAttribute(name, modeConf, objectModel)};
       return objects;
    }
-   /**
-    * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-    */
-   public void service(ServiceManager manager) throws ServiceException {
-      this.manager = manager;
-   }
+   // /**
+   // * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+   // */
+   // public void service(ServiceManager manager) throws ServiceException {
+   // this.manager = manager;
+   // }
    /**
     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
     */
@@ -67,24 +67,29 @@
       super.configure(conf);
    }
    private void init() {
-      String uri = "";
-      try{
-         SourceResolver resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
-         Source source = resolver.resolveURI("");
-         uri = source.getURI();
-         if(resolver != null)
-            manager.release(resolver);
-      }catch(org.apache.avalon.framework.service.ServiceException se){
-         // Report Error?
-      }catch(java.net.MalformedURLException mue){
-         // Report Error?
-      }catch(java.io.IOException ioe){
-         // Report Error?
-      }
-      // TODO: Release resolver
-      StringTokenizer tokens = new StringTokenizer(uri, "/");
-      while(tokens.hasMoreTokens() && !(tokens.nextToken().equals("modules")));
-      if(tokens.hasMoreTokens())
-         moduleId = tokens.nextToken();
+      // ## Set ModuleId
+      // OBSOLETE: Following code replaced by Globals.getModule()
+      // String uri = "";
+      // try{
+      // SourceResolver resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+      // Source source = resolver.resolveURI("");
+      // uri = source.getURI();
+      // if(resolver != null)
+      // manager.release(resolver);
+      // }catch(org.apache.avalon.framework.service.ServiceException se){
+      // // Report Error?
+      // }catch(java.net.MalformedURLException mue){
+      // // Report Error?
+      // }catch(java.io.IOException ioe){
+      // // Report Error?
+      // }
+      // // XTODO: Release resolver
+      // StringTokenizer tokens = new StringTokenizer(uri, "/");
+      // while(tokens.hasMoreTokens() && !(tokens.nextToken().equals("modules")));
+      // if(tokens.hasMoreTokens()){
+      // moduleId = tokens.nextToken();
+      // }
+      // END OBSOLETE
+      moduleId = Globals.getModule();
    }
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSet.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSet.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSet.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSet.java Wed Jan 30 23:44:03 2008
@@ -1,5 +1,10 @@
 package org.apache.lenya.cms.modules;
 import org.apache.lenya.cms.content.Content;
+/**
+ * 
+ * @author solprovider
+ * @since 1.3
+ */
 public class ModuleSet {
    Module flat = null;
    Module hierarchical = null;

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSourceFactory.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSourceFactory.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSourceFactory.java Wed Jan 30 23:44:03 2008
@@ -1,5 +1,4 @@
 package org.apache.lenya.cms.modules;
-import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.util.Map;
@@ -23,7 +22,7 @@
  * 2000125: Integrated with org.apache.lenya.cms.modules
  * 
  * @author solprovider
- * 
+ * @since 1.3
  */
 public class ModuleSourceFactory implements SourceFactory, ThreadSafe, URIAbsolutizer, Contextualizable {
    protected org.apache.avalon.framework.context.Context context;
@@ -119,19 +118,11 @@
       // BUG ALERT: See description above about no default
       if(filepath.length() < 1)
          filepath = "module.xmap";
-      // ## Get Module - BEGIN
-      // System.out.println("GetFile P=" + publication + " M=" + moduleId + " R=" + filepath);
       String newlocation = pub.getModules().getFile(moduleId, filepath, needsReset);
-      // System.out.println("GetModule F=" + newlocation);
       if(newlocation.length() < 1)
          throw new SourceNotFoundException("Not found: " + location + " -> " + newlocation);
-      System.out.println("ModuleSource: " + newlocation);
-      FileSource source = new FileSource("file://" + newlocation);
-      System.out.println("FileSource: " + source.getURI());
-      File file = source.getFile();
-      System.out.println("File: " + file.getAbsolutePath());
-      return source;
-      // return new FileSource(newlocation);
+      // System.out.println("ModuleSource: " + newlocation);
+      return new FileSource("file://" + newlocation);
    }
    public void release(Source source1) {
    }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Modules.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Modules.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Modules.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Modules.java Wed Jan 30 23:44:03 2008
@@ -8,6 +8,7 @@
  * Singleton class containing all Modules.
  * 
  * @author solprovider
+ * @since 1.3
  */
 public class Modules {
    static Map modules;

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java Wed Jan 30 23:44:03 2008
@@ -62,7 +62,7 @@
    private File contentDirectory;
    private String contentType = Content.TYPE_HIERARCHICAL;
    // Lenya1.3 - END
-   //TODO: Reload Publication
+   // TODO: Reload Publication
    /**
     * Creates a new instance of Publication
     * 
@@ -165,7 +165,7 @@
             content = (Content) new HierarchicalContent(contentDirectory, getLanguages());
          }
          // Modules
-         modules = new PublicationModules(id, contentType, servletContextPath, config.getChild("modules"));
+         modules = new PublicationModules(id, contentType, config.getChild("modules"));
          // Lenya1.3 - END
       }catch(PublicationException e){
          throw e;

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/CollectionImpl.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/CollectionImpl.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/CollectionImpl.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/CollectionImpl.java Wed Jan 30 23:44:03 2008
@@ -14,265 +14,245 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.publication;
-
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-
 import javax.xml.parsers.ParserConfigurationException;
-
 import org.apache.lenya.xml.DocumentHelper;
 import org.apache.lenya.xml.NamespaceHelper;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
 import org.apache.xpath.XPathAPI;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
-
 /**
  * Implementation of a Collection.
  */
 public class CollectionImpl extends DefaultDocument implements Collection {
-    
-    private static final Category log = Category.getInstance(CollectionImpl.class);
-
-    /**
-     * Ctor.
-     * @param publication A publication.
-     * @param id The document ID.
-     * @param area The area the document belongs to.
-     * @throws DocumentException when something went wrong.
-     */
-    public CollectionImpl(Publication publication, String id, String area) throws DocumentException {
-        super(publication, id, area);
-    }
-
-    /**
-     * Ctor.
-     * @param publication A publication.
-     * @param id The document ID.
-     * @param area The area the document belongs to.
-     * @param language The language of the document.
-     * @throws DocumentException when something went wrong.
-     */
-    public CollectionImpl(Publication publication, String id, String area, String language) throws DocumentException {
-        super(publication, id, area, language);
-    }
-
-    private List documentsList = new ArrayList();
-    
-    /**
-     * Returns the list that holds the documents. Use this method to invoke lazy loading.
-     * @return A list.
-     * @throws DocumentException when something went wrong.
-     */
-    protected List documents() throws DocumentException {
-        load();
-        return documentsList;
-    }
-
-    /**
-     * @see org.apache.lenya.cms.publication.Collection#getDocuments()
-     */
-    public Document[] getDocuments() throws DocumentException {
-        return (Document[]) documents().toArray(new Document[documents().size()]);
-    }
-
-    /**
-     * @see org.apache.lenya.cms.publication.Collection#add(org.apache.lenya.cms.publication.Document)
-     */
-    public void add(Document document) throws DocumentException {
-        documents().add(document);
-        save();
-    }
-
-    /**
-     * @see org.apache.lenya.cms.publication.Collection#add(int, org.apache.lenya.cms.publication.Document)
-     */
-    public void add(int position, Document document) throws DocumentException {
-        documents().add(position, document);
-        save();
-    }
-
-    /**
-     * @see org.apache.lenya.cms.publication.Collection#remove(org.apache.lenya.cms.publication.Document)
-     */
-    public void remove(Document document) throws DocumentException {
-        if (!documents().contains(document)) {
-            throw new DocumentException(
-                "Collection [" + this +"] does not contain document [" + document + "]");
-        }
-        documents().remove(document);
-        save();
-    }
-
-    private boolean isLoaded = false;
-
-    /**
-     * Loads the collection from its XML source.
-     * @throws DocumentException when something went wrong.
-     */
-    protected void load() throws DocumentException {
-        if (!isLoaded) {
-            log.debug("Loading: ", new DocumentException());
-            NamespaceHelper helper;
-            try {
-                helper = getNamespaceHelper();
-
-                Element collectionElement = helper.getDocument().getDocumentElement();
-                Element[] documentElements =
-                    helper.getChildren(collectionElement, ELEMENT_DOCUMENT);
-
-                for (int i = 0; i < documentElements.length; i++) {
-                    Element documentElement = documentElements[i];
-                    Document document = loadDocument(documentElement);
-                    documentsList.add(document);
-                }
-            } catch (DocumentException e) {
-                throw e;
-            } catch (Exception e) {
-                throw new DocumentException(e);
-            }
-            isLoaded = true;
-        }
-    }
-
-    /**
-     * Loads a document from an XML element.
-     * @param documentElement The XML element.
-     * @return A document.
-     * @throws DocumentBuildException when something went wrong.
-     */
-    protected Document loadDocument(Element documentElement) throws DocumentBuildException {
-        DocumentBuilder builder = getPublication().getDocumentBuilder();
-        String documentId = documentElement.getAttribute(ATTRIBUTE_ID);
-        String url =
-            builder.buildCanonicalUrl(
-                getPublication(),
-                getArea(),
-                documentId,
-                getLanguage());
-        Document document = builder.buildDocument(getPublication(), url);
-        return document;
-    }
-
-    /**
-     * Saves the XML source of this collection.
-     * @throws DocumentException when something went wrong.
-     */
-    public void save() throws DocumentException {
-        try {
-            
-            NamespaceHelper helper = getNamespaceHelper();
+   private static Logger log = Logger.getLogger(CollectionImpl.class);
+   /**
+    * Ctor.
+    * 
+    * @param publication
+    *           A publication.
+    * @param id
+    *           The document ID.
+    * @param area
+    *           The area the document belongs to.
+    * @throws DocumentException
+    *            when something went wrong.
+    */
+   public CollectionImpl(Publication publication, String id, String area) throws DocumentException {
+      super(publication, id, area);
+   }
+   /**
+    * Ctor.
+    * 
+    * @param publication
+    *           A publication.
+    * @param id
+    *           The document ID.
+    * @param area
+    *           The area the document belongs to.
+    * @param language
+    *           The language of the document.
+    * @throws DocumentException
+    *            when something went wrong.
+    */
+   public CollectionImpl(Publication publication, String id, String area, String language) throws DocumentException {
+      super(publication, id, area, language);
+   }
+   private List documentsList = new ArrayList();
+   /**
+    * Returns the list that holds the documents. Use this method to invoke lazy loading.
+    * 
+    * @return A list.
+    * @throws DocumentException
+    *            when something went wrong.
+    */
+   protected List documents() throws DocumentException {
+      load();
+      return documentsList;
+   }
+   /**
+    * @see org.apache.lenya.cms.publication.Collection#getDocuments()
+    */
+   public Document[] getDocuments() throws DocumentException {
+      return (Document[]) documents().toArray(new Document[documents().size()]);
+   }
+   /**
+    * @see org.apache.lenya.cms.publication.Collection#add(org.apache.lenya.cms.publication.Document)
+    */
+   public void add(Document document) throws DocumentException {
+      documents().add(document);
+      save();
+   }
+   /**
+    * @see org.apache.lenya.cms.publication.Collection#add(int, org.apache.lenya.cms.publication.Document)
+    */
+   public void add(int position, Document document) throws DocumentException {
+      documents().add(position, document);
+      save();
+   }
+   /**
+    * @see org.apache.lenya.cms.publication.Collection#remove(org.apache.lenya.cms.publication.Document)
+    */
+   public void remove(Document document) throws DocumentException {
+      if(!documents().contains(document)){
+         throw new DocumentException("Collection [" + this + "] does not contain document [" + document + "]");
+      }
+      documents().remove(document);
+      save();
+   }
+   private boolean isLoaded = false;
+   /**
+    * Loads the collection from its XML source.
+    * 
+    * @throws DocumentException
+    *            when something went wrong.
+    */
+   protected void load() throws DocumentException {
+      if(!isLoaded){
+         log.debug("Loading: ", new DocumentException());
+         NamespaceHelper helper;
+         try{
+            helper = getNamespaceHelper();
             Element collectionElement = helper.getDocument().getDocumentElement();
-            if (collectionElement.getAttributeNS(null, ATTRIBUTE_ID) == null | collectionElement.getAttribute(ATTRIBUTE_ID).equals("")) {
-                collectionElement.setAttributeNS(null, ATTRIBUTE_ID, this.getId());
-            }                   
-            Element[] existingDocumentElements = helper.getChildren(collectionElement, ELEMENT_DOCUMENT);
-            for (int i = 0; i < existingDocumentElements.length; i++) {
-                collectionElement.removeChild(existingDocumentElements[i]);
-            }
-            
-            collectionElement.normalize();
-            
-            NodeList emptyTextNodes = XPathAPI.selectNodeList(collectionElement, "text()");
-            for (int i = 0; i < emptyTextNodes.getLength(); i++) {
-                Node node = emptyTextNodes.item(i);
-                node = collectionElement.removeChild(node);
-            }
-
-            Document[] documents = getDocuments();
-            for (int i = 0; i < documents.length; i++) {
-                Element documentElement = createDocumentElement(documents[i], helper);
-                collectionElement.appendChild(documentElement);
+            Element[] documentElements = helper.getChildren(collectionElement, ELEMENT_DOCUMENT);
+            for(int i = 0; i < documentElements.length; i++){
+               Element documentElement = documentElements[i];
+               Document document = loadDocument(documentElement);
+               documentsList.add(document);
             }
-            DocumentHelper.writeDocument(helper.getDocument(), getFile());
-            
-        } catch (DocumentException e) {
+         }catch(DocumentException e){
             throw e;
-        } catch (Exception e) {
+         }catch(Exception e){
             throw new DocumentException(e);
-        }
-    }
-
-    /**
-     * Creates an element to store a document.
-     * @param helper The namespace helper of the document.
-     * @param document The document.
-     * @return An XML element.
-     * @throws DocumentException when something went wrong.
-     */
-    protected Element createDocumentElement(Document document, NamespaceHelper helper)
-        throws DocumentException {
-        Element documentElement = helper.createElement(ELEMENT_DOCUMENT);
-        documentElement.setAttributeNS(null, ATTRIBUTE_ID, document.getId());
-        return documentElement;
-    }
-
-    /**
-     * Returns the namespace helper for the XML source.
-     * @return A namespace helper.
-     * @throws DocumentException when something went wrong.
-     * @throws ParserConfigurationException when something went wrong.
-     * @throws SAXException when something went wrong.
-     * @throws IOException when something went wrong.
-     */
-    protected NamespaceHelper getNamespaceHelper()
-        throws DocumentException, ParserConfigurationException, SAXException, IOException {
-
-        NamespaceHelper helper;
-
-        if (exists()) {
-            File file = getFile();
-            org.w3c.dom.Document document = DocumentHelper.readDocument(file);
-            helper = new NamespaceHelper(Collection.NAMESPACE, Collection.DEFAULT_PREFIX, document);
-        } else {
-            helper =
-                new NamespaceHelper(
-                    Collection.NAMESPACE,
-                    Collection.DEFAULT_PREFIX,
-                    ELEMENT_COLLECTION);
-        }
-        return helper;
-    }
-
-    /**
-     * @see org.apache.lenya.cms.publication.Collection#contains(org.apache.lenya.cms.publication.Document)
-     */
-    public boolean contains(Document document) throws DocumentException {
-        return documents().contains(document);
-    }
-
-    /**
-     * @see org.apache.lenya.cms.publication.Collection#clear()
-     */
-    public void clear() throws DocumentException {
-        documents().clear();
-    }
-
-    /**
-     * @see org.apache.lenya.cms.publication.Collection#getFirstPosition(org.apache.lenya.cms.publication.Document)
-     */
-    public int getFirstPosition(Document document) throws DocumentException {
-        load();
-        if (!contains(document)) {
-            throw new DocumentException(
-                "The collection [" + this +"] does not contain the document [" + document + "]");
-        }
-        return documents().indexOf(document);
-    }
-
-    /**
-     * @see org.apache.lenya.cms.publication.Collection#size()
-     */
-    public int size() throws DocumentException {
-        return documents().size();
-    }
-
+         }
+         isLoaded = true;
+      }
+   }
+   /**
+    * Loads a document from an XML element.
+    * 
+    * @param documentElement
+    *           The XML element.
+    * @return A document.
+    * @throws DocumentBuildException
+    *            when something went wrong.
+    */
+   protected Document loadDocument(Element documentElement) throws DocumentBuildException {
+      DocumentBuilder builder = getPublication().getDocumentBuilder();
+      String documentId = documentElement.getAttribute(ATTRIBUTE_ID);
+      String url = builder.buildCanonicalUrl(getPublication(), getArea(), documentId, getLanguage());
+      Document document = builder.buildDocument(getPublication(), url);
+      return document;
+   }
+   /**
+    * Saves the XML source of this collection.
+    * 
+    * @throws DocumentException
+    *            when something went wrong.
+    */
+   public void save() throws DocumentException {
+      try{
+         NamespaceHelper helper = getNamespaceHelper();
+         Element collectionElement = helper.getDocument().getDocumentElement();
+         if(collectionElement.getAttributeNS(null, ATTRIBUTE_ID) == null | collectionElement.getAttribute(ATTRIBUTE_ID).equals("")){
+            collectionElement.setAttributeNS(null, ATTRIBUTE_ID, this.getId());
+         }
+         Element[] existingDocumentElements = helper.getChildren(collectionElement, ELEMENT_DOCUMENT);
+         for(int i = 0; i < existingDocumentElements.length; i++){
+            collectionElement.removeChild(existingDocumentElements[i]);
+         }
+         collectionElement.normalize();
+         NodeList emptyTextNodes = XPathAPI.selectNodeList(collectionElement, "text()");
+         for(int i = 0; i < emptyTextNodes.getLength(); i++){
+            Node node = emptyTextNodes.item(i);
+            node = collectionElement.removeChild(node);
+         }
+         Document[] documents = getDocuments();
+         for(int i = 0; i < documents.length; i++){
+            Element documentElement = createDocumentElement(documents[i], helper);
+            collectionElement.appendChild(documentElement);
+         }
+         DocumentHelper.writeDocument(helper.getDocument(), getFile());
+      }catch(DocumentException e){
+         throw e;
+      }catch(Exception e){
+         throw new DocumentException(e);
+      }
+   }
+   /**
+    * Creates an element to store a document.
+    * 
+    * @param helper
+    *           The namespace helper of the document.
+    * @param document
+    *           The document.
+    * @return An XML element.
+    * @throws DocumentException
+    *            when something went wrong.
+    */
+   protected Element createDocumentElement(Document document, NamespaceHelper helper) throws DocumentException {
+      Element documentElement = helper.createElement(ELEMENT_DOCUMENT);
+      documentElement.setAttributeNS(null, ATTRIBUTE_ID, document.getId());
+      return documentElement;
+   }
+   /**
+    * Returns the namespace helper for the XML source.
+    * 
+    * @return A namespace helper.
+    * @throws DocumentException
+    *            when something went wrong.
+    * @throws ParserConfigurationException
+    *            when something went wrong.
+    * @throws SAXException
+    *            when something went wrong.
+    * @throws IOException
+    *            when something went wrong.
+    */
+   protected NamespaceHelper getNamespaceHelper() throws DocumentException, ParserConfigurationException, SAXException, IOException {
+      NamespaceHelper helper;
+      if(exists()){
+         File file = getFile();
+         org.w3c.dom.Document document = DocumentHelper.readDocument(file);
+         helper = new NamespaceHelper(Collection.NAMESPACE, Collection.DEFAULT_PREFIX, document);
+      }else{
+         helper = new NamespaceHelper(Collection.NAMESPACE, Collection.DEFAULT_PREFIX, ELEMENT_COLLECTION);
+      }
+      return helper;
+   }
+   /**
+    * @see org.apache.lenya.cms.publication.Collection#contains(org.apache.lenya.cms.publication.Document)
+    */
+   public boolean contains(Document document) throws DocumentException {
+      return documents().contains(document);
+   }
+   /**
+    * @see org.apache.lenya.cms.publication.Collection#clear()
+    */
+   public void clear() throws DocumentException {
+      documents().clear();
+   }
+   /**
+    * @see org.apache.lenya.cms.publication.Collection#getFirstPosition(org.apache.lenya.cms.publication.Document)
+    */
+   public int getFirstPosition(Document document) throws DocumentException {
+      load();
+      if(!contains(document)){
+         throw new DocumentException("The collection [" + this + "] does not contain the document [" + document + "]");
+      }
+      return documents().indexOf(document);
+   }
+   /**
+    * @see org.apache.lenya.cms.publication.Collection#size()
+    */
+   public int size() throws DocumentException {
+      return documents().size();
+   }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org