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 2006/06/12 01:24:58 UTC

svn commit: r413547 [2/15] - in /lenya/branches/revolution/1.3.x: ./ src/java/org/apache/lenya/cms/cocoon/components/modules/input/ src/java/org/apache/lenya/cms/cocoon/components/source/ src/java/org/apache/lenya/cms/cocoon/components/source/impl/ src...

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,212 @@
+package org.apache.lenya.cms.cocoon.components.source.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceFactory;
+import org.apache.excalibur.source.URIAbsolutizer;
+import org.apache.excalibur.source.impl.FileSource;
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.cocoon.components.CocoonComponentManager;
+import org.apache.cocoon.components.ContextHelper;
+import org.apache.excalibur.source.SourceUtil;
+import org.apache.excalibur.source.SourceNotFoundException;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.content.Content;
+import org.apache.lenya.cms.publication.Modules;
+import org.apache.lenya.cms.publication.PageEnvelope;
+import org.apache.lenya.cms.publication.PageEnvelopeException;
+import org.apache.lenya.cms.publication.PageEnvelopeFactory;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationFactory;
+/**
+ * Implements content: protocol.
+ * This should call the Content API that calls a Content Impl.
+ * 
+ * == Content API ==
+ * Source getResourceByUNID(String unid, String translation, String revision)
+ * Source getResourceByID(String structure, String id, String translation, String revision)
+ * 
+ * == Content Impls ==
+ * ContentHierarchical (Lenya 1.2)
+ * ContentFlat (Lenya 1.3)
+ */
+
+
+public class ContentSourceFactory
+    implements SourceFactory, ThreadSafe, URIAbsolutizer, Contextualizable {
+
+    protected org.apache.avalon.framework.context.Context context;
+    private String servletContextPath;
+    String pubsPrefix;
+    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+    SourceResolver resolver = null;
+
+    public void contextualize(org.apache.avalon.framework.context.Context context)
+    throws ContextException {
+        this.context = context;
+    }
+
+    public Source getSource(String plocation, Map parameters) throws IOException, MalformedURLException {
+       String location = plocation;
+       int pos;
+       Map contextmap = ContextHelper.getObjectModel(context);
+       org.apache.cocoon.environment.http.HttpContext httpcontext = 
+             (org.apache.cocoon.environment.http.HttpContext) contextmap.get("context");
+       servletContextPath = httpcontext.getRealPath("");
+//WORK: Move resolver, pubsPrefix and other init out of getSource().  Make static?
+        ComponentManager manager = CocoonComponentManager.getSitemapComponentManager();
+        try{
+           resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+        }catch(org.apache.avalon.framework.component.ComponentException ce){
+        }
+        if(null == resolver){
+           throw new SourceNotFoundException("No Resolver: " + plocation);
+        }
+        String uri = resolver.resolveURI("").getURI();
+        pos = uri.indexOf("/pubs/");
+        if(pos > 0){
+           pubsPrefix = uri.substring(0, pos + 6);
+        }else{
+           pos = uri.indexOf("/modules/");
+           if(pos > 0){
+              pubsPrefix = uri.substring(0, pos) + "/pubs/";
+           }
+        }
+       String publication;
+       String contentpath;
+       Content content;
+       try{
+            PageEnvelope envelope = 
+                  PageEnvelopeFactory.getInstance().getPageEnvelope(ContextHelper.getObjectModel(context));
+            Publication pub = envelope.getPublication();
+            publication = pub.getId();
+            content = pub.getContent();
+            contentpath = pub.getContentDirectory().getAbsolutePath() + File.separator;
+        }catch(org.apache.lenya.cms.publication.PageEnvelopeException pee){
+            throw new MalformedURLException("Could not get Publication ID.");
+        }
+       // Decide Usage
+       //Revision
+       String revision = "live";
+       pos = location.lastIndexOf("!");
+       if(pos != -1){
+          revision = location.substring(pos + 1);
+          location = location.substring(0, pos);
+       }
+       //Language
+       String language = "";
+       pos = location.lastIndexOf("_");
+       if(pos != -1){
+          language = location.substring(pos + 1);
+          location = location.substring(0, pos);
+       }
+//WORK: Set language to document or publication's default if not specified.
+       pos = location.indexOf(":///");
+       int endpos;
+       String structure = "";
+       String unid = "";
+       String fullid = "";
+       if(pos != -1){
+          // content:///parents/resourceID
+          //Guess structure?
+          fullid = location.substring(pos + 4);
+       }else{
+          pos = location.indexOf("://");
+	    if(pos != -1){
+          // content://structure/parents/resourceID
+             pos += 3;
+             endpos = location.indexOf("/", pos);
+             if(endpos > 0){
+                structure = location.substring(pos, endpos);
+                fullid = location.substring(endpos + 1);
+             }else{
+                structure = location.substring(pos);
+             }
+          }else{
+             //Use UNID
+             // content:/resourceUNID
+             pos = location.indexOf(":/");
+             if(pos != -1){
+                // module:/unid
+                pos += 2;
+                unid = location.substring(pos);
+             }else{
+                // (Default protocol)
+                pos = location.indexOf("/");
+                if(pos != -1){
+                   fullid = location;
+                }else{
+                   unid = location;
+                }
+             }
+          }
+       }
+       if(unid.length() < 1){
+          unid = content.getUNID(structure, "/" + fullid);
+       }
+
+       /********** Get Source *************/
+       String resourcepath = contentpath + "resource" + File.separator + unid + File.separator;
+       String resourcefile = resourcepath + "resource.xml";
+       String translationfile = resourcepath + language + File.separator + "translation.xml";
+       String revisionfile = resourcepath + language + File.separator + revision + ".xml";
+
+       //Revision as filename
+       try{
+          Source source = resolver.resolveURI(revisionfile);
+          if(source.exists()){
+            if (resolver != null) manager.release(resolver);
+             return source;
+          }
+       }catch(java.net.MalformedURLException mue2){
+       }catch(java.io.IOException ioe1){
+       }
+       //Revision as translation parameter
+       try{
+//IOException!!!
+          File tf = new File(translationfile);
+          Configuration config = builder.buildFromFile(tf);
+          String newrevision = config.getAttribute(revision, null);
+          revisionfile = resourcepath + language + File.separator + newrevision + ".xml";
+System.out.println("REV2=" + revisionfile);
+             Source source = resolver.resolveURI(revisionfile);
+             if(source.exists()){
+               if (resolver != null) manager.release(resolver);
+                return source;
+             }
+       }catch(org.xml.sax.SAXException se){
+       }catch(org.apache.avalon.framework.configuration.ConfigurationException ce){
+       }catch(java.net.MalformedURLException mue2){
+       }catch(java.io.IOException ioe1){
+System.out.println("IOE=" + ioe1.getMessage());
+       }
+
+       if (resolver != null) manager.release(resolver);
+       throw new SourceNotFoundException("Not found: " + plocation);
+    }
+    public void release(Source source1) {
+    }
+    public String absolutize(String baseURI, String location) {
+        return SourceUtil.absolutize(baseURI, location, false, false);
+    }
+    private Publication getPublication(String publication){
+      try{
+         return PublicationFactory.getPublication(publication, servletContextPath);
+      }catch(org.apache.lenya.cms.publication.PublicationException pe){
+         return (Publication) null;
+      }
+    }
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,265 @@
+package org.apache.lenya.cms.cocoon.components.source.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.apache.cocoon.components.CocoonComponentManager;
+import org.apache.cocoon.components.ContextHelper;
+
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+
+import org.apache.excalibur.source.impl.FileSource;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceFactory;
+import org.apache.excalibur.source.SourceNotFoundException;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceUtil;
+import org.apache.excalibur.source.URIAbsolutizer;
+
+import org.apache.lenya.cms.publication.Modules;
+import org.apache.lenya.cms.publication.PageEnvelope;
+import org.apache.lenya.cms.publication.PageEnvelopeException;
+import org.apache.lenya.cms.publication.PageEnvelopeFactory;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationFactory;
+
+public class ModuleSourceFactory
+    implements SourceFactory, ThreadSafe, URIAbsolutizer, Contextualizable {
+
+    protected org.apache.avalon.framework.context.Context context;
+    private String servletContextPath;
+    String pubsPrefix;
+    String globalPrefix;
+    private Set publications = new HashSet();   // Publications checked
+    static private Map moduleInheritance = new HashMap();   // Key={publication, module} Value = Next publication
+
+
+    public void contextualize(org.apache.avalon.framework.context.Context context)
+    throws ContextException {
+        this.context = context;
+    }
+
+    public Source getSource(String location, Map parameters) throws IOException, MalformedURLException {
+       int pos;
+       Map contextmap = ContextHelper.getObjectModel(context);
+       org.apache.cocoon.environment.http.HttpContext httpcontext = 
+             (org.apache.cocoon.environment.http.HttpContext) contextmap.get("context");
+       servletContextPath = httpcontext.getRealPath("");
+       SourceResolver resolver = null;
+       ComponentManager manager = CocoonComponentManager.getSitemapComponentManager();
+       try{
+           resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+       }catch(org.apache.avalon.framework.component.ComponentException ce){
+       }
+       if(null == resolver){
+           System.out.println("ModuleSourceFactory ComponentException");
+           return new FileSource(location);
+       }
+       String uri = resolver.resolveURI("").getURI();
+       StringTokenizer tokens = new StringTokenizer(uri, "/\\:", true);
+       StringBuffer buffer = new StringBuffer();
+       boolean done = false;
+       while(tokens.hasMoreTokens() & !done){
+          String token = tokens.nextToken();
+          if(token.equalsIgnoreCase("pubs") | token.equalsIgnoreCase("modules")){
+             done = true;
+          }else buffer.append(token);
+       }
+       String tmpPrefix = buffer.toString();
+       globalPrefix = tmpPrefix + "modules" + File.separator;
+       pubsPrefix = tmpPrefix + "pubs" + File.separator;
+
+       String publication;
+       Modules modules;
+       publications.clear();
+       try{
+            PageEnvelope envelope = 
+                  PageEnvelopeFactory.getInstance().getPageEnvelope(ContextHelper.getObjectModel(context));
+            Publication pub = envelope.getPublication();
+            publication = pub.getId();
+		modules = pub.getModules();
+        }catch(org.apache.lenya.cms.publication.PageEnvelopeException pee){
+            throw new MalformedURLException("ModuleSourceFactory PageEnvelopeException. Could not get Publication.");
+        }
+
+       // Reset moduleInheritance
+       pos = location.indexOf("::");
+       if(pos != -1) moduleInheritance.clear();
+       // Decide Usage
+       pos = location.indexOf(":///");
+       int endpos;
+       String module = getModuleID(uri);
+       String filepath = "module.xmap";
+       if(pos != -1){
+          // module:/filepath/filename.ext
+          //Get current Module ID
+          filepath = location.substring(pos + 4);
+       }else{
+          pos = location.indexOf("://");
+	    if(pos != -1){
+             // module://modulename/filepath/filename.ext
+             pos += 3;
+             endpos = location.indexOf("/", pos);
+             if(endpos > 0){
+                module = location.substring(pos, endpos);
+                filepath = location.substring(endpos + 1);
+             }else{
+                module = location.substring(pos);
+             }
+          }else{
+             pos = location.indexOf(":/");
+             if(pos != -1){
+                // module:///publication/modulename/filepath/filename.ext
+                pos += 2;
+                endpos = location.indexOf("/", pos);
+                if(endpos > 0){
+                   publication = location.substring(pos, endpos);
+                   pos = endpos + 1;
+                   endpos = location.indexOf("/", pos);
+                   if(endpos > 0){
+                      module = location.substring(pos, endpos);
+                      filepath = location.substring(endpos + 1);
+                   }else{
+                      module = location.substring(pos);
+                   }
+                }else{
+                   publication = location.substring(pos);
+                }      
+             }else{
+                // /filepath/filename.ext (Default protocol)
+                filepath = location;
+             }
+          }
+       }
+       // Verify
+       if(publication.length() < 1) throw new MalformedURLException("No Publication ID found.");
+       if(module.length() < 1) module = getModuleID(uri);
+       if(filepath.length() < 1) filepath = "module.xmap";
+       //Check current publication
+       if(!modules.isAllowed(module)) 
+             throw new SourceNotFoundException("Not allowed: " + publication + "/" + module + "/" + filepath);
+       /********** Get Source *************/
+       //String newpath;
+       String newlocation = pubsPrefix  + publication + File.separator + "modules" + File.separator + module + File.separator + filepath;
+       // Check if exists locally.  Yes = done.
+       try{
+          Source source = resolver.resolveURI(newlocation);
+          if(source.exists()){
+            if (resolver != null) manager.release(resolver);
+             return source;
+          }
+       }catch(java.net.MalformedURLException mue2){
+       }catch(java.io.IOException ioe1){
+       }
+       publications.add(publication);
+
+       //Check inherited publication(s)
+       if(null != modules){
+          Source ret = getInheritedSource(publication, module, filepath, modules.getTemplates(module), parameters, resolver);
+          if(null != ret){
+            if (resolver != null) manager.release(resolver);
+            return ret;
+          }
+       }
+
+       // Check global
+       newlocation = globalPrefix + module + File.separator + filepath;
+       try{
+          Source source = resolver.resolveURI(newlocation);
+          if(source.exists()){
+             if (resolver != null) manager.release(resolver);
+             return source;
+          }
+       }catch(java.net.MalformedURLException mue2){
+       }catch(java.io.IOException ioe1){
+       }
+       if (resolver != null) manager.release(resolver);
+       throw new SourceNotFoundException("Not found: " + publication + "/" + module + "/" + filepath);
+    }
+
+    public void release(Source source1) {
+    }
+
+    public String absolutize(String baseURI, String location) {
+        return SourceUtil.absolutize(baseURI, location, false, false);
+    }
+   private String getModuleID(String uri) throws MalformedURLException{
+        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;
+   }
+   private Source getInheritedSource(String publication, String modulex, String filepath, String[] templates, Map parameters, SourceResolver resolver){
+       String module = modulex;
+       int i = 0;
+       boolean found = false;
+       Modules modules = (Modules) null;
+       String key = publication + "~" + module;
+       String newpublication = "";
+       if(moduleInheritance.containsKey(key)){
+          newpublication = (String) moduleInheritance.get(key);
+          Publication pub = getPublication(newpublication);
+          modules = pub.getModules();
+          found = true;
+          publications.add(templates[i]);
+       }else{
+          while(!found & (i < templates.length)){
+             newpublication = templates[i];
+             // Do not repeat publication
+             if(!publications.contains(newpublication)){
+                modules = (Modules) null;
+                Publication pub = getPublication(newpublication);
+                if(null != pub){
+                   modules = pub.getModules();
+                   if(modules.isAllowed(module)) found = true;
+                }
+                publications.add(newpublication);
+             }
+             i++;
+          }
+       }
+       if(found){
+          moduleInheritance.put(key , newpublication);
+          String newlocation = pubsPrefix + newpublication + File.separator + "modules" + File.separator+ module + File.separator + filepath;
+          try{
+             Source source = resolver.resolveURI(newlocation);
+             if(source.exists()){
+                return source;
+             }
+          }catch(java.net.MalformedURLException mue2){
+          }catch(java.io.IOException ioe1){
+          }
+          if(null != modules){
+             //First check if module name was overridden
+             Source ret = getInheritedSource(newpublication, modules.getInheritedModule(module), 
+                   filepath, modules.getTemplates(module), parameters, resolver);
+             if(null != ret) return ret;
+             return getInheritedSource(newpublication, module, filepath, modules.getTemplates(module), parameters, resolver);
+          }
+       }
+       return (Source) null;
+   }
+   private Publication getPublication(String publication){
+      try{
+         return PublicationFactory.getPublication(publication, servletContextPath);
+      }catch(org.apache.lenya.cms.publication.PublicationException pe){
+         return (Publication) null;
+      }
+   }
+}
\ No newline at end of file

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ModuleSourceFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Content.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Content.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Content.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Content.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,12 @@
+package org.apache.lenya.cms.content;
+
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceNotFoundException;
+import org.apache.lenya.cms.publication.Publication;
+
+public interface Content{
+   public String getUNID(String structure, String id);
+   public String getNewFilename(String unid, String language);
+   public String getIndexFilename(String indexName, String language);
+   public String[] getLanguages();
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Content.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Resource.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Resource.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Resource.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Resource.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,41 @@
+package org.apache.lenya.cms.content;
+
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceNotFoundException;
+
+public interface Resource{
+ 
+//   public Source getSource(String translation, String revision) throws SourceNotFoundException;
+
+   public String getUNID();
+   public String getID();
+
+   public String getType();
+
+   public String getDocumentType();
+
+   public String getLanguage();
+
+   public String getDefaultLanguage();
+
+   public String[] getLanguages();
+
+   public String getNewFilename(String language);
+
+
+/**
+ * Get Navigation Title from live revision of current language.
+ */
+   public String getTitle();
+/**
+ * Get Navigation Title from live revision of specified language.
+ */
+   public String getTitle(String language);
+/**
+ * Get Navigation Title from specified revision of specified language.
+ */
+   public String getTitle(String language, String revision);
+
+//   public Translation getTranslation(String translation);
+
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/Resource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/SitetreeGenerator.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/SitetreeGenerator.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/SitetreeGenerator.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/SitetreeGenerator.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,188 @@
+package org.apache.lenya.cms.content.flat;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.util.Map;
+import java.util.*;
+import org.apache.avalon.excalibur.pool.Recyclable;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.caching.CacheableProcessingComponent;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.generation.ServiceableGenerator;
+import org.apache.excalibur.xml.sax.XMLConsumer;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.lenya.cms.publication.PageEnvelope;
+import org.apache.lenya.cms.publication.PageEnvelopeException;
+import org.apache.lenya.cms.publication.PageEnvelopeFactory;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationFactory;
+
+import org.xml.sax.SAXException;
+/*
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.XMLReaderFactory;
+*/
+
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.generation.AbstractGenerator;
+
+/**
+ * The <code>SitetreeGenerator</code> is a class that reads XML from a source
+ * and generates SAX Events.
+ * The SitetreeGenerator implements the <code>CacheableProcessingComponent</code> interface.
+ * 
+ * @cocoon.sitemap.component.name   sitetree
+ * @cocoon.sitemap.component.label  content
+ * @cocoon.sitemap.component.logger sitemap.generator.sitetree
+ * @cocoon.sitemap.component.documentation.caching
+ * @cocoon.sitemap.component.pooling.min   8
+ * @cocoon.sitemap.component.pooling.max  32
+ * @cocoon.sitemap.component.pooling.grow  4
+ *
+ * @author <a href="mailto:solprovider@apache.org">Paul Ercolino</a>
+ */
+public class SitetreeGenerator extends ServiceableGenerator
+implements CacheableProcessingComponent {
+
+    /** The input source */
+    protected Source inputSource;
+
+    /**
+     * Recycle this component.
+     * All instance variables are set to <code>null</code>.
+     */
+    public void recycle() {
+        if (null != this.inputSource) {
+            super.resolver.release(this.inputSource);
+            this.inputSource = null;
+        }
+        super.recycle();
+    }
+
+    /**
+     * 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 {
+        super.setup(resolver, objectModel, src, par);
+        try {
+   PageEnvelope envelope;
+   String publication = "FAILED";
+   Publication pub;
+   String language = "en";
+       try{
+            envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
+            pub = envelope.getPublication();
+            publication = pub.getId();
+            language = envelope.getDocument().getLanguage();
+       }catch(org.apache.lenya.cms.publication.PageEnvelopeException pee){
+            System.out.println("PEE EXCEPTION");
+            throw new ProcessingException("Sitetree Generator: could not use PageEnvelope.");          
+       } 
+// Lenya1.3
+       if(pub.getContentType().equalsIgnoreCase("flat")){
+          this.inputSource = super.resolver.resolveURI(pub.getContent().getIndexFilename(src, language));
+       }else{
+// Lenya1.2
+          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());
+          }
+        } catch (SourceException se) {
+            throw SourceUtil.handle("Error during resolving of '" + src + "'.", se);
+        }
+    }
+
+    /**
+     * Generate the unique key.
+     * This key must be unique inside the space of this component.
+     *
+     * @return The generated key hashes the src
+     */
+    public Serializable getKey() {
+        return this.inputSource.getURI();
+    }
+
+    /**
+     * Generate the validity object.
+     *
+     * @return The generated validity object or <code>null</code> if the
+     *         component is currently not cacheable.
+     */
+    public SourceValidity getValidity() {
+        return this.inputSource.getValidity();
+    }
+
+    /**
+     * Generate XML data.
+     */
+    public void generate()
+        throws IOException, SAXException, ProcessingException {
+        try {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Source " + super.source +
+                                  " resolved to " + this.inputSource.getURI());
+            }
+           SourceUtil.parse(this.manager, this.inputSource, super.xmlConsumer);
+        } catch (SAXException e) {
+            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;
+   }
+   private Publication getPublication(String publication, String servletContextPath){
+      try{
+         return PublicationFactory.getPublication(publication, servletContextPath);
+      }catch(org.apache.lenya.cms.publication.PublicationException pe){
+System.out.println("PNF: " + publication + " not found.");
+         return (Publication) null;
+      }
+   }
+
+
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/SitetreeGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,222 @@
+package org.apache.lenya.cms.content.flat;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.transformation.AbstractDOMTransformer;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.servlet.multipart.Part;
+import org.apache.lenya.cms.content.Content;
+import org.apache.lenya.cms.publication.PageEnvelope;
+import org.apache.lenya.cms.publication.PageEnvelopeFactory;
+import org.apache.lenya.cms.publication.Publication;
+//import org.apache.lenya.cms.publication.ResourcesManager;
+import org.apache.lenya.xml.DocumentHelper;
+import org.apache.lenya.xml.NamespaceHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+/**
+ * @cocoon.sitemap.component.documentation
+ * This transformer creates a new Revision.
+ * 
+ * It takes the UNID as the src parameter, uses the current language, and create a new Revision
+ * It will be enhanced to take "/structure/path/docid" as the src.  That will be easy.  If there is a slash, then convert using Content.getUNID().
+ * 
+ * Much of the code was modified from org.apache.lenya.cms.cocoon.acting.UploadAction
+ * 
+ * @author <a href="mailto:solprovider@apache.org">Paul Ercolino</a>
+ */
+public class CreateRevisionTransformer extends AbstractDOMTransformer{
+    private static final String SERIALIZER_NAME = "xml";
+    public static final String UPLOADASSET_PARAM_NAME = "properties.asset.data";
+    public static final String UPLOADASSET_PARAM_PREFIX = "properties.asset.";
+    public static final String UPLOADASSET_RETURN_FILESIZE = "file-size";
+    public static final String UPLOADASSET_RETURN_MIMETYPE = "mime-type";
+    public static final String CONTENT_PREFIX = "content";
+    public static final String FILE_NAME_REGEXP = "[-a-zA-Z0-9_. ]+";
+    // optional parameters for meta data according to dublin core
+    public static final String[] DUBLIN_CORE_PARAMETERS = { "title", "creator", "subject",
+            "description", "publisher", "contributor", "date", "type", "format", "identifier",
+            "source", "language", "relation", "coverage", "rights" };
+
+    protected org.w3c.dom.Document transform(org.w3c.dom.Document doc){
+       Request request = ObjectModelHelper.getRequest(super.objectModel);
+       PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
+       Publication pub = envelope.getPublication();
+       Content content = pub.getContent();
+       String unid = this.source;
+       String language = envelope.getDocument().getLanguage();
+       String sourceName = content.getNewFilename(unid, language);
+       try{
+           save(sourceName, doc);
+       }catch(java.io.IOException ioe){
+           System.out.println("CreateRevision: IOException");
+       }catch(org.apache.cocoon.ProcessingException pe){
+           System.out.println("CreateRevision: ProcessingException");
+       }catch(org.xml.sax.SAXException saxe){
+           System.out.println("CreateRevision: SAXException");
+       }
+       return doc;
+    }
+
+    /**
+     *
+     * @param systemID The name of the revision xml file.
+     * @param doc The data to be inserted.
+     */
+    private void save(String systemID, org.w3c.dom.Document doc)
+    throws SAXException, IOException, ProcessingException {
+        // test parameters
+        if (systemID == null) throw new ProcessingException("createFile: systemID is required.");
+        if (doc == null) throw new ProcessingException("createFile: document is required.");
+        File file = new File(systemID);
+        if(file.exists()){
+System.out.println("Revision '"+systemID+"' already exists.");
+           throw new ProcessingException("Revision '"+systemID+"' already exists.");
+        }
+        String filenameNoExtension = systemID;
+        int pos = systemID.lastIndexOf(".");
+        if(pos > 0) filenameNoExtension = systemID.substring(0, pos);
+//System.out.println("Upload: FNE=" + filenameNoExtension);
+        //Check for file upload from request, Save fileupload.
+        Request request = ObjectModelHelper.getRequest(super.objectModel);
+        File assetFile;
+        // determine if the upload is an asset or a content upload
+        Map dublinCoreParams = getDublinCoreParameters(request);
+        // upload the file to the uploadDir
+        Part part = (Part) request.get(UPLOADASSET_PARAM_NAME);
+        String extension = "";
+        Document metadoc = (Document) null;
+        if(null != part){
+           String filename = part.getFileName();
+           pos = filename.lastIndexOf(".");
+           if(pos > 0) extension = filename.substring(pos);
+System.out.println("Upload: EXT=" + extension);
+           String mimeType = part.getMimeType();
+           dublinCoreParams.put("format", mimeType);
+           int fileSize = part.getSize();
+           dublinCoreParams.put("extent", Integer.toString(fileSize));
+           assetFile = new File(filenameNoExtension + "." + extension);
+           try{
+              saveFileFromPart(assetFile, part);
+           }catch(java.lang.Exception e){
+System.out.println("CreateRevision: Exception saving upload.");
+               throw new ProcessingException("CreateRevision: Exception saving upload.");
+           }
+           try{
+              metadoc = createMetaDocument(dublinCoreParams);
+           }catch(javax.xml.transform.TransformerConfigurationException tce){
+System.out.println("CreateRevision: TransformerConfigurationException creating DC Meta Document.");
+           }catch(javax.xml.transform.TransformerException te){
+System.out.println("CreateRevision: TransformerException creating DC Meta Document.");
+           }catch(javax.xml.parsers.ParserConfigurationException pce){
+System.out.println("CreateRevision: ParserConfigurationException creating DC Meta Document.");
+
+           }
+        }
+//Upload is saved.
+//doc contains input.
+//metadoc contains DublinCore Document.
+//WORK: Merge documents and store extension.
+        if(null != metadoc){
+            File metaDataFile = new File(filenameNoExtension + ".meta");
+            try{
+               DocumentHelper.writeDocument(metadoc, metaDataFile);
+            }catch(javax.xml.transform.TransformerConfigurationException tce){
+System.out.println("CreateRevision: TransformerConfigurationException saving DC Meta Document.");
+            }catch(javax.xml.transform.TransformerException te){
+System.out.println("CreateRevision: TransformerException saving DC Meta Document.");
+            }
+        }
+            try{
+               DocumentHelper.writeDocument(doc, file);
+            }catch(javax.xml.transform.TransformerConfigurationException tce){
+System.out.println("CreateRevision: TransformerConfigurationException");
+               throw new ProcessingException("CreateRevision: TransformerConfigurationException");
+            }catch(javax.xml.transform.TransformerException te){
+System.out.println("CreateRevision: TransformerException");
+               throw new ProcessingException("CreateRevision: TransformerException");
+            }
+    }
+
+    /**
+     * Saves the asset to a file.
+     * 
+     * @param assetFile The asset file.
+     * @param part The part of the multipart request.
+     * @throws Exception if an error occurs.
+     */
+    protected void saveFileFromPart(File assetFile, Part part) throws Exception {
+        if (!assetFile.exists()) {
+            boolean created = assetFile.createNewFile();
+            if (!created) {
+                throw new RuntimeException("The file [" + assetFile + "] could not be created.");
+            }
+        }
+        byte[] buf = new byte[4096];
+        FileOutputStream out = new FileOutputStream(assetFile);
+        try {
+            InputStream in = part.getInputStream();
+            int read = in.read(buf);
+            while (read > 0) {
+                out.write(buf, 0, read);
+                read = in.read(buf);
+            }
+        } finally {
+            out.close();
+        }
+    }
+    /**
+     * Retrieves optional parameters for the meta file which contains dublin core information from
+     * the request.
+     * @param request The request.
+     * @return A map.
+     */
+    protected Map getDublinCoreParameters(Request request) {
+        HashMap dublinCoreParams = new HashMap();
+        for (int i = 0; i < DUBLIN_CORE_PARAMETERS.length; i++) {
+            String paramName = DUBLIN_CORE_PARAMETERS[i];
+            String paramValue = request.getParameter(UPLOADASSET_PARAM_PREFIX + paramName);
+            if (paramValue == null)  paramValue = "";
+            dublinCoreParams.put(paramName, paramValue);
+        }
+        Iterator iter = dublinCoreParams.keySet().iterator();
+        while (iter.hasNext()) {
+            String paramName = (String) iter.next();
+            getLogger().debug(paramName + ": " + dublinCoreParams.get(paramName));
+        }
+        return dublinCoreParams;
+    }
+
+    /**
+     * Create the meta data file given the dublin core parameters.
+     * 
+     * @param dublinCoreParams a <code>Map</code> containing the dublin core values
+     * @throws TransformerConfigurationException if an error occurs.
+     * @throws TransformerException if an error occurs.
+     * @throws ParserConfigurationException if an error occurs.
+     */
+    protected org.w3c.dom.Document createMetaDocument(Map dublinCoreParams)
+            throws TransformerConfigurationException, TransformerException, ParserConfigurationException {
+        NamespaceHelper helper = new NamespaceHelper("http://purl.org/dc/elements/1.1/", "dc", "metadata");
+        Element root = helper.getDocument().getDocumentElement();
+        Iterator iter = dublinCoreParams.keySet().iterator();
+        while (iter.hasNext()) {
+            String tagName = (String) iter.next();
+            String tagValue = (String) dublinCoreParams.get(tagName);
+            root.appendChild(helper.createElement(tagName, tagValue));
+        }
+        return helper.getDocument();
+    }
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatContent.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatContent.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatContent.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatContent.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,65 @@
+package org.apache.lenya.cms.content.flat;
+
+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.Indexer;
+import org.apache.lenya.cms.content.Resource;
+import org.apache.lenya.cms.publication.Publication;
+
+public class FlatContent implements Content{
+   File directory;
+   FlatIndexer indexer;
+   String[] languages = { "en" };
+
+   public FlatContent(File pdirectory, String[] planguages){
+      directory = pdirectory;
+      languages = planguages;
+      indexer = new FlatIndexer(new File(directory, "index"), this);
+// The next line starts indexing everything in the background when Lenya starts.
+      new Thread((Runnable) indexer).start();
+   }
+/* Content API */
+   public String getIndexFilename(String indexName, String language){
+     return indexer.getIndexFilename(indexName, language);
+   }
+   public String getNewFilename(String unid, String language){
+      Resource resource = getResource(unid, language, "live");
+      return resource.getNewFilename(language);
+   }
+   public String getUNID(String structure, String id){
+      FlatRelations relations = getRelations(structure);
+      return relations.getUNID(id);
+   }
+/* FlatContent API */
+   public String[] getLanguages(){
+      return languages;
+   }
+   public String[] getResources(){
+      return (new File(directory, "resource")).list();
+   }
+   public Resource getResource(String unid, String language, String revision){
+      return (Resource) new FlatResource(directory, unid, language, revision);
+   }
+   public FlatRelations getRelations(String structure){
+     return new FlatRelations(new File(directory, "relation" + File.separator + structure + ".xml"));
+   }
+
+/* Obsolete 
+   public Resource getResource(String unid){
+      return (Resource) new FlatResource(directory, unid);
+   }
+   public Resource getResource(String unid, String language){
+      return (Resource) new FlatResource(directory, unid, language);
+   }
+
+   public Source getSource(String unid, String translation, String revision) throws SourceNotFoundException {
+      return (Source) null;
+   }
+   public Source getMeta(String unid, String translation, String revision) throws SourceNotFoundException {
+      return (Source) null;
+   }
+*/
+
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatContent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndex.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndex.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndex.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndex.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,196 @@
+package org.apache.lenya.cms.content.flat;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+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.content.flat.index.FlatIndexPart;
+import org.apache.lenya.xml.DocumentHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class FlatIndex {
+   File configurationFile;
+   File indexFile;
+   FlatContent content;
+   String indexName;
+   String language = "en";
+   String structure = "";
+   String revision = "live";
+   Map filter = new HashMap();
+   Map include = new HashMap();
+
+   public FlatIndex(FlatContent pcontent, File indexDirectory, String pindexName, String planguage){
+      indexName = pindexName;
+      configurationFile = new File(indexDirectory, indexName + ".xconf");
+      indexFile = new File(indexDirectory, indexName + "_" + planguage + ".xml");
+      content = pcontent;
+      language = planguage;
+//      loadConfiguration();
+   }
+   private void loadConfiguration(){
+      Document document;
+      try{
+         document = DocumentHelper.readDocument(configurationFile);
+      }catch(javax.xml.parsers.ParserConfigurationException pce){
+         System.out.println("Indexer: could not parse " + configurationFile.getPath());
+         return;
+      }catch(org.xml.sax.SAXException saxe){
+         System.out.println("Indexer: " + configurationFile.getPath() + " is not valid.");
+         return;
+      }catch(java.io.IOException ioe){
+         System.out.println("Indexer: could not read " + configurationFile.getPath());
+         return;
+      }
+      Element root = document.getDocumentElement();
+      if(root.hasAttribute("structure")) structure = root.getAttribute("structure");
+      if(root.hasAttribute("revision")) revision = root.getAttribute("revision");
+      NodeList nl;
+      int length;
+      int i;
+      nl = root.getElementsByTagName("filter");
+      length = nl.getLength();
+      for(i = 0; i < length; i++){
+         FlatIndexPart part = new FlatIndexPart((Element) nl.item(i));
+         filter.put(part.getName(), part);
+      }
+      nl = root.getElementsByTagName("include");
+      length = nl.getLength();
+      for(i = 0; i < length; i++){
+         FlatIndexPart part = new FlatIndexPart((Element) nl.item(i));
+         include.put(part.getName(), part);
+      }
+      include.put("unid", new FlatIndexPart("unid"));
+      include.put("type", new FlatIndexPart("type"));
+      include.put("doctype", new FlatIndexPart("doctype"));
+      include.put("id", new FlatIndexPart("id"));
+      include.put("title", new FlatIndexPart("title"));
+      include.put("href", new FlatIndexPart("href"));
+   }
+   public String getIndexFilename(){
+      if(!indexFile.exists()) update();
+      return indexFile.getPath();
+   }
+   public void update(){
+System.out.println("Indexer updating " + indexName + "(" + language + ")");
+      loadConfiguration();
+      // Init Document
+      Document document;
+      try{
+         document = org.apache.lenya.xml.DocumentHelper.createDocument("", "index", null);
+      }catch(javax.xml.parsers.ParserConfigurationException pce){
+         System.out.println("FlatIndex: ParserConfigurationException");
+         return;
+      }
+      Element root = document.getDocumentElement();
+      root.setAttribute("name", indexName);
+      root.setAttribute("language", language);
+      //Update
+      if(structure.length() > 0){
+         include.put("fullid", new FlatIndexPart("fullid"));
+         updateStructure(document, root);
+      }else updateFlat(document, root);
+      // Write document
+      try{
+         org.apache.lenya.xml.DocumentHelper.writeDocument(document, indexFile);
+      }catch(javax.xml.transform.TransformerConfigurationException tce){
+          System.out.println("FlatIndex: TransformerConfigurationException");
+      }catch(javax.xml.transform.TransformerException te){
+          System.out.println("FlatIndex: TransformerException");
+      }catch(java.io.IOException ioe){
+          System.out.println("FlatIndex: IOException");
+      }
+//System.out.println("Indexing " + indexName + "_" + language + " Completed");
+   }
+   private void updateStructure(Document document, Element root){
+      FlatRelations relations = content.getRelations(structure);
+      Element resourceElement = relations.getRoot();
+      addStructureResource(document, root, resourceElement, "", "");
+   }
+/**
+ * Add child "resource" elements of resourceElement to root, and recurse for each.  Must pass filters.
+ */
+   private void addStructureResource(Document document, Element root, Element resourceElement, String parenttype, String parentdoctype){
+//      NodeList children = resourceElement.getElementsByTagName("resource"); //getDescendants, need getChildren
+      NodeList children = resourceElement.getChildNodes();
+      int length = children.getLength();
+      for(int i = 0; i < length; i++){
+         if(children.item(i).getNodeName().equals("resource")){
+            Element resourceChild = (Element) children.item(i);
+            String unid = resourceChild.getAttribute("unid");
+            FlatResource resource = 
+                  (FlatResource) content.getResource(unid, language, revision);
+            if(resource.hasRevision()){
+               String fullid = resourceChild.getAttribute("full");
+               String fulltype = parenttype + "/" + resource.getType();
+               String fulldoctype = parentdoctype + "/" + resource.getDocumentType();
+               FlatIndexPart part;
+               //FILTER - BEGIN
+               Iterator fi = filter.values().iterator();
+               boolean useResource = true;
+               while(fi.hasNext() & useResource){
+                  part = (FlatIndexPart) fi.next();
+                  useResource = false;
+                  if(part.check(resource.get(part.getProperty(), fullid, fulltype, fulldoctype))) useResource = true;
+               }
+               //FILTER - END
+               if(useResource){
+                  //INCLUDE - BEGIN
+                  Element element = addElement(document, root, "resource");
+                  element.setAttribute("unid", unid);
+                  Iterator ii = include.values().iterator();
+                  while(ii.hasNext()){
+                     part = (FlatIndexPart) ii.next();
+                     String value = resource.get(part.getProperty(), fullid);
+                     if(value.length() > 0) element.setAttribute(part.getName(), value);
+                  }
+                  //INCLUDE - END
+                  addStructureResource(document, element, resourceChild, fulltype, fulldoctype);
+               }  //if useResource
+            } //if resource not null
+         }  //if "resource"
+      }  //for
+   }  //function
+   private void updateFlat(Document document, Element root){
+      // Build Index
+      String[] unids = content.getResources();
+      int unidsLength = unids.length;
+      for(int u = 0; u < unidsLength; u++){
+         FlatResource resource = (FlatResource) content.getResource(unids[u], language, revision);
+         if(resource.hasRevision()){
+            FlatIndexPart part;
+            //FILTER - BEGIN
+            Iterator fi = filter.values().iterator();
+            boolean useResource = true;
+            while(fi.hasNext() & useResource){
+               part = (FlatIndexPart) fi.next();
+               useResource = false;
+               if(part.check(resource.get(part.getProperty()))) useResource = true;
+            }
+            //FILTER - END
+            if(useResource){
+               //INCLUDE - BEGIN
+               Element element = addElement(document, root, "resource");
+               element.setAttribute("unid", unids[u]);
+               Iterator ii = include.values().iterator();
+               while(ii.hasNext()){
+                  part = (FlatIndexPart) ii.next();
+                  String value = resource.get(part.getProperty());
+                 if(value.length() > 0) element.setAttribute(part.getName(), value);
+               }
+               //INCLUDE - END
+            }  //if useResource
+         } //if resource not null
+      }
+   }
+   private Element addElement(Document document, Element parent, String newElementName){
+      Element newElement = document.createElement(newElementName);
+      parent.appendChild(newElement);
+      return newElement;
+   }
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndexPart.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndexPart.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndexPart.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndexPart.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,46 @@
+package org.apache.lenya.cms.content.flat.index;
+
+import java.util.StringTokenizer;
+import org.w3c.dom.Element;
+
+public class FlatIndexPart {
+   String name="";
+   String property = "";
+   String value = "";
+
+   public FlatIndexPart(Element element){
+      if(element.hasAttribute("property")){
+         property = element.getAttribute("property");
+         name = property;
+      }
+      if(element.hasAttribute("name")) property = element.getAttribute("name");
+
+      if(null != element.getFirstChild()){
+         value = element.getFirstChild().getNodeValue();
+         if(null == value) value = "";
+      }
+   }
+   public FlatIndexPart(String variable){
+      name = variable;
+      property = variable;
+   }
+   public String getName(){ return name; }
+   public String getProperty(){ return property; }
+   public String getValue(){ return value; }
+
+   public boolean check(String test){
+//System.out.print(" T=" + test + " V=" + value);
+      if(test.length() < 1) return true;
+      if(test.equals("/")) return true; //Structured indexes add slash prefix.
+      if(test.equalsIgnoreCase("true")) return true;
+      String token;
+      StringTokenizer tokens = new StringTokenizer(value, "|,;");
+      do{
+         token = tokens.nextToken();
+         if(test.equals(token)) return true;
+         if(test.endsWith(token)) return true;
+      }while(tokens.hasMoreTokens());
+//System.out.print(" FALSE ");
+      return false;
+   }
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndexPart.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndexer.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndexer.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndexer.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndexer.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,49 @@
+package org.apache.lenya.cms.content.flat;
+
+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;
+
+public class FlatIndexer implements Runnable {
+   File indexDirectory;
+   FlatContent content;
+   boolean isCurrent = false;
+
+   public FlatIndexer(File pindexDirectory, FlatContent pcontent){
+      indexDirectory = pindexDirectory;
+      content = pcontent;
+   }
+
+   public void run(){
+      updateAll();
+   }
+
+   public void updateAll(){
+      if(isCurrent) return;
+      if(!indexDirectory.exists()) return;
+//System.out.println("Starting Indexer UpdateAll");
+      String[] files = indexDirectory.list();
+//System.out.println("FI-uA: iD=" + indexDirectory.getPath());
+      if(null == files) return;
+      int filesLength = files.length;
+      for(int f = 0; f < filesLength; f++){
+         String filename = files[f];
+         if(filename.endsWith(".xconf")){
+            String indexName = filename.substring(0, filename.lastIndexOf(".xconf"));
+            String[] languages = content.getLanguages();
+            int languagesLength = languages.length;
+            for(int l = 0; l < languagesLength; l++){
+               String language = languages[l];
+               FlatIndex index = new FlatIndex(content, indexDirectory, indexName, language);
+               index.update();
+            }
+         }
+      }
+      isCurrent = true;
+   }
+   public String getIndexFilename(String indexName, String language){
+      return (new FlatIndex(content, indexDirectory, indexName, language)).getIndexFilename();
+   }
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndexer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatRelations.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatRelations.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatRelations.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatRelations.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,56 @@
+package org.apache.lenya.cms.content.flat;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.lenya.xml.DocumentHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class FlatRelations {
+   File file;
+   Document relations;
+   Element root;
+   Map map;
+
+   public FlatRelations(File pfile){
+      file = pfile;
+      reset();
+   }
+
+   public void reset(){
+      try{
+         relations = DocumentHelper.readDocument(file);
+         map = new HashMap();
+         root = relations.getDocumentElement();
+         addResourceToMap(root);
+//WORK: Log Catches properly
+      }catch(javax.xml.parsers.ParserConfigurationException pce){
+         System.out.println("FlatRelations 1: Could not parse " + file.toString());
+      }catch(org.xml.sax.SAXException saxe){
+         System.out.println("FlatRelations 2: Could not parse " + file.toString());
+      }catch(java.io.IOException ioe){
+         // File not found.  Expected for non-Lenya1.3 pubs.
+      }
+   }
+   private void addResourceToMap(Element root){
+         NodeList resources = root.getElementsByTagName("resource");
+         int length = resources.getLength();
+         for(int i = 0; i < length; i++){
+            Element resource = (Element) resources.item(i);
+            map.put(resource.getAttribute("full"), resource.getAttribute("unid"));
+            addResourceToMap(resource);
+         }
+   }
+   public Element getRoot(){ return root; }
+   public String getUNID(String unid){
+      update();
+      if(map.containsKey(unid)) return (String) map.get(unid);
+      return "";
+   }
+   private void update(){
+//WORK: Reset if file modified
+   }
+
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatRelations.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatResource.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatResource.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatResource.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatResource.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,193 @@
+package org.apache.lenya.cms.content.flat;
+
+import java.io.File;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceNotFoundException;
+import org.apache.lenya.cms.content.Resource;
+//import org.apache.lenya.cms.content.Translation;
+import org.apache.lenya.xml.DocumentHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class FlatResource implements Resource {
+   File contentDirectory;
+   File resourceDirectory;
+   Document resource;
+   Element root;
+   String unid ="";
+   String id ="";
+   String type = "xml";
+   String doctype = "";
+   String defaultLanguage = "en";
+   String defaultRevision = "live";
+   String extension = "";
+   String[] languages = {"en"};
+
+   public FlatResource(File directory, String punid, String language, String revision){
+      contentDirectory = directory;
+      unid = punid;
+      defaultLanguage = language;
+      defaultRevision = revision;
+      init(false);
+   }
+   public FlatResource(File directory, String punid, String language){
+      contentDirectory = directory;
+      unid = punid;
+      defaultLanguage = language;
+      init(false);
+   }
+   public FlatResource(File directory, String punid){
+      contentDirectory = directory;
+      unid = punid;
+//WORK: defaultLanguage = Publication's default language.
+      init(true);
+   }
+   private void init(boolean useDefaultLanguage){
+      resourceDirectory = new File(contentDirectory, "resource" + File.separator + unid);
+      try{
+         resource = DocumentHelper.readDocument(new File(resourceDirectory, "resource.xml"));
+         root = resource.getDocumentElement();
+         if(useDefaultLanguage){
+            if(root.hasAttribute("defaultlanguage")){
+              defaultLanguage = root.getAttribute("defaultlanguage");
+            }else{
+//WORK: Use Publication's Default Language
+            }
+         }
+         if(root.hasAttribute("doctype")) doctype = root.getAttribute("doctype");
+         if(root.hasAttribute("type")) type = root.getAttribute("type");
+         if(root.hasAttribute("id")) id = root.getAttribute("id");
+         NodeList ts = root.getElementsByTagName("translation");
+         int length = ts.getLength();
+         languages = new String[length];
+         for(int i = 0; i < length; i++){
+            Element t = (Element) ts.item(i);
+            languages[i] = t.getAttribute("language");
+         }
+      }catch(javax.xml.parsers.ParserConfigurationException pce){
+      }catch(org.xml.sax.SAXException saxe){
+      }catch(java.io.IOException ioe){
+      }
+   }
+   public String getUNID(){
+      return unid;
+   }
+   public String getID(){
+      return id;
+   }
+   public String getType(){
+      return type;
+   }
+   public String getDocumentType(){
+      return doctype;
+   }
+   public String getLanguage(){
+      return defaultLanguage;
+   }
+//Maintain separately?
+   public String getDefaultLanguage(){
+      return defaultLanguage;
+   }
+   public String[] getLanguages(){
+     return languages;
+   }
+/**
+ * Get Navigation Title from live revision of current language.
+ */
+   public String getTitle(){
+      return getTitle(defaultLanguage, "live");
+   }
+/**
+ * Get Navigation Title from live revision of specified language.
+ */
+   public String getTitle(String language){
+      return getTitle(language, "live");
+   }
+/**
+ * Get Navigation Title from specified revision of specified language.
+ */
+   public String getTitle(String language, String revision){
+      return getTranslation(language).getRevision(revision).getTitle();
+   }
+   public String getExtension(){
+      return getTranslation().getExtension();
+   }
+   public String getHREF(){
+      return getTranslation().getHREF();
+   }
+   public String getNewFilename(String language){
+      return getTranslation(language).getNewFilename();
+   }
+
+/**
+ * Get variable for Index Filters
+ */
+   public String get(String property, String fullid, String fulltype, String fulldoctype){
+      if(property.equalsIgnoreCase("type")){ return fulltype;
+      }else if(property.equalsIgnoreCase("doctype")){ return fulldoctype;
+      }
+      return get(property, fullid);
+   }
+/**
+ * Get variable for Structured Index Filters
+ */
+   public String get(String property, String fullid){
+      if(property.equalsIgnoreCase("fullid")){ return fullid; }
+      return get(property);
+   }
+/**
+ * Get variable for Flat Index Includes
+ */
+   public String get(String property){
+      if(property.equalsIgnoreCase("unid")){ return getUNID();
+      }else if(property.equalsIgnoreCase("id")){ return getID();
+      }else if(property.equalsIgnoreCase("type")){ return getType();
+      }else if(property.equalsIgnoreCase("doctype")){ return getDocumentType();
+      }else if(property.equalsIgnoreCase("extension")){ return getExtension();
+      }else if(property.equalsIgnoreCase("title")){ return getTitle();
+      }else if(property.equalsIgnoreCase("language")){ return getLanguage();
+      }else if(property.equalsIgnoreCase("fullid")){ return getID();
+      }else if(property.equalsIgnoreCase("href")){ return getHREF();
+      }
+      return getXPath(property);
+   }
+   private String getXPath(String property){
+      return "";
+   }
+
+   public FlatTranslation getTranslation(){
+      return getTranslation(defaultLanguage, true);
+   }
+   public FlatTranslation getTranslation(String language){
+      return getTranslation(language, true);
+   }
+   public FlatTranslation getTranslation(String language, boolean allowDefaultLanguage){
+      if(allowDefaultLanguage){
+         return new FlatTranslation(resourceDirectory, language, defaultLanguage);
+      }else return new FlatTranslation(resourceDirectory, language);
+   }
+   public boolean hasRevision(){
+/*
+System.out.println("U=" + unid + " L=" + defaultLanguage + " R=" + defaultRevision);
+     FlatTranslation translation = getTranslation(defaultLanguage, false);
+     if(null == translation) System.out.println("Null Translation");
+     FlatRevision revision = translation.getRevision(defaultRevision);
+     if(null == revision) System.out.println("Null Revision");
+     boolean exists = revision.exists();
+     System.out.println("Exists=" + exists);
+*/
+      try{
+         return getTranslation(defaultLanguage, false).getRevision(defaultRevision).exists();
+      }catch(java.lang.NullPointerException npe){
+         return false;
+      }
+   }
+/*
+   public Source getSource(String translation, String revision) throws SourceNotFoundException {
+      throw new SourceNotFoundException("FlatResource.getSource is not implemented yet");
+   }
+
+*/
+
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatRevision.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatRevision.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatRevision.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatRevision.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,68 @@
+package org.apache.lenya.cms.content.flat;
+
+import java.io.File;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceNotFoundException;
+//import org.apache.lenya.cms.content.Revision;
+import org.apache.lenya.xml.DocumentHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class FlatRevision {
+   File translationDirectory;
+   File file;
+   File metafile;
+   String revision;
+   String title = "";
+   String extension = "";
+   String href = "";
+   Document resource;
+   Element root;
+
+   public FlatRevision(File directory, String prevision){
+      translationDirectory = directory;
+      revision = prevision;
+      init();
+   }
+   private void init(){
+      try{
+         metafile = new File(translationDirectory, revision + ".xml");
+         resource = DocumentHelper.readDocument(metafile);
+         root = resource.getDocumentElement();
+         if(root.hasAttribute("title")) title = root.getAttribute("title");
+         if(root.hasAttribute("extension")) extension = root.getAttribute("extension");
+         if(root.hasAttribute("href")) href = root.getAttribute("href");
+      }catch(javax.xml.parsers.ParserConfigurationException pce){
+      }catch(org.xml.sax.SAXException saxe){
+      }catch(java.io.IOException ioe){
+      }
+      if(extension.length() > 0){
+         file = new File(translationDirectory, revision + "." + extension);
+      }else file = metafile;
+   }
+   public String getTitle(){
+      return title;
+   }
+   public String getExtension(){
+      return extension;
+   }
+   public String getHREF(){
+      return href;
+   }
+   public String getFilename(){
+      return file.getPath();
+   }
+   public String getMetaFilename(){
+      return metafile.getPath();
+   }
+   public boolean exists(){
+      return file.exists();
+   }
+
+
+/*
+   public Source getSource() throws SourceNotFoundException{
+      throw new SourceNotFoundException("FlatRevision.getSource is not implemented yet");
+   }
+*/
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatRevision.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatTranslation.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatTranslation.java?rev=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatTranslation.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatTranslation.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,129 @@
+package org.apache.lenya.cms.content.flat;
+
+import java.io.File;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceNotFoundException;
+//import org.apache.lenya.cms.content.Revision;
+//import org.apache.lenya.cms.content.Translation;
+import org.apache.lenya.xml.DocumentHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class FlatTranslation {
+   File resourceDirectory;
+   File translationDirectory;
+   String language = "en";
+   String defaultLanguage = "en";
+   String live = "";
+   String edit = "last";
+   String revision = "live";
+   Document document;
+   Element root;
+
+   SortedSet revisions = new TreeSet();
+   public FlatTranslation(File directory, String planguage, String pdefaultLanguage, String prevision){
+      resourceDirectory = directory;
+      language = planguage;
+      defaultLanguage = pdefaultLanguage;
+      revision = prevision;
+      init();
+   }
+   public FlatTranslation(File directory, String planguage, String pdefaultLanguage){
+      resourceDirectory = directory;
+      language = planguage;
+      defaultLanguage = pdefaultLanguage;
+      init();
+   }
+   public FlatTranslation(File directory, String planguage){
+      resourceDirectory = directory;
+      language = planguage;
+      defaultLanguage = planguage;
+      init();
+   }
+   private void init(){
+      translationDirectory = new File(resourceDirectory, language);
+      if(!translationDirectory.exists()) translationDirectory = new File(resourceDirectory, defaultLanguage);
+      if(!translationDirectory.exists()) return;
+      try{
+         document = DocumentHelper.readDocument(new File(translationDirectory, "translation.xml"));
+         root = document.getDocumentElement();
+         if(root.hasAttribute("live")) live = root.getAttribute("live");
+         if(root.hasAttribute("edit")) edit = root.getAttribute("edit");
+      }catch(javax.xml.parsers.ParserConfigurationException pce){
+System.out.println("FlatTranslation: ParserConfigurationException");
+      }catch(org.xml.sax.SAXException saxe){
+System.out.println("FlatTranslation: SAXException");
+      }catch(java.io.IOException ioe){
+System.out.println("FlatTranslation: IOException");
+      }
+      String[] filelist = translationDirectory.list();
+      for(int f = 0; f < filelist.length; f++){
+         String filename = filelist[f];
+         int pos = filename.lastIndexOf(".");
+         if(pos > 0) filename = filename.substring(0, pos);
+         if(!filename.equalsIgnoreCase("translation")) revisions.add(filename);
+      }
+   }
+   public String[] getRevisions() {
+      return (String[]) revisions.toArray();
+   }
+   public String getLive() {
+      return live;      
+   }
+   public String getEdit() {
+      return edit;
+   }
+   public String getNewFilename(){
+      String newRevision = getDateString();
+//WORK: Change Edit to newRevision
+      return new File(translationDirectory, newRevision + ".xml").getPath();
+   }
+   public String getExtension() {
+      FlatRevision fr = getRevision();
+      if(null == fr) return "";
+      return fr.getExtension();
+   }
+   public String getHREF() {
+      FlatRevision fr = getRevision();
+      if(null == fr) return "";
+      return fr.getHREF();
+   }
+   public FlatRevision getRevision(){
+      return getRevision(revision);
+   }
+   public FlatRevision getRevision(String prevision){
+      String rev = prevision;
+      if(rev.equalsIgnoreCase("edit")){
+          if(edit.length() > 0){
+             rev = edit;
+          }else rev = live;
+      }
+      if(rev.equalsIgnoreCase("live")) rev = live;
+      try{
+         if(rev.equalsIgnoreCase("last")) rev = (String) revisions.last();
+         if(rev.equalsIgnoreCase("first")) rev = (String) revisions.first();
+      }catch(java.util.NoSuchElementException nsee){
+         return null;
+      }
+      if(null == rev) return null;
+      if(rev.length() < 1) return null;
+      return new FlatRevision(translationDirectory, rev);
+   }
+   private String getDateString(){
+      return Long.toString(new java.util.Date().getTime());
+   }
+
+/*
+   public Source getSource(String revision) throws SourceNotFoundException {
+      throw new SourceNotFoundException("FlatTranslation.getSource is not implemented yet");
+   }
+   public Source getMeta() throws SourceNotFoundException {
+      throw new SourceNotFoundException("FlatTranslation.getMeta is not implemented yet");
+   }
+   public Source getTranslationMeta(String translation) throws SourceNotFoundException {
+      throw new SourceNotFoundException("FlatTranslation.getTranslationMeta is not implemented yet");
+   }
+*/
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatTranslation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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=413547&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/hierarchical/HierarchicalContent.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/hierarchical/HierarchicalContent.java Sun Jun 11 16:24:48 2006
@@ -0,0 +1,36 @@
+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{
+   File directory;
+   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.
+   }
+   public String getUNID(String structure, String id){
+      return structure + File.separator + id;
+   }
+   public String[] getLanguages(){
+      return languages;
+   }
+   public String getNewFilename(String unid, String language){
+      return new File(directory, "live" + File.separator + unid + File.separator + getDateString() + "_" + language +"." + ".xml").getPath();
+   }
+
+   private String getDateString(){
+      return Long.toString(new java.util.Date().getTime());
+   }
+}

Propchange: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/hierarchical/HierarchicalContent.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=413547&r1=413546&r2=413547&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 Sun Jun 11 16:24:48 2006
@@ -31,6 +31,12 @@
 import org.apache.lenya.cms.publishing.PublishingEnvironment;
 import org.apache.log4j.Category;
 
+//Lenya1.3 - BEGIN
+import org.apache.lenya.cms.content.Content;
+import org.apache.lenya.cms.content.flat.FlatContent;
+import org.apache.lenya.cms.content.hierarchical.HierarchicalContent;
+//Lenya1.3 - END
+
 /**
  * A publication.
  */
@@ -63,6 +69,14 @@
     private static final String ATTRIBUTE_XPATH = "xpath";
 	private static final String ELEMENT_CONTENT_DIR = "content-dir";
 
+//Lenya1.3 - BEGIN
+   private Modules modules;
+   private Content content;
+   private File publicationDirectory;
+   private File contentDirectory;
+   private String contentType = "hierarchical";
+//Lenya1.3 - END
+
     /**
      * Creates a new instance of Publication
      * 
@@ -170,6 +184,21 @@
             	this.areaContentDir.put(key, dir);
             }
 
+//Lenya1.3 - BEGIN
+//Content
+            Configuration contentConfig = config.getChild("content");
+            contentType = contentConfig.getAttribute("type", "hierarchical");
+            String contentConfigValue = contentConfig.getValue(CONTENT_PATH);
+            publicationDirectory = new File(getServletContext(), PUBLICATION_PREFIX + File.separator + getId());
+            contentDirectory = new File(publicationDirectory, contentConfigValue);
+            if(contentType.equalsIgnoreCase("flat")){
+               content = (Content) new FlatContent(contentDirectory, getLanguages());
+            }else{
+               content = (Content) new HierarchicalContent(contentDirectory, getLanguages());
+            }
+//Modules
+            modules = new Modules(id, servletContextPath, config.getChild("modules"));
+//Lenya1.3 - END
             
         } catch (PublicationException e) {
             throw e;
@@ -186,6 +215,20 @@
         livemountpoint = config.getChild(LIVE_MOUNT_POINT).getValue("");
 
     }
+//Lenya1.3 - BEGIN
+    public Modules getModules() {
+        return modules;
+    }
+    public Content getContent() {
+        return content;
+    }
+    public File getContentDirectory() {
+        return contentDirectory;
+    }
+    public String getContentType() {
+        return contentType;
+    }
+//Lenya1.3 - END    
 
     /**
      * Returns the publication ID.
@@ -213,21 +256,26 @@
         return servletContext;
     }
 
+//Lenya1.3 BEGIN - changed
     /**
      * Returns the publication directory.
      * @return A <code>File</code> object.
      */
     public File getDirectory() {
-        return 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
     /**
      * 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.
+     * @deprecated Areas are bad.  Do not use them.
      */
+//Lenya1.3 END
     public File getContentDirectory(String area) {
     	Object key = getContentDirKey(area);
     	String contentDir = (String) this.areaContentDir.get(key);

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?rev=413547&r1=413546&r2=413547&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Sun Jun 11 16:24:48 2006
@@ -265,12 +265,16 @@
      * Sets the area.
      * @param area A string.
      */
+// LENYA1.3 BEGIN - Area as Module cannot error, so assume "live".
     protected void setArea(String area) {
         if (!AbstractPublication.isValidArea(area)) {
-            throw new IllegalArgumentException("The area [" + area + "] is not valid!");
+           this.area = Publication.LIVE_AREA;
+        }else{
+           this.area = area;
         }
-        this.area = area;
     }
+// LENYA1.3 END
+
 
     private String extension = "html";
 

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java?rev=413547&r1=413546&r2=413547&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java Sun Jun 11 16:24:48 2006
@@ -67,9 +67,20 @@
         String documentId = documentURL;
 
         if (!documentId.startsWith("/")) {
-            throw new DocumentBuildException(
-                "Document ID [" + documentId + "] does not start with '/'!");
+//Lenya 1.3 - BEGIN
+//         throw new DocumentBuildException("Document ID [" + documentId + "] does not start with '/'!");
+           documentId = "/index";
+//Lenya 1.3 - END
         }
+//TODO: If documentId starts with parameters, remove each possible parameter, and check if document exists
+//try each of these with remaining docID.
+//   last parameter = structure
+//   first parameter = structure
+//   structure = "live"
+//NEED Content.documentExists(structure, docID)
+//Then try: for each part from end, is UNID?
+//NEED Content.documentExists(UNID)
+//Lenya 1.3 - END
 
         DefaultDocument document =
             createDocument(publication, info.getArea(), documentId, language);



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