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/09/10 02:30:22 UTC

svn commit: r693670 [5/6] - in /lenya/branches/revolution/1.3.x: ./ src/java/org/apache/lenya/cms/ac/ src/java/org/apache/lenya/cms/ac/usecase/ src/java/org/apache/lenya/cms/ac/workflow/ src/java/org/apache/lenya/cms/ant/ src/java/org/apache/lenya/cms/...

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/SitetreeGenerator.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/SitetreeGenerator.java?rev=693670&r1=693669&r2=693670&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/SitetreeGenerator.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/SitetreeGenerator.java Tue Sep  9 17:30:20 2008
@@ -12,7 +12,6 @@
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
 import org.apache.excalibur.source.SourceValidity;
-import org.apache.lenya.cms.content.Content;
 import org.apache.lenya.cms.publication.PageEnvelope;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.util.Globals;
@@ -48,30 +47,34 @@
     * Setup the file generator. Try to get the last modification date of the source for caching.
     */
    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException {
+      if(null == src) src = "";
       super.setup(resolver, objectModel, src, par);
       try{
          PageEnvelope envelope;
          Publication pub = Globals.getPublication();
-         String language = "en";
+         if(null == pub){ throw new ProcessingException("SitetreeGenerator.setup: No Publication."); }
+         String language = FlatContent.LANGUAGE_DEFAULT;
          try{
             envelope = PageEnvelope.getCurrent();
             language = envelope.getDocument().getLanguage();
          }catch(org.apache.lenya.cms.publication.PageEnvelopeException pee){
-            System.out.println("Sitetree Generator: could not use PageEnvelope.");
-            throw new ProcessingException("Sitetree Generator: could not use PageEnvelope.");
+            System.out.println("SitetreeGenerator.setup: Could not use PageEnvelope.");
+            throw new ProcessingException("SitetreeGenerator.setup: Could not use PageEnvelope.");
          }
-         // Lenya-1.3
-         if(pub.getContentType().equalsIgnoreCase(Content.TYPE_FLAT)){
-            this.inputSource = super.resolver.resolveURI(pub.getContent().getIndexFilename(src, language));
+         File indexFile;
+         if(pub.getContentType().equalsIgnoreCase(FlatContent.TYPE)){
+            // Flat Content
+            // NOTE: Using Oresolver.resolveURI(getIndexFilename()) fails. Must create File first.
+            indexFile = new File(pub.getContent().getIndexFilename(src, language));
+            // System.out.println("SitetreeGenerator setup src=" + src + " " + (indexFile.exists() ? "exists" : "does not exist") + "\nFILE=" + indexFile.getAbsolutePath());
          }else{
-            // Lenya-1.2 Hierarchical Content 
-            File testfile = new File(pub.getContentDirectory(), src + File.separator + "sitetree.xml");
-            if(!testfile.exists())
-               testfile = new File(pub.getContentDirectory(), "live" + File.separator + "sitetree.xml");
-            this.inputSource = super.resolver.resolveURI(testfile.getPath());
+            // Hierarchical Content
+            indexFile = new File(pub.getContentDirectory(), src + File.separator + "sitetree.xml");
+            if(!indexFile.exists()) indexFile = new File(pub.getContentDirectory(), "live" + File.separator + "sitetree.xml");
          }
+         this.inputSource = super.resolver.resolveURI(indexFile.getPath());
       }catch(SourceException se){
-         throw SourceUtil.handle("Error during resolving of '" + src + "'.", se);
+         throw SourceUtil.handle("SitetreeGenerator SourceException resolving '" + src + "'.", se);
       }
    }
    /**
@@ -94,6 +97,7 @@
     * Generate XML data.
     */
    public void generate() throws IOException, SAXException, ProcessingException {
+      // System.out.println("SitetreeGenerator.generate");
       try{
          if(getLogger().isDebugEnabled()){
             getLogger().debug("Source " + super.source + " resolved to " + this.inputSource.getURI());
@@ -103,41 +107,4 @@
          SourceUtil.handleSAXException(this.inputSource.getURI(), e);
       }
    }
-   // DEV
-   // private void showMap(Map map) {
-   // System.out.println("%%% MAP BEGIN %%%");
-   // Set keys = map.keySet();
-   // Iterator iterator = keys.iterator();
-   // while(iterator.hasNext()){
-   // Object key = iterator.next();
-   // System.out.println(key + " = " + map.get(key));
-   // }
-   // System.out.println("%%% MAP END %%%");
-   // }
-   // private void showParameters(Parameters parameters) {
-   // System.out.println("%%% PARAMETERS BEGIN %%%");
-   // String[] names = parameters.getNames();
-   // int nlength = names.length;
-   // for(int i = 0; i < nlength; i++){
-   // try{
-   // System.out.println("PAR: " + names[i] + "=" + parameters.getParameter(names[i]));
-   // }catch(org.apache.avalon.framework.parameters.ParameterException pe){
-   // System.out.println("PAR: " + names[i] + " FAILURE");
-   // }
-   // }
-   // System.out.println("%%% PARAMETERS END %%%");
-   // }
-   // 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);
-   // }
-   // return module;
-   // }
 }

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=693670&r1=693669&r2=693670&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 Tue Sep  9 17:30:20 2008
@@ -1,5 +1,6 @@
 package org.apache.lenya.cms.modules;
 import java.io.File;
+import java.io.FileFilter;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -19,12 +20,14 @@
  */
 public abstract class Module {
    public static final String MODULE_XML = "module.xml";
+   public static final String INDEX_FILE_SUFFIX = ".index"; // Start with period.
    Set inheritList = new LinkedHashSet(); // String names of other Modules in this publication.
    Map requiredList = new TreeMap(); // required Modules: id = reason
    Map recommendedList = new TreeMap(); // recommended Modules: id = reason
    Map optionalList = new TreeMap(); // optional Modules: id = reason
    Map variables = new HashMap(); // nameString = valueString
    Map files; // filename -> actual location as String (Better as File or Source?)
+   Map indexes = new HashMap(); // indexId -> Configuration
    File moduleDirectory;
    private String type = Content.TYPE_DEFAULT;
    private String id;
@@ -43,9 +46,9 @@
       this.moduleDirectory = moduleDirectory;
       id = moduleDirectory.getName();
       File configFile = new File(moduleDirectory, MODULE_XML);
+      DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+      Configuration config;
       if(configFile.canRead()){
-         DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
-         Configuration config;
          try{
             config = builder.buildFromFile(configFile);
             id = config.getAttribute("id", id);
@@ -125,6 +128,16 @@
                String key = publication + "." + module;
                inheritList.add(key);
             }
+            // Indexes
+            Configuration[] indexesConf = config.getChildren("index");
+            int numIndexes = indexesConf.length;
+            for(int vI = 0; vI < numIndexes; vI++){
+               Configuration index = indexesConf[vI];
+               // Get attributes
+               String indexId = index.getAttribute("id", "");
+               // System.out.println("Module: Found Index " + indexId);
+               if(0 < indexId.length()) indexes.put(indexId, index);
+            }
             // Resource parents inherit after specified inheritance.
             // Added from bottom to top: xml/xhtml/home inherits from xhtml then xml.
             if(resource.length() > 0){
@@ -147,6 +160,28 @@
          }catch(IOException e){
             System.out.println("Module " + publicationId + "." + id + " has an IOException.\n" + e.getLocalizedMessage());
          }
+      } // end if - read configuration
+      IndexFileFilter filter = new IndexFileFilter();
+      File[] indexFiles = moduleDirectory.listFiles(filter);
+      int numIndexFiles = indexFiles.length;
+      for(int vI = 0; vI < numIndexFiles; vI++){
+         File indexFile = indexFiles[vI];
+         // System.out.println("Module: Found Index File " + indexFile.getAbsolutePath());
+         try{
+            config = builder.buildFromFile(indexFile);
+            String indexId = config.getAttribute("id", indexFile.getName().split(INDEX_FILE_SUFFIX, 1)[0]);
+            if(1 > indexId.length()){
+               String filename = indexFile.getName();
+               indexId = filename.substring(0, filename.length() - INDEX_FILE_SUFFIX.length());
+               indexes.put(indexId, config);
+            }
+         }catch(ConfigurationException e){
+            System.out.println("Module " + publicationId + "." + id + " Index " + indexFile.getName() + " has a ConfigurationException.\n" + e.getLocalizedMessage());
+         }catch(SAXException e){
+            System.out.println("Module " + publicationId + "." + id + " Index " + indexFile.getName() + " has a SAXException.\n" + e.getLocalizedMessage());
+         }catch(IOException e){
+            System.out.println("Module " + publicationId + "." + id + " Index " + indexFile.getName() + " has an IOException.\n" + e.getLocalizedMessage());
+         }
       }
    }
    public String getContentType() {
@@ -177,6 +212,7 @@
     * @return
     */
    public String getFile(String filename) {
+      // System.out.println("Module.getFile " + filename);
       String ret = "";
       // Check cache
       if(files.containsKey(filename)){
@@ -187,6 +223,20 @@
             ret = "";
          }
       }
+      // TODO: Check Design Resources without creating infinite loop.
+      // BUG WATCH: This function is called by FlatIndexer while initializing FlatContent. Infinite loop.
+      // Initialization only needs filename="."
+      // if((ret.length() < 1) && (0 < filename.length()) && !(".".equals(filename))){
+      // // Check Design Resources
+      // Publication publication = Globals.getPublication();
+      // if(FlatContent.TYPE.equalsIgnoreCase(publication.getContentType())){
+      // String unid = Globals.getDesignUnid(filename);
+      // // Cannot access Content during initialization.
+      // Resource resource = ((FlatContent) publication.getContent()).getDesignResource(unid);
+      // File file = new File(resource.getURI());
+      // if(file.exists()) ret = file.getAbsolutePath();
+      // }
+      // }
       if(ret.length() < 1){
          // Check this Module.
          File file = new File(moduleDirectory, filename);
@@ -223,12 +273,10 @@
          Iterator inherit = inheritList.iterator();
          while(inherit.hasNext() && (ret.length() < 1)){
             module = Modules.getModule((String) inherit.next(), type);
-            if(null != module)
-               ret = module.getVariable(parameterName);
+            if(null != module) ret = module.getVariable(parameterName);
          }
       }
-      if(ret.length() > 0)
-         variables.put(parameterName, ret);
+      if(ret.length() > 0) variables.put(parameterName, ret);
       return ret;
    }
    /**
@@ -254,4 +302,17 @@
    public String getPublicationId() {
       return publicationId;
    }
+   /**
+    * 
+    * @return Map(indexId) = Configuration
+    */
+   public Map getIndexes() {
+      return indexes;
+   }
+   private class IndexFileFilter implements FileFilter {
+      public boolean accept(File file) {
+         if(!file.canRead()) return false;
+         return file.getName().toLowerCase().endsWith(INDEX_FILE_SUFFIX.toLowerCase());
+      }
+   }
 }

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=693670&r1=693669&r2=693670&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 Tue Sep  9 17:30:20 2008
@@ -6,14 +6,16 @@
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.components.modules.input.AbstractInputModule;
-import org.apache.lenya.cms.publication.PageEnvelope;
-import org.apache.lenya.cms.publication.PageEnvelopeException;
+import org.apache.lenya.cms.content.flat.FlatDesign;
 import org.apache.lenya.cms.publication.Publication;
 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>
+ * Retrieves Module Variables from publication.xconf and module.xml.<br>
+ * {module:module} returns current Module Id.<br>
+ * {module:unid:PathAsForModuleProtocol} returns the UNID for the specified Design Resource regardless of the Resource's existence.<br>
+ * Example: {module:unid:///myxml.xml} returns the Design Resource UNID for the myxml.xml file from the current Module.<br>
+ * <br>
+ * Other variables are specified as <module name="modulename"><variable name="{variablename}">{value}</variable></module>
  * 
  * @author solprovider
  * @since 1.3
@@ -24,6 +26,7 @@
     */
    private String moduleId = "";
    public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+      // System.out.println("ModuleInputModule.getAttribute " + name);
       if(getLogger().isDebugEnabled()){
          getLogger().debug("Resolving [" + name + "]");
       }
@@ -32,14 +35,11 @@
       if(name.equalsIgnoreCase("module")){
          return moduleId;
       }
-      // Module Variables
-      PageEnvelope pe;
-      try{
-         pe = PageEnvelope.getCurrent();
-      }catch(PageEnvelopeException e){
-         throw new ConfigurationException("Resolving page envelope failed: ", e);
+      if(name.startsWith("unid:")){
+         return FlatDesign.getDesignUnid(name.substring(5));
       }
-      Publication pub = pe.getPublication();
+      // Module Variables
+      Publication pub = Globals.getPublication();
       PublicationModules modules = pub.getModules();
       return modules.getVariable(moduleId, name);
    }

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=693670&r1=693669&r2=693670&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 Tue Sep  9 17:30:20 2008
@@ -14,8 +14,8 @@
 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.PageEnvelope;
 import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.util.Globals;
 /**
  * 2000125: Integrated with org.apache.lenya.cms.modules
  * 
@@ -41,19 +41,15 @@
          return new FileSource(location);
       }
       String uri = resolver.resolveURI("").getURI();
-      String publication;
-      Publication pub;
-      try{
-         PageEnvelope envelope = PageEnvelope.getCurrent();
-         pub = envelope.getPublication();
-         publication = pub.getId();
-      }catch(org.apache.lenya.cms.publication.PageEnvelopeException pee){
-         throw new MalformedURLException("ModuleSourceFactory PageEnvelopeException. Could not get Publication.");
+      Publication publication = Globals.getPublication();
+      
+      String publicationId = "";
+      if(null != publication){
+         publicationId = publication.getId();
       }
       // Reset moduleInheritance
       boolean needsReset = false;
-      if(location.indexOf("::") != -1)
-         needsReset = true;
+      if(location.indexOf("::") != -1) needsReset = true;
       // Decide Usage
       pos = location.indexOf(":///");
       int endpos;
@@ -68,6 +64,7 @@
       // This errors.
       // Every Module must have a module.xmap (even if it is empty)!
       String filepath = "module.xmap";
+      // TODO: Improve parsing using
       if(pos != -1){ // module:/filepath/filename.ext
          // Get current Module ID
          filepath = location.substring(pos + 4);
@@ -90,7 +87,7 @@
                pos += 2;
                endpos = location.indexOf("/", pos);
                if(endpos > 0){
-                  publication = location.substring(pos, endpos);
+                  publicationId = location.substring(pos, endpos);
                   pos = endpos + 1;
                   endpos = location.indexOf("/", pos);
                   if(endpos > 0){
@@ -100,7 +97,7 @@
                      moduleId = location.substring(pos);
                   }
                }else{
-                  publication = location.substring(pos);
+                  publicationId = location.substring(pos);
                }
             }else{
                // /filepath/filename.ext (Default protocol)
@@ -109,16 +106,12 @@
          }
       }
       // Verify
-      if(publication.length() < 1)
-         throw new MalformedURLException("No Publication ID found.");
-      if(moduleId.length() < 1)
-         moduleId = getModuleID(uri);
+      if(publicationId.length() < 1) throw new MalformedURLException("No Publication ID found.");
+      if(moduleId.length() < 1) moduleId = getModuleID(uri);
       // BUG ALERT: See description above about no default
-      if(filepath.length() < 1)
-         filepath = "module.xmap";
-      String newlocation = pub.getModules().getFile(moduleId, filepath, needsReset);
-      if(newlocation.length() < 1)
-         throw new SourceNotFoundException("Not found: " + location + " -> " + newlocation);
+      if(filepath.length() < 1) filepath = "module.xmap";
+      String newlocation = publication.getModules().getFile(moduleId, filepath, needsReset);
+      if(newlocation.length() < 1) throw new SourceNotFoundException("Not found: " + location + " -> " + newlocation);
       // System.out.println("ModuleSource: " + newlocation);
       return new FileSource("file://" + newlocation);
    }

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationInputModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationInputModule.java?rev=693670&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationInputModule.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationInputModule.java Tue Sep  9 17:30:20 2008
@@ -0,0 +1,95 @@
+package org.apache.lenya.cms.modules;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.components.modules.input.AbstractInputModule;
+import org.apache.lenya.cms.content.flat.FlatContent;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.util.Globals;
+/**
+ * Retrieves Publication variables {publication:variablename} where case-insensitive variablename =<br>
+ * contenttype - flat or hierarchical<br>
+ * defaultlanguage<br>
+ * BreadcrumbPrefix<br>
+ * SSLPrefix<br>
+ * ServletContext<br>
+ * Directory - Discouraged, use content: and module: protocols<br>
+ * ContentDirectory - Discouraged, use content: protocol<br>
+ * The following three return semicolon-separated lists: languages<br>
+ * revisions<br>
+ * structures<br>
+ * <br>
+ * Anything else defaults to the publication Id. Best practice suggests using {publication:publication}.
+ * 
+ * @author solprovider
+ * @since 1.3
+ */
+public class PublicationInputModule extends AbstractInputModule implements ThreadSafe {
+   /**
+    * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+    */
+   public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+      // TODO: Add "name"
+      if(getLogger().isDebugEnabled()){
+         getLogger().debug("Resolving [" + name + "]");
+      }
+      Publication publication = Globals.getPublication();
+      if(name.equalsIgnoreCase("contenttype")) return publication.getContentType();
+      if(name.equalsIgnoreCase("defaultlanguage")) return publication.getDefaultLanguage();
+      if(name.equalsIgnoreCase("BreadcrumbPrefix")) return publication.getBreadcrumbPrefix();
+      if(name.equalsIgnoreCase("SSLPrefix")) return publication.getSSLPrefix();
+      if(name.equalsIgnoreCase("revisions")){
+         Iterator iterator = ((FlatContent) publication.getContent()).getRevisions().iterator();
+         StringBuffer buffer = new StringBuffer("");
+         if(iterator.hasNext()) buffer.append((String) iterator.next());
+         while(iterator.hasNext())
+            buffer.append(";" + (String) iterator.next());
+         return buffer.toString();
+      }
+      if(name.equalsIgnoreCase("structures")){
+         Iterator iterator = ((FlatContent) publication.getContent()).getStructures().iterator();
+         StringBuffer buffer = new StringBuffer("");
+         if(iterator.hasNext()) buffer.append((String) iterator.next());
+         while(iterator.hasNext())
+            buffer.append(";" + (String) iterator.next());
+         return buffer.toString();
+      }
+      if(name.equalsIgnoreCase("languages")){
+         String[] languagesArray = publication.getLanguages();
+         StringBuffer buffer = new StringBuffer(languagesArray[0]);
+         for(int l = 1; l < languagesArray.length; l++)
+            buffer.append(";" + languagesArray[l]);
+         return buffer.toString();
+      }
+      try{
+         if(name.equalsIgnoreCase("ServletContext")) return publication.getServletContext().getCanonicalPath();
+         if(name.equalsIgnoreCase("Directory")) return publication.getDirectory().getCanonicalPath();
+         if(name.equalsIgnoreCase("ContentDirectory")) return publication.getContentDirectory().getCanonicalPath();
+      }catch(java.io.IOException ioe){
+         return "error";
+      }
+      return publication.getId();
+   }
+   /**
+    * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+    */
+   public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException {
+      return Collections.EMPTY_SET.iterator();
+   }
+   /**
+    * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+    */
+   public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+      Object[] objects = {getAttribute(name, modeConf, objectModel)};
+      return objects;
+   }
+   /**
+    * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+    */
+   public void configure(Configuration conf) throws ConfigurationException {
+      super.configure(conf);
+   }
+}
\ No newline at end of file

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModules.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModules.java?rev=693670&r1=693669&r2=693670&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModules.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModules.java Tue Sep  9 17:30:20 2008
@@ -38,8 +38,7 @@
    Configuration config;
    public PublicationModules(String publicationId, String contentType, Configuration config) {
       // public PublicationModules(String publicationId, String contentType, String servletContextPath, Configuration config) {
-      if(null == config)
-         return;
+      if(null == config) return;
       int i;
       this.publicationId = publicationId;
       // this.servletContextPath = servletContextPath;
@@ -51,16 +50,14 @@
             String attribute = attrnames[i];
             String value = config.getAttribute(attrnames[i]);
             if(attribute.equalsIgnoreCase("include")){
-               if(!value.equalsIgnoreCase("all"))
-                  allAllowed = false;
+               if(!value.equalsIgnoreCase("all")) allAllowed = false;
             }else if(attribute.equalsIgnoreCase("external")){
-               if(!(value.equalsIgnoreCase("all") | value.equalsIgnoreCase("true")))
-                  allExternal = false;
+               if(!(value.equalsIgnoreCase("all") | value.equalsIgnoreCase("true"))) allExternal = false;
             }else if((attribute.equalsIgnoreCase("inherit") | attribute.equalsIgnoreCase("template"))){
                templates.add(value);
             }
          }catch(org.apache.avalon.framework.configuration.ConfigurationException ce){
-            // TODO: Log Errors?
+            System.out.println("PublicationModules attributes ConfigurationException " + ce.getLocalizedMessage());
          }
       } // For each Attribute
       Configuration[] children = config.getChildren();
@@ -72,7 +69,7 @@
                try{
                   templates.add(children[c].getAttribute(attrnames[i]));
                }catch(org.apache.avalon.framework.configuration.ConfigurationException ce){
-                  // TODO: Log Errors?
+                  System.out.println("PublicationModules inherit ConfigurationException " + ce.getLocalizedMessage());
                }
             }
             try{
@@ -91,11 +88,9 @@
                try{
                   String value = children[c].getAttribute(attrnames[i]);
                   if(attribute.equalsIgnoreCase("external")){
-                     if(!(value.equalsIgnoreCase("yes") | value.equalsIgnoreCase("true")))
-                        isExternal = false;
+                     if(!(value.equalsIgnoreCase("yes") | value.equalsIgnoreCase("true"))) isExternal = false;
                   }else if(attribute.equalsIgnoreCase("exclude")){
-                     if(!(value.equalsIgnoreCase("yes") | value.equalsIgnoreCase("true")))
-                        isExcluded = true;
+                     if(!(value.equalsIgnoreCase("yes") | value.equalsIgnoreCase("true"))) isExcluded = true;
                   }else if(attribute.equalsIgnoreCase("name")){
                      name = value;
                   }else if((attribute.equalsIgnoreCase("inherit") | attribute.equalsIgnoreCase("template"))){
@@ -105,6 +100,7 @@
                   }
                }catch(org.apache.avalon.framework.configuration.ConfigurationException ce){
                   // TODO: Log Errors?
+                  System.out.println("PublicationModules module ConfigurationException " + ce.getLocalizedMessage());
                }
             }
             if(name.length() > 0){
@@ -112,10 +108,8 @@
                   exclude.add(name);
                }else{
                   external.put(name, new Boolean(isExternal));
-                  if(template.length() > 0)
-                     inherit.put(name, template);
-                  if(module.length() > 0)
-                     inherit.put(name, module);
+                  if(template.length() > 0) inherit.put(name, template);
+                  if(module.length() > 0) inherit.put(name, module);
                   // Variables
                   Map varmap = getVariablesFromConfiguration(children[c]);
                   Iterator keys = varmap.keySet().iterator();
@@ -136,38 +130,18 @@
     * @return
     */
    public boolean isExternal(String moduleId) {
-      if(exclude.contains(moduleId))
-         return false;
-      if(allExternal)
-         return true;
-      if(external.containsKey(moduleId))
-         return ((Boolean) external.get(moduleId)).booleanValue();
+      if(exclude.contains(moduleId)) return false;
+      if(allExternal) return true;
+      if(external.containsKey(moduleId)) return ((Boolean) external.get(moduleId)).booleanValue();
       // TODO: Check parent templates?
       return allAllowed;
    }
    public boolean isAllowed(String moduleId) {
-      if(exclude.contains(moduleId))
-         return false;
-      if(allAllowed)
-         return true;
-      if(external.containsKey(moduleId))
-         return true;
+      if(exclude.contains(moduleId)) return false;
+      if(allAllowed) return true;
+      if(external.containsKey(moduleId)) return true;
       return false;
    }
-   // public String[] getTemplates(String moduleId) {
-   // if(inherit.containsKey(moduleId)){
-   // ArrayList tmpArray = new ArrayList();
-   // tmpArray.add(inherit.get(moduleId));
-   // tmpArray.addAll(templates);
-   // return (String[]) tmpArray.toArray(new String[0]);
-   // }
-   // return (String[]) templates.toArray(new String[0]);
-   // }
-   // public String getInheritedModule(String moduleId) {
-   // if(modules.containsKey(moduleId))
-   // return (String) modules.get(moduleId);
-   // return moduleId;
-   // }
    /**
     * Returns Map("moduleId") = "inheritedFromPublication" Expected to be used only for Publication creation and modification (using the PublicationModulesGenerator) so performance (e.g. using a cache) is unimportant.
     */
@@ -187,7 +161,7 @@
             if((publication.length() < 1) || publication.equalsIgnoreCase(publicationId) || templates.contains(publication)){
                String module = parts[1];
                if(!exclude.contains(module)){
-                  // System.out.println("KEY=" + key + " P=" + publication + " M=" + module);
+                  // System.out.println("PublicationModules.getSourceModules KEY=" + key + " P=" + publication + " M=" + module);
                   modulesList.add(module);
                }
             }
@@ -200,18 +174,19 @@
       Iterator iterator = modulesList.iterator();
       while(iterator.hasNext()){
          String moduleId = (String) iterator.next();
+         // TODO: Do not call getFile during initialization.
          String filepath = getFile(moduleId, ".", false);
          String inheritedModuleId = Globals.getModuleId(filepath);
          String inheritedPublication = Globals.getPublicationId(filepath);
          Module inheritedModule = Modules.getModule(inheritedPublication, inheritedModuleId, contentType);
          if(null == inheritedModule){
-            System.out.println(moduleId + "Module found at " + filepath + " could not be opened as Publication " + inheritedPublication + " Module " + inheritedModuleId);
+            System.out.println("PublicationModules.getSourceModules " + moduleId + "Module found at " + filepath + " could not be opened as Publication " + inheritedPublication + " Module " + inheritedModuleId);
          }else{
             String resource = inheritedModule.getResource();
             if(resource.length() > 0){
                resources.put(resource, inheritedModule);
             }
-            // System.out.println("FP=" + filepath + " MI=" + moduleId + " P=" + inheritedPublication + " M=" + inheritedModuleId + " R=" + resource);
+            // System.out.println("PublicationModules.getSourceModules MI=" + moduleId + " P=" + inheritedPublication + " M=" + inheritedModuleId + " R=" + resource); // + "FP=" + filepath);
             modules.put(moduleId, inheritedModule);
          }
       }
@@ -230,8 +205,7 @@
    }
    public String getVariable(String moduleId, String varname) {
       // TODO: Add reset. Do InputModules support double colon syntax?
-      if(exclude.contains(moduleId))
-         return "";
+      if(exclude.contains(moduleId)) return "";
       if(variables.containsKey(publicationId + "." + moduleId + "." + varname)){
          return (String) variables.get(publicationId + "." + moduleId + "." + varname);
       }
@@ -272,12 +246,23 @@
       }
       return ret;
    }
+   /**
+    * Do not call getFile() during initialization.<br>
+    * getFile calls Module.getFile calling Content.getDesignResource.<br>
+    * Content initialization checks Modules for Structures and RevisionNames.<br>
+    * Infinite loop!<br>
+    * 
+    * @param moduleId
+    * @param filename
+    * @param reset
+    * @return
+    */
    public String getFile(String moduleId, String filename, boolean reset) {
+      // WARNING: Do not call during initialization.
       if(reset){
          files = new HashMap();
       }
-      if(exclude.contains(moduleId))
-         return "";
+      if(exclude.contains(moduleId)) return "";
       if(files.containsKey(moduleId + "." + filename)){
          return (String) files.get(moduleId + "." + filename);
       }
@@ -285,8 +270,7 @@
       String ret = "";
       Module module = Modules.getModule(publicationId, moduleId, contentType);
       if(null != module){
-         if(reset)
-            module.resetFiles();
+         if(reset) module.resetFiles();
          ret = module.getFile(filename);
       }
       if(ret.length() < 1){
@@ -295,8 +279,7 @@
          while(iterator.hasNext() && (ret.length() < 1)){
             module = Modules.getModule((String) iterator.next(), moduleId, contentType);
             if(null != module){
-               if(reset)
-                  module.resetFiles();
+               if(reset) module.resetFiles();
                ret = module.getFile(filename);
             }
          }
@@ -305,8 +288,7 @@
          // Check Global Module
          module = Modules.getModule("", moduleId, contentType);
          if(null != module){
-            if(reset)
-               module.resetFiles();
+            if(reset) module.resetFiles();
             ret = module.getFile(filename);
          }
       }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModulesGenerator.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModulesGenerator.java?rev=693670&r1=693669&r2=693670&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModulesGenerator.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModulesGenerator.java Tue Sep  9 17:30:20 2008
@@ -3,10 +3,12 @@
 import java.io.Serializable;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.caching.CacheableProcessingComponent;
 import org.apache.cocoon.generation.ServiceableGenerator;
 import org.apache.excalibur.source.SourceValidity;
+import org.apache.lenya.cms.content.flat.FlatContent;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.util.Globals;
 import org.xml.sax.ContentHandler;
@@ -25,6 +27,10 @@
    private static final String ATTR_MODULE_NAME = "name";
    private static final String ATTR_PUB_ID = "publication";
    private static final String ATTR_PUB_CONTENT = "content";
+   private static final String ELEMENT_STRUCTURE = "structure";
+   private static final String ATTR_STRUCTURE_ID = "id";
+   private static final String ELEMENT_REVISION = "revision";
+   private static final String ATTR_REVISION_ID = "id";
    public Serializable getKey() {
       // TODO Auto-generated method stub
       return null;
@@ -33,7 +39,12 @@
       // TODO Auto-generated method stub
       return null;
    }
+   /**
+    * Generate XML describing the resources used by the current publication
+    */
    public void generate() throws IOException, SAXException, ProcessingException {
+      // <modules publication="default13" content="flat">
+      // Root node of XML with publication's Id and content type.
       Publication publication = Globals.getPublication();
       PublicationModules modules = publication.getModules();
       Map modulesMap = modules.getSourceModules();
@@ -42,17 +53,23 @@
       handler.startDocument();
       handler.startPrefixMapping(PREFIX, URI);
       AttributesImpl attributes = new AttributesImpl();
-      // attributes.addAttribute("", "xmlns", "xmlns", "CDATA", URI);
       attributes.addAttribute(URI, ATTR_PUB_ID, ATTR_PUB_ID, "CDATA", publication.getId());
       attributes.addAttribute(URI, ATTR_PUB_CONTENT, ATTR_PUB_CONTENT, "CDATA", publication.getContentType());
-      // attributes.addAttribute("xmlns", PREFIX, "xmlns:" + PREFIX, "CDATA", URI);
       handler.startElement(URI, ELEMENT_TOP, ELEMENT_TOP, attributes);
       handleResources(handler, resources);
       handleModules(handler, modulesMap);
+      if(publication.getContentType().equals(FlatContent.TYPE)){
+         FlatContent flatContent = (FlatContent) publication.getContent();
+         handleStructures(handler, flatContent.getStructures());
+         handleRevisions(handler, flatContent.getRevisions());
+      }
       handler.endElement(URI, ELEMENT_TOP, ELEMENT_TOP);
       handler.endDocument();
    }
    private void handleResources(ContentHandler handler, Map resources) throws SAXException {
+      // <resource resource="/xml/xhtml" publication="" module="xhtml" name="XHTML"/>
+      // ResourceType is last part of "resource" attribute.
+      // publication and module attributes set base class. Inheritance follows from that module.
       Iterator moduleI = resources.entrySet().iterator();
       while(moduleI.hasNext()){
          Map.Entry entry = (Map.Entry) moduleI.next();
@@ -70,6 +87,8 @@
       }
    }
    private void handleModules(ContentHandler handler, Map modules) throws SAXException {
+      // <module id="live" publication="" module="live" name="Live"/>
+      // For a given "id", publication and module attributes set base class. Inheritance follows from that module.
       Iterator moduleI = modules.entrySet().iterator();
       while(moduleI.hasNext()){
          Map.Entry entry = (Map.Entry) moduleI.next();
@@ -86,4 +105,28 @@
          handler.endElement(URI, ELEMENT_MODULE, ELEMENT_MODULE);
       }
    }
+   private void handleStructures(ContentHandler handler, Set structures) throws SAXException {
+      // <structure id="live"/>
+      // List structures used by this publication.
+      Iterator moduleI = structures.iterator();
+      while(moduleI.hasNext()){
+         String structure = (String) moduleI.next();
+         AttributesImpl attributes = new AttributesImpl();
+         attributes.addAttribute(URI, ATTR_STRUCTURE_ID, ATTR_STRUCTURE_ID, "CDATA", structure);
+         handler.startElement(URI, ELEMENT_STRUCTURE, ELEMENT_STRUCTURE, attributes);
+         handler.endElement(URI, ELEMENT_STRUCTURE, ELEMENT_STRUCTURE);
+      }
+   }
+   private void handleRevisions(ContentHandler handler, Set revisions) throws SAXException {
+      // <revision id="live"/>
+      // List revisions used by this publication.
+      Iterator moduleI = revisions.iterator();
+      while(moduleI.hasNext()){
+         String revision = (String) moduleI.next();
+         AttributesImpl attributes = new AttributesImpl();
+         attributes.addAttribute(URI, ATTR_REVISION_ID, ATTR_REVISION_ID, "CDATA", revision);
+         handler.startElement(URI, ELEMENT_REVISION, ELEMENT_REVISION, attributes);
+         handler.endElement(URI, ELEMENT_REVISION, ELEMENT_REVISION);
+      }
+   }
 }

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=693670&r1=693669&r2=693670&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 Tue Sep  9 17:30:20 2008
@@ -26,6 +26,7 @@
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.lenya.cms.content.Content;
 import org.apache.lenya.cms.content.flat.FlatContent;
+import org.apache.lenya.cms.content.flat.FlatDesign;
 import org.apache.lenya.cms.content.hierarchical.HierarchicalContent;
 import org.apache.lenya.cms.modules.PublicationModules;
 import org.apache.lenya.cms.publishing.PublishingEnvironment;
@@ -59,6 +60,7 @@
    // Lenya1.3 - BEGIN
    private PublicationModules modules;
    private Content content;
+   private FlatDesign design = null;
    private File publicationDirectory;
    private File contentDirectory;
    private String contentType = Content.TYPE_HIERARCHICAL;
@@ -75,11 +77,10 @@
     *            if there was a problem reading the config file
     */
    protected AbstractPublication(String id, String servletContextPath) throws PublicationException {
+      // System.out.println("AbstractPublication " + id + " cp=" + servletContextPath);
       // assert id != null;
       this.id = id;
       // assert servletContextPath != null;
-      // System.out.println("Publication ServletContextPath=" +
-      // servletContextPath);
       File servletContext = new File(servletContextPath);
       // assert servletContext.exists();
       this.servletContext = servletContext;
@@ -153,20 +154,24 @@
             this.areaContentDir.put(key, dir);
          }
          // Lenya1.3 - BEGIN
-         // Content
+         // Configuration
          Configuration contentConfig = config.getChild("content");
          contentType = contentConfig.getAttribute("type", Content.TYPE_HIERARCHICAL);
          String contentConfigValue = contentConfig.getValue(CONTENT_PATH);
          publicationDirectory = new File(getServletContext(), PUBLICATION_PREFIX + File.separator + getId());
          contentDirectory = new File(publicationDirectory, contentConfigValue);
-         // TODO: Move code based on ContentType to Content package.
-         if(contentType.equalsIgnoreCase(Content.TYPE_FLAT)){
-            content = (Content) new FlatContent(contentDirectory, getLanguages());
-         }else{
-            content = (Content) new HierarchicalContent(contentDirectory, getLanguages());
+         // Design
+         if(contentType.equalsIgnoreCase(FlatContent.TYPE)){
+            design = new FlatDesign(contentDirectory, id);
          }
          // Modules
          modules = new PublicationModules(id, contentType, config.getChild("modules"));
+         // Content
+         if(contentType.equalsIgnoreCase(FlatContent.TYPE)){
+            content = (Content) new FlatContent(contentDirectory, getLanguages(), modules, design);
+         }else{
+            content = (Content) new HierarchicalContent(contentDirectory, getLanguages());
+         }
          // Lenya1.3 - END
       }catch(PublicationException e){
          throw e;
@@ -185,6 +190,9 @@
    public Content getContent() {
       return content;
    }
+   public FlatDesign getDesign() {
+      return design;
+   }
    public File getContentDirectory() {
       return contentDirectory;
    }
@@ -224,8 +232,7 @@
     * @return A <code>File</code> object.
     */
    public File getDirectory() {
-      if(null == publicationDirectory)
-         publicationDirectory = new File(getServletContext(), PUBLICATION_PREFIX + File.separator + getId());
+      if(null == publicationDirectory) publicationDirectory = new File(getServletContext(), PUBLICATION_PREFIX + File.separator + getId());
       return publicationDirectory;
    }
    // Lenya1.3 - deprecated
@@ -375,9 +382,7 @@
     * @return A document builder.
     */
    public DocumentBuilder getDocumentBuilder() {
-      if(documentBuilder == null){
-         throw new IllegalStateException("The document builder was not defined in publication.xconf!");
-      }
+      if(documentBuilder == null){ throw new IllegalStateException("The document builder was not defined in publication.xconf!"); }
       return documentBuilder;
    }
    /**
@@ -440,9 +445,7 @@
             SiteTree sourceTree = getSiteTree(sourceDocument.getArea());
             SiteTree destinationTree = getSiteTree(destinationDocument.getArea());
             SiteTreeNode sourceNode = sourceTree.getNode(sourceDocument.getId());
-            if(sourceNode == null){
-               throw new PublicationException("The node for source document [" + sourceDocument.getId() + "] doesn't exist!");
-            }
+            if(sourceNode == null){ throw new PublicationException("The node for source document [" + sourceDocument.getId() + "] doesn't exist!"); }
             SiteTreeNode[] siblings = sourceNode.getNextSiblings();
             String parentId = sourceNode.getAbsoluteParentId();
             SiteTreeNode sibling = null;
@@ -480,8 +483,7 @@
                // and synchronize visibilityinnav attribute with the one in
                // the source area
                String visibility = "true";
-               if(!sourceNode.visibleInNav())
-                  visibility = "false";
+               if(!sourceNode.visibleInNav()) visibility = "false";
                destinationNode.setNodeAttribute(SiteTreeNodeImpl.VISIBLEINNAV_ATTRIBUTE_NAME, visibility);
                // also update the link attribute if necessary
                if(sourceNode.hasLink() != destinationNode.hasLink()){
@@ -510,9 +512,7 @@
     * @see org.apache.lenya.cms.publication.Publication#deleteDocument(org.apache.lenya.cms.publication.Document)
     */
    public void deleteDocument(Document document) throws PublicationException {
-      if(!document.exists()){
-         throw new PublicationException("Document [" + document + "] does not exist!");
-      }
+      if(!document.exists()){ throw new PublicationException("Document [" + document + "] does not exist!"); }
       deleteFromSiteStructure(document);
       deleteDocumentSource(document);
    }
@@ -533,16 +533,10 @@
             throw new PublicationException(e);
          }
          SiteTreeNode node = tree.getNode(document.getId());
-         if(node == null){
-            throw new PublicationException("Sitetree node for document [" + document + "] does not exist!");
-         }
+         if(node == null){ throw new PublicationException("Sitetree node for document [" + document + "] does not exist!"); }
          Label label = node.getLabel(document.getLanguage());
-         if(label == null){
-            throw new PublicationException("Sitetree label for document [" + document + "] in language [" + document.getLanguage() + "]does not exist!");
-         }
-         if(node.getLabels().length == 1 && node.getChildren().length > 0){
-            throw new PublicationException("Cannot delete last language version of document [" + document + "] because this node has children.");
-         }
+         if(label == null){ throw new PublicationException("Sitetree label for document [" + document + "] in language [" + document.getLanguage() + "]does not exist!"); }
+         if(node.getLabels().length == 1 && node.getChildren().length > 0){ throw new PublicationException("Cannot delete last language version of document [" + document + "] because this node has children."); }
          node.removeLabel(label);
          try{
             if(node.getLabels().length == 0){

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelope.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelope.java?rev=693670&r1=693669&r2=693670&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelope.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelope.java Tue Sep  9 17:30:20 2008
@@ -109,11 +109,12 @@
     * @deprecated Performance problems. Use {@link PageEnvelopeFactory#getPageEnvelope(Map)} instead.
     */
    public PageEnvelope(Map objectModel) throws PageEnvelopeException {
-      try{
-         init(PublicationFactory.getPublication(objectModel), ObjectModelHelper.getRequest(objectModel));
-      }catch(PublicationException e){
-         throw new PageEnvelopeException(e);
-      }
+      // try{
+      // init(PublicationFactory.getPublication(objectModel), ObjectModelHelper.getRequest(objectModel));
+      init(Globals.getPublication(), ObjectModelHelper.getRequest(objectModel));
+      // }catch(PublicationException e){
+      // throw new PageEnvelopeException(e);
+      // }
    }
    /**
     * Creates a new instance of PageEnvelope from a sitemap inside a publication.
@@ -197,17 +198,18 @@
     * @throws PageEnvelopeException
     */
    static public PageEnvelope getCurrent() throws PageEnvelopeException {
+      // Check if already set.
       Request request = Globals.getRequest();
-      if(null == request){
-         throw new PageEnvelopeException("Cannot access a PageEnvelope without a Request.");
+      if(null != request){
+         Object o = request.getAttribute(PageEnvelope.class.getName());
+         if(null != o){ return (PageEnvelope) o; }
       }
-      Object o = request.getAttribute(PageEnvelope.class.getName());
-      if(null != o){
-         return (PageEnvelope) o;
+      // Otherwise create.
+      PageEnvelope envelope = new PageEnvelope(Globals.getObjectModel(), true);
+      if(null != request){
+         // Store for future use.
+         request.setAttribute(PageEnvelope.class.getName(), envelope);
       }
-      PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
-      envelope = new PageEnvelope(Globals.getObjectModel(), true);
-      request.setAttribute(PageEnvelope.class.getName(), envelope);
       return envelope;
    }
    /**

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/Publication.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/Publication.java?rev=693670&r1=693669&r2=693670&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/Publication.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/Publication.java Tue Sep  9 17:30:20 2008
@@ -14,252 +14,245 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.publication;
-
 import java.io.File;
 import org.apache.lenya.cms.content.Content;
+import org.apache.lenya.cms.content.flat.FlatDesign;
 import org.apache.lenya.cms.modules.PublicationModules;
 import org.apache.lenya.cms.publishing.PublishingEnvironment;
-
-
 /**
  * A Lenya publication.
  */
 public interface Publication {
-
-    String AUTHORING_AREA = "authoring";
-    String STAGING_AREA = "staging";
-    String LIVE_AREA = "live";
-    String ADMIN_AREA = "admin";
-    String ARCHIVE_AREA = "archive";
-    String TRASH_AREA = "trash";
-    String ELEMENT_PATH_MAPPER = "path-mapper";
-    String ELEMENT_DOCUMENT_BUILDER = "document-builder";
-    String ELEMENT_SITE_STRUCTURE = "site-structure";
-    String ATTRIBUTE_TYPE = "type";
-    String LANGUAGES = "languages";
-    String LANGUAGE = "language";
-    String DEFAULT_LANGUAGE_ATTR = "default";
-    String BREADCRUMB_PREFIX = "breadcrumb-prefix";
-    String SSL_PREFIX = "ssl-prefix";
-    String LIVE_MOUNT_POINT = "live-mount-point";
-    String PUBLICATION_PREFIX = "lenya" + File.separator + "pubs";
-    String PUBLICATION_PREFIX_URI = "lenya/pubs";
-    String CONFIGURATION_PATH = "config";
-    String CONTENT_PATH = "content";
-    String PENDING_PATH = "pending";    
-    String DELETE_PATH = "delete";
-    String INFO_AREA_PREFIX = "info-";
-    String SEARCH_AREA_PREFIX = "search-";
-    String CONFIGURATION_FILE = CONFIGURATION_PATH + File.separator + "publication.xconf";
-
-    /**
-     * Returns the publication ID.
-     * @return A string value.
-     */
-    String getId();
-
-    /**
-     * Returns the publishing environment of this publication.
-     * @return A {@link PublishingEnvironment} object.
-     * @deprecated It is planned to decouple the environments from the publication.
-     */
-    PublishingEnvironment getEnvironment();
-
-    /**
-     * Returns the servlet context this publication belongs to
-     * (usually, the <code>webapps/lenya</code> directory).
-     * @return A <code>File</code> object.
-     */
-    File getServletContext();
-
-    /**
-     * Returns the publication directory.
-     * @return A <code>File</code> object.
-     */
-    File getDirectory();
-
-    /**
-     * Return the directory of a specific area.
-     * 
-     * @param area a <code>File</code> representing the root of the area content directory.
-     * 
-     * @return the directory of the given content area. 
-     */
-    File getContentDirectory(String area);
-
-    /**
-     * DOCUMENT ME!
-     *
-     * @param mapper DOCUMENT ME!
-     */
-    void setPathMapper(DefaultDocumentIdToPathMapper mapper);
-
-    /**
-     * Returns the path mapper.
-     * 
-     * @return a <code>DocumentIdToPathMapper</code>
-     */
-    DocumentIdToPathMapper getPathMapper();
-
-    /**
-     * Get the default language
-     * 
-     * @return the default language
-     */
-    String getDefaultLanguage();
-
-    /**
-     * Set the default language
-     * 
-     * @param language the default language
-     */
-    void setDefaultLanguage(String language);
-
-    /**
-     * Get all available languages for this publication
-     * 
-     * @return an <code>Array</code> of languages
-     */
-    String[] getLanguages();
-
-    /**
-     * Get the breadcrumb prefix. It can be used as a prefix if a publication is part of a larger site
-     * 
-     * @return the breadcrumb prefix
-     */
-    String getBreadcrumbPrefix();
-
-    /**
-     * Get the SSL prefix. If you want to serve SSL-protected pages through a special site, use this
-     * prefix. This can come in handy if you have multiple sites that need SSL protection and you want
-     * to share one SSL certificate.
-     * 
-     * @return the SSL prefix
-     */
-    String getSSLPrefix();
-
-    /**
-     * Get the Live mount point. The live mount point is used to rewrite links that are of the form 
-     * /contextprefix/publication/area/documentid to /livemountpoint/documentid
-     * 
-     * This is useful if you serve your live area through mod_proxy. to enable this functionality, set
-     * the Live mount point to / or something else. An empty mount point disables the feature.
-     * 
-     * @return the Live mount point
-     */
-    String getLiveMountPoint();
-
-    /**
-     * Get the sitetree for a specific area of this publication. 
-     * Sitetrees are created on demand and are cached.
-     * 
-     * @param area the area
-     * @return the sitetree for the specified area
-     * 
-     * @throws SiteTreeException if an error occurs 
-     */
-    SiteTree getTree(String area) throws SiteTreeException;
-
-    /**
-     * Get the sitetree for a specific area of this publication. 
-     * Sitetrees are created on demand and are cached.
-     *
-     * @deprecated Please use getTree() because this method returns the interface and not a specific implementation
-     * @see getTree()
-     * 
-     * @param area the area
-     * @return the sitetree for the specified area
-     * 
-     * @throws SiteTreeException if an error occurs 
-     */
-    DefaultSiteTree getSiteTree(String area) throws SiteTreeException;
-
-    /**
-     * Returns the document builder of this instance.
-     * @return A document builder.
-     */
-    DocumentBuilder getDocumentBuilder();
-
-    /**
-     * Copies a document from one location to another location.
-     * @param sourceDocument The document to copy.
-     * @param destinationDocument The destination document.
-     * @throws PublicationException if a document which destinationDocument depends on
-     * does not exist.
-     */
-    void copyDocument(Document sourceDocument, Document destinationDocument)
-        throws PublicationException;
-
-    /**
-     * Copies a document to another area.
-     * @param sourceDocument The document to copy.
-     * @param destinationArea The destination area.
-     * @throws PublicationException if a document which the
-     * destination document depends on does not exist.
-     */
-    void copyDocumentToArea(Document sourceDocument, String destinationArea)
-        throws PublicationException;
-
-    /**
-     * Copies a document set to another area.
-     * @param documentSet The document set to copy.
-     * @param destinationArea The destination area.
-     * @throws PublicationException if a document which one of the
-     * destination documents depends on does not exist.
-     */
-    void copyDocumentSetToArea(DocumentSet documentSet, String destinationArea)
-        throws PublicationException;
-        
-    /**
-     * Deletes a document.
-     * @param document The document to delete.
-     * @throws PublicationException when something went wrong.
-     */
-    void deleteDocument(Document document) throws PublicationException;
-    
-    /**
-     * Moves a document from one location to another.
-     * @param sourceDocument The source document.
-     * @param destinationDocument The destination document.
-     * @throws PublicationException if a document which the
-     * destination document depends on does not exist.
-     */
-    void moveDocument(Document sourceDocument, Document destinationDocument) throws PublicationException;
-
-    /**
-     * Creates a version of the document object in another area.
-     * @param document The document to clone.
-     * @param area The destination area.
-     * @return A document.
-     * @throws PublicationException when an error occurs.
-     */
-    Document getAreaVersion(Document document, String area) throws PublicationException;
-
-    /**
-     * Returns the proxy which is used for a particular document. 
-     * @param document The document.
-     * @param isSslProtected A boolean value.
-     * @return A proxy or <code>null</code> if no proxy is defined
-     * for this version.
-     */
-    Proxy getProxy(Document document, boolean isSslProtected);
-    
-    /**
-     * Returns an array of XPaths representing attributes to be rewritten
-     * when a document URL has changed.
-     * @return An array of strings.
-     */
-    String[] getRewriteAttributeXPaths();
-
-//Lenya1.3 - BEGIN
-    PublicationModules getModules();
-    Content getContent();
-    File getContentDirectory();
-    String getContentType();
-//Lenya1.3 - END
-
+   String AUTHORING_AREA = "authoring";
+   String STAGING_AREA = "staging";
+   String LIVE_AREA = "live";
+   String ADMIN_AREA = "admin";
+   String ARCHIVE_AREA = "archive";
+   String TRASH_AREA = "trash";
+   String ELEMENT_PATH_MAPPER = "path-mapper";
+   String ELEMENT_DOCUMENT_BUILDER = "document-builder";
+   String ELEMENT_SITE_STRUCTURE = "site-structure";
+   String ATTRIBUTE_TYPE = "type";
+   String LANGUAGES = "languages";
+   String LANGUAGE = "language";
+   String DEFAULT_LANGUAGE_ATTR = "default";
+   String BREADCRUMB_PREFIX = "breadcrumb-prefix";
+   String SSL_PREFIX = "ssl-prefix";
+   String LIVE_MOUNT_POINT = "live-mount-point";
+   String PUBLICATION_PREFIX = "lenya" + File.separator + "pubs";
+   String PUBLICATION_PREFIX_URI = "lenya/pubs";
+   String CONFIGURATION_PATH = "config";
+   String CONTENT_PATH = "content";
+   String PENDING_PATH = "pending";
+   String DELETE_PATH = "delete";
+   String INFO_AREA_PREFIX = "info-";
+   String SEARCH_AREA_PREFIX = "search-";
+   String CONFIGURATION_FILE = CONFIGURATION_PATH + File.separator + "publication.xconf";
+   /**
+    * Returns the publication ID.
+    * 
+    * @return A string value.
+    */
+   String getId();
+   /**
+    * Returns the publishing environment of this publication.
+    * 
+    * @return A {@link PublishingEnvironment} object.
+    * @deprecated It is planned to decouple the environments from the publication.
+    */
+   PublishingEnvironment getEnvironment();
+   /**
+    * Returns the servlet context this publication belongs to (usually, the <code>webapps/lenya</code> directory).
+    * 
+    * @return A <code>File</code> object.
+    */
+   File getServletContext();
+   /**
+    * Returns the publication directory.
+    * 
+    * @return A <code>File</code> object.
+    */
+   File getDirectory();
+   /**
+    * Return the directory of a specific area.
+    * 
+    * @param area
+    *           a <code>File</code> representing the root of the area content directory.
+    * 
+    * @return the directory of the given content area.
+    */
+   File getContentDirectory(String area);
+   /**
+    * DOCUMENT ME!
+    * 
+    * @param mapper
+    *           DOCUMENT ME!
+    */
+   void setPathMapper(DefaultDocumentIdToPathMapper mapper);
+   /**
+    * Returns the path mapper.
+    * 
+    * @return a <code>DocumentIdToPathMapper</code>
+    */
+   DocumentIdToPathMapper getPathMapper();
+   /**
+    * Get the default language
+    * 
+    * @return the default language
+    */
+   String getDefaultLanguage();
+   /**
+    * Set the default language
+    * 
+    * @param language
+    *           the default language
+    */
+   void setDefaultLanguage(String language);
+   /**
+    * Get all available languages for this publication
+    * 
+    * @return an <code>Array</code> of languages
+    */
+   String[] getLanguages();
+   /**
+    * Get the breadcrumb prefix. It can be used as a prefix if a publication is part of a larger site
+    * 
+    * @return the breadcrumb prefix
+    */
+   String getBreadcrumbPrefix();
+   /**
+    * Get the SSL prefix. If you want to serve SSL-protected pages through a special site, use this prefix. This can come in handy if you have multiple sites that need SSL protection and you want to share one SSL certificate.
+    * 
+    * @return the SSL prefix
+    */
+   String getSSLPrefix();
+   /**
+    * Get the Live mount point. The live mount point is used to rewrite links that are of the form /contextprefix/publication/area/documentid to /livemountpoint/documentid
+    * 
+    * This is useful if you serve your live area through mod_proxy. to enable this functionality, set the Live mount point to / or something else. An empty mount point disables the feature.
+    * 
+    * @return the Live mount point
+    */
+   String getLiveMountPoint();
+   /**
+    * Get the sitetree for a specific area of this publication. Sitetrees are created on demand and are cached.
+    * 
+    * @param area
+    *           the area
+    * @return the sitetree for the specified area
+    * 
+    * @throws SiteTreeException
+    *            if an error occurs
+    */
+   SiteTree getTree(String area) throws SiteTreeException;
+   /**
+    * Get the sitetree for a specific area of this publication. Sitetrees are created on demand and are cached.
+    * 
+    * @deprecated Please use getTree() because this method returns the interface and not a specific implementation
+    * @see getTree()
+    * 
+    * @param area
+    *           the area
+    * @return the sitetree for the specified area
+    * 
+    * @throws SiteTreeException
+    *            if an error occurs
+    */
+   DefaultSiteTree getSiteTree(String area) throws SiteTreeException;
+   /**
+    * Returns the document builder of this instance.
+    * 
+    * @return A document builder.
+    */
+   DocumentBuilder getDocumentBuilder();
+   /**
+    * Copies a document from one location to another location.
+    * 
+    * @param sourceDocument
+    *           The document to copy.
+    * @param destinationDocument
+    *           The destination document.
+    * @throws PublicationException
+    *            if a document which destinationDocument depends on does not exist.
+    */
+   void copyDocument(Document sourceDocument, Document destinationDocument) throws PublicationException;
+   /**
+    * Copies a document to another area.
+    * 
+    * @param sourceDocument
+    *           The document to copy.
+    * @param destinationArea
+    *           The destination area.
+    * @throws PublicationException
+    *            if a document which the destination document depends on does not exist.
+    */
+   void copyDocumentToArea(Document sourceDocument, String destinationArea) throws PublicationException;
+   /**
+    * Copies a document set to another area.
+    * 
+    * @param documentSet
+    *           The document set to copy.
+    * @param destinationArea
+    *           The destination area.
+    * @throws PublicationException
+    *            if a document which one of the destination documents depends on does not exist.
+    */
+   void copyDocumentSetToArea(DocumentSet documentSet, String destinationArea) throws PublicationException;
+   /**
+    * Deletes a document.
+    * 
+    * @param document
+    *           The document to delete.
+    * @throws PublicationException
+    *            when something went wrong.
+    */
+   void deleteDocument(Document document) throws PublicationException;
+   /**
+    * Moves a document from one location to another.
+    * 
+    * @param sourceDocument
+    *           The source document.
+    * @param destinationDocument
+    *           The destination document.
+    * @throws PublicationException
+    *            if a document which the destination document depends on does not exist.
+    */
+   void moveDocument(Document sourceDocument, Document destinationDocument) throws PublicationException;
+   /**
+    * Creates a version of the document object in another area.
+    * 
+    * @param document
+    *           The document to clone.
+    * @param area
+    *           The destination area.
+    * @return A document.
+    * @throws PublicationException
+    *            when an error occurs.
+    */
+   Document getAreaVersion(Document document, String area) throws PublicationException;
+   /**
+    * Returns the proxy which is used for a particular document.
+    * 
+    * @param document
+    *           The document.
+    * @param isSslProtected
+    *           A boolean value.
+    * @return A proxy or <code>null</code> if no proxy is defined for this version.
+    */
+   Proxy getProxy(Document document, boolean isSslProtected);
+   /**
+    * Returns an array of XPaths representing attributes to be rewritten when a document URL has changed.
+    * 
+    * @return An array of strings.
+    */
+   String[] getRewriteAttributeXPaths();
+   // Lenya1.3 - BEGIN
+   PublicationModules getModules();
+   Content getContent();
+   FlatDesign getDesign();
+   File getContentDirectory();
+   String getContentType();
+   // Lenya1.3 - END
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PublicationFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PublicationFactory.java?rev=693670&r1=693669&r2=693670&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PublicationFactory.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PublicationFactory.java Tue Sep  9 17:30:20 2008
@@ -18,7 +18,6 @@
 package org.apache.lenya.cms.publication;
 import java.io.File;
 import java.io.IOException;
-import java.util.HashMap;
 import java.util.Map;
 import org.apache.cocoon.environment.Context;
 import org.apache.cocoon.environment.ObjectModelHelper;
@@ -26,11 +25,13 @@
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.excalibur.source.SourceUtil;
-import org.apache.lenya.cms.publication.file.FilePublication;
+import org.apache.lenya.util.Globals;
 import org.apache.lenya.util.ServletHelper;
 import org.apache.log4j.Logger;
 /**
  * Factory for creating publication objects.
+ * 
+ * @deprecated Use Globals.getPublication functions.
  */
 public final class PublicationFactory {
    private static Logger log = Logger.getLogger(PublicationFactory.class);
@@ -39,7 +40,7 @@
     */
    private PublicationFactory() {
    }
-   private static Map keyToPublication = new HashMap();
+   // private static Map keyToPublication = new HashMap();
    /**
     * Creates a new publication. The publication ID is resolved from the request URI. The servlet context path is resolved from the context object.
     * 
@@ -50,8 +51,10 @@
     * 
     * @throws PublicationException
     *            if there was a problem creating the publication.
+    * @deprecated Use Globals.getPublication()
     */
    public static Publication getPublication(Map objectModel) throws PublicationException {
+      // System.out.println("PublicationFactory Map");
       // assert objectModel != null;
       Request request = ObjectModelHelper.getRequest(objectModel);
       Context context = ObjectModelHelper.getContext(objectModel);
@@ -69,24 +72,27 @@
     * 
     * @throws PublicationException
     *            if there was a problem creating the publication.
+    * @deprecated Use Globals.getPublication(id)
     */
    public static Publication getPublication(String id, String servletContextPath) throws PublicationException {
-      // assert id != null;
-      // assert servletContextPath != null;
-      String key = generateKey(id, servletContextPath);
-      Publication publication = null;
-      if(keyToPublication.containsKey(key)){
-         publication = (Publication) keyToPublication.get(key);
-      }else{
-         if(PublicationFactory.existsPublication(id, servletContextPath)){
-            publication = new FilePublication(id, servletContextPath);
-            keyToPublication.put(key, publication);
-         }
-      }
-      if(publication == null){
-         throw new PublicationException("The publication for ID [" + id + "] could not be created.");
-      }
-      return publication;
+      // System.out.println("PublicationFactory id contextPath");
+      return Globals.getPublication(id);
+      // // assert id != null;
+      // // assert servletContextPath != null;
+      // String key = generateKey(id, servletContextPath);
+      // Publication publication = null;
+      // if(keyToPublication.containsKey(key)){
+      // publication = (Publication) keyToPublication.get(key);
+      // }else{
+      // if(PublicationFactory.existsPublication(id, servletContextPath)){
+      // publication = new FilePublication(id, servletContextPath);
+      // keyToPublication.put(key, publication);
+      // }
+      // }
+      // if(publication == null){
+      // throw new PublicationException("The publication for ID [" + id + "] could not be created.");
+      // }
+      // return publication;
    }
    /**
     * Generates a key to cache a publication. The cache key is constructed using the canonical servlet context path and the publication ID.
@@ -100,6 +106,7 @@
     *            when the servlet context does not exist.
     */
    protected static String generateKey(String publicationId, String servletContextPath) throws PublicationException {
+      // System.out.println("PublicationFactory.generateKey");
       String key;
       File servletContext = new File(servletContextPath);
       String canonicalPath;
@@ -123,8 +130,10 @@
     * 
     * @throws PublicationException
     *            if there was a problem creating the publication.
+    * @deprecated Use Globals.getPublication()
     */
    public static Publication getPublication(Request request, Context context) throws PublicationException {
+      // System.out.println("PublicationFactory request context");
       log.debug("Creating publication from Cocoon object model");
       String webappUrl = ServletHelper.getWebappURI(request);
       String servletContextPath = context.getRealPath("");
@@ -140,8 +149,10 @@
     * @return A publication
     * @throws PublicationException
     *            when something went wrong
+    * @deprecated Use Globals.getPublication()
     */
    public static Publication getPublication(String webappUrl, File servletContext) throws PublicationException {
+      // System.out.println("PublicationFactory url context");
       log.debug("Creating publication from webapp URL and servlet context");
       log.debug("    Webapp URL:       [" + webappUrl + "]");
       String publicationId = new URLInformation(webappUrl).getPublicationId();
@@ -156,16 +167,19 @@
     * @param servletContextPath
     *           The webapp context path.
     * @return <code>true</code> if the publication exists, <code>false</code> otherwise.
+    * @deprecated Use Globals.existsPublication(id)
     */
    public static boolean existsPublication(String id, String servletContextPath) {
-      if(servletContextPath.endsWith("/")){
-         servletContextPath = servletContextPath.substring(0, servletContextPath.length() - 1);
-      }
-      File publicationDirectory = new File(servletContextPath + File.separator + Publication.PUBLICATION_PREFIX + File.separator + id);
-      boolean exists = true;
-      exists = exists && publicationDirectory.isDirectory();
-      exists = exists && new File(publicationDirectory, Publication.CONFIGURATION_FILE).exists();
-      return exists;
+      // System.out.println("PublicationFactory.existsPublication");
+      return Globals.existsPublication(id);
+      // if(servletContextPath.endsWith("/")){
+      // servletContextPath = servletContextPath.substring(0, servletContextPath.length() - 1);
+      // }
+      // File publicationDirectory = new File(servletContextPath + File.separator + Publication.PUBLICATION_PREFIX + File.separator + id);
+      // boolean exists = true;
+      // exists = exists && publicationDirectory.isDirectory();
+      // exists = exists && new File(publicationDirectory, Publication.CONFIGURATION_FILE).exists();
+      // return exists;
    }
    /**
     * Creates a publication using a source resolver and a request.
@@ -177,8 +191,10 @@
     * @return A publication.
     * @throws PublicationException
     *            when something went wrong.
+    * @deprecated Use Globals.getPublication()
     */
    public static Publication getPublication(SourceResolver resolver, Request request) throws PublicationException {
+      // System.out.println("PublicationFactory resolver request");
       log.debug("Creating publication from resolver and request");
       Publication publication;
       String webappUri = ServletHelper.getWebappURI(request);
@@ -186,7 +202,7 @@
       try{
          source = resolver.resolveURI("context:///");
          File servletContext = SourceUtil.getFile(source);
-         publication = PublicationFactory.getPublication(webappUri, servletContext);
+         publication = getPublication(webappUri, servletContext);
       }catch(Exception e){
          throw new PublicationException(e);
       }finally{

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java?rev=693670&r1=693669&r2=693670&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java Tue Sep  9 17:30:20 2008
@@ -26,7 +26,6 @@
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationFactory;
 import org.apache.lenya.cms.publication.ResourcesManager;
 import org.apache.lenya.cms.rc.FileReservedCheckInException;
 import org.apache.lenya.cms.rc.RCEnvironment;
@@ -36,6 +35,7 @@
 import org.apache.lenya.cms.task.ExecutionException;
 import org.apache.lenya.cms.task.Task;
 import org.apache.lenya.cms.workflow.WorkflowFactory;
+import org.apache.lenya.util.Globals;
 import org.apache.lenya.workflow.Event;
 import org.apache.lenya.workflow.Situation;
 import org.apache.lenya.workflow.SynchronizedWorkflowInstances;
@@ -58,8 +58,10 @@
       if(publication == null){
          try{
             String publicationId = getParameters().getParameter(Task.PARAMETER_PUBLICATION_ID);
-            String servletContextPath = getParameters().getParameter(Task.PARAMETER_SERVLET_CONTEXT);
-            publication = PublicationFactory.getPublication(publicationId, servletContextPath);
+            publication = Globals.getPublication(publicationId);
+            if(null == publication){
+               throw new PublicationException("PublicationTask.getPublication: No Publication.");
+            }
          }catch(Exception e){
             throw new ExecutionException(e);
          }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/LoadQuartzServlet.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/LoadQuartzServlet.java?rev=693670&r1=693669&r2=693670&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/LoadQuartzServlet.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/LoadQuartzServlet.java Tue Sep  9 17:30:20 2008
@@ -37,9 +37,9 @@
 import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationFactory;
 import org.apache.lenya.cms.publishing.PublishingEnvironment;
 import org.apache.lenya.cms.scheduler.xml.TriggerHelper;
+import org.apache.lenya.util.Globals;
 import org.apache.lenya.util.NamespaceMap;
 import org.apache.lenya.xml.DocumentHelper;
 import org.apache.log4j.Logger;
@@ -220,7 +220,10 @@
             String jobId = getJobId(schedulerParameters);
             getScheduler().deleteJob(jobId, publicationId);
          }else if(action.equals(DOCUMENT_DELETED)){
-            Publication publication = PublicationFactory.getPublication(publicationId, getServletContextDirectory().getAbsolutePath());
+            Publication publication = Globals.getPublication(publicationId);
+            if(null == publication){
+               throw new PublicationException("LoadQuartzServlet.handleRequest: No Publication.");
+            }
             String documentUrl = (String) schedulerParameters.get(PARAMETER_DOCUMENT_URL);
             org.apache.lenya.cms.publication.Document document = publication.getDocumentBuilder().buildDocument(publication, documentUrl);
             deleteDocumentJobs(document);
@@ -332,7 +335,7 @@
       for(int i = 0; i < publicationDirectories.length; i++){
          File directory = publicationDirectories[i];
          String publicationId = directory.getName();
-         if(PublicationFactory.existsPublication(publicationId, getServletContextDirectory().getAbsolutePath())){
+         if(Globals.existsPublication(publicationId)){
             getScheduler().restoreJobs(publicationId);
          }
       }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/SchedulerWrapper.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/SchedulerWrapper.java?rev=693670&r1=693669&r2=693670&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/SchedulerWrapper.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/SchedulerWrapper.java Tue Sep  9 17:30:20 2008
@@ -28,8 +28,8 @@
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationFactory;
 import org.apache.lenya.cms.scheduler.xml.TriggerHelper;
+import org.apache.lenya.util.Globals;
 import org.apache.lenya.xml.NamespaceHelper;
 import org.apache.log4j.Logger;
 import org.quartz.JobDataMap;
@@ -203,7 +203,11 @@
     *            when the publication does not exist.
     */
    protected Publication getPublication(String jobGroup) throws PublicationException {
-      return PublicationFactory.getPublication(jobGroup, getServletContextPath());
+      Publication publication = Globals.getPublication(jobGroup);
+      if(null == publication){
+         throw new PublicationException("ScheduleWrapper.getPublication: No Publication.");
+      }
+      return publication;
    }
    /**
     * Adds a job.

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/task/TaskParameters.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/task/TaskParameters.java?rev=693670&r1=693669&r2=693670&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/task/TaskParameters.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/task/TaskParameters.java Tue Sep  9 17:30:20 2008
@@ -14,82 +14,71 @@
  *  limitations under the License.
  *
  */
-
 /* $Id$  */
-
 package org.apache.lenya.cms.task;
-
 import java.util.Map;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.PublicationFactory;
-
+import org.apache.lenya.util.Globals;
 public class TaskParameters extends ParameterWrapper {
-    public static final String[] REQUIRED_KEYS =
-        {
-            Task.PARAMETER_SERVLET_CONTEXT,
-            Task.PARAMETER_SERVER_URI,
-            Task.PARAMETER_SERVER_PORT,
-            Task.PARAMETER_CONTEXT_PREFIX,
-            Task.PARAMETER_PUBLICATION_ID };
-
-    /**
-     * Ctor.
-     * @param prefixedParameters The prefixed parameters .
-     */
-    public TaskParameters(Map prefixedParameters) {
-        super(prefixedParameters);
-    }
-
-    public static final String PREFIX = "task";
-
-    /**
-     * @see org.apache.lenya.cms.task.ParameterWrapper#getPrefix()
-     */
-    public String getPrefix() {
-        return PREFIX;
-    }
-
-    /**
-     * @see org.apache.lenya.cms.task.ParameterWrapper#getRequiredKeys()
-     */
-    protected String[] getRequiredKeys() {
-        return REQUIRED_KEYS;
-    }
-
-    /**
-     * Returns the publication.
-     * @return A publication.
-     * @throws ExecutionException when something went wrong.
-     */
-    public Publication getPublication() throws ExecutionException {
-        Publication publication;
-        try {
-            publication =
-                PublicationFactory.getPublication(
-                    get(Task.PARAMETER_PUBLICATION_ID),
-                    get(Task.PARAMETER_SERVLET_CONTEXT));
-        } catch (PublicationException e) {
-            throw new ExecutionException(e);
-        }
-        return publication;
-    }
-
-    /**
-     * Sets the publication.
-     * @param publication A publication.
-     */
-    public void setPublication(Publication publication) {
-        put(Task.PARAMETER_PUBLICATION_ID, publication.getId());
-        put(Task.PARAMETER_SERVLET_CONTEXT, publication.getServletContext().getAbsolutePath());
-    }
-
-    /**
-     * Sets the servlet context path.
-     * @param servletContextPath A string.
-     */
-    public void setServletContextPath(String servletContextPath) {
-        put(Task.PARAMETER_SERVLET_CONTEXT, servletContextPath);
-    }
-
+   public static final String[] REQUIRED_KEYS = {Task.PARAMETER_SERVLET_CONTEXT, Task.PARAMETER_SERVER_URI, Task.PARAMETER_SERVER_PORT, Task.PARAMETER_CONTEXT_PREFIX, Task.PARAMETER_PUBLICATION_ID};
+   /**
+    * Ctor.
+    * 
+    * @param prefixedParameters
+    *           The prefixed parameters .
+    */
+   public TaskParameters(Map prefixedParameters) {
+      super(prefixedParameters);
+   }
+   public static final String PREFIX = "task";
+   /**
+    * @see org.apache.lenya.cms.task.ParameterWrapper#getPrefix()
+    */
+   public String getPrefix() {
+      return PREFIX;
+   }
+   /**
+    * @see org.apache.lenya.cms.task.ParameterWrapper#getRequiredKeys()
+    */
+   protected String[] getRequiredKeys() {
+      return REQUIRED_KEYS;
+   }
+   /**
+    * Returns the publication.
+    * 
+    * @return A publication.
+    * @throws ExecutionException
+    *            when something went wrong.
+    */
+   public Publication getPublication() throws ExecutionException {
+      try{
+         Publication publication = Globals.getPublication(get(Task.PARAMETER_PUBLICATION_ID));
+         if(null == publication){
+            throw new PublicationException("TaskParameters.getPublication: No Publication.");
+         }
+         return publication;
+      }catch(PublicationException e){
+         throw new ExecutionException(e);
+      }
+   }
+   /**
+    * Sets the publication.
+    * 
+    * @param publication
+    *           A publication.
+    */
+   public void setPublication(Publication publication) {
+      put(Task.PARAMETER_PUBLICATION_ID, publication.getId());
+      put(Task.PARAMETER_SERVLET_CONTEXT, publication.getServletContext().getAbsolutePath());
+   }
+   /**
+    * Sets the servlet context path.
+    * 
+    * @param servletContextPath
+    *           A string.
+    */
+   public void setServletContextPath(String servletContextPath) {
+      put(Task.PARAMETER_SERVLET_CONTEXT, servletContextPath);
+   }
 }



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