svn commit: r565766 - in /lenya/trunk/src: impl/java/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/cocoon/source/ java/org/apache/lenya/cms/repository/ modules/simplesite/java/src/org/apache/lenya/cms/site/simple/ modules/sitetree/java/sr...

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Tue Aug 14 07:09:21 2007
New Revision: 565766

URL: http://svn.apache.org/viewvc?view=rev&rev=565766
Log:
Added RepositoryItem.getSession(), removed NodeFactory.setSession()

Modified:
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationConfiguration.java
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationImpl.java
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java
    lenya/trunk/src/java/org/apache/lenya/cms/repository/NodeFactory.java
    lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItem.java
    lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStore.java
    lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
    lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java
    lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeFactory.java

Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java?view=diff&rev=565766&r1=565765&r2=565766
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java Tue Aug 14 07:09:21 2007
@@ -179,16 +179,7 @@
                     webappUrl);
             if (publication.exists()) {
                 DocumentBuilder builder = publication.getDocumentBuilder();
-                if (builder.isDocument(this, webappUrl)) {
-                    DocumentLocator locator = builder.getLocator(this, webappUrl);
-                    String area = locator.getArea();
-                    String path = locator.getPath();
-                    String language = locator.getLanguage();
-                    SiteStructure site = publication.getArea(area).getSite();
-                    return site.contains(path, language);
-                } else {
-                    return false;
-                }
+                return builder.isDocument(this, webappUrl);
             } else {
                 return false;
             }

Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java?view=diff&rev=565766&r1=565765&r2=565766
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java Tue Aug 14 07:09:21 2007
@@ -534,7 +534,6 @@
         NodeFactory factory = null;
         try {
             factory = (NodeFactory) manager.lookup(NodeFactory.ROLE);
-            factory.setSession(session);
             return (Node) session.getRepositoryItem(factory, sourceUri);
         } catch (Exception e) {
             throw new RuntimeException("Creating repository node failed: ", e);
@@ -636,6 +635,10 @@
         } catch (RepositoryException e) {
             throw new RuntimeException(e);
         }
+    }
+
+    public Session getSession() {
+        return getFactory().getSession();
     }
 
 }

Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationConfiguration.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationConfiguration.java?view=diff&rev=565766&r1=565765&r2=565766
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationConfiguration.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationConfiguration.java Tue Aug 14 07:09:21 2007
@@ -28,6 +28,7 @@
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.Session;
 
 /**
  * A publication's configuration. Keep in sync with
@@ -553,6 +554,10 @@
     public String getName() {
         loadConfiguration();
         return this.name;
+    }
+
+    public Session getSession() {
+        throw new UnsupportedOperationException();
     }
 
 }

Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationImpl.java?view=diff&rev=565766&r1=565765&r2=565766
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationImpl.java Tue Aug 14 07:09:21 2007
@@ -30,6 +30,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
+import org.apache.lenya.cms.repository.Session;
 
 /**
  * A publication.
@@ -252,6 +253,10 @@
 
     public String getName() {
         return delegate.getName();
+    }
+
+    public Session getSession() {
+        return getFactory().getSession();
     }
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java?view=diff&rev=565766&r1=565765&r2=565766
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java Tue Aug 14 07:09:21 2007
@@ -108,7 +108,6 @@
         NodeFactory factory = null;
         try {
             factory = (NodeFactory) this.manager.lookup(NodeFactory.ROLE);
-            factory.setSession(session);
             
             String sourceUri;
             int revisionNumber = -1;

Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/NodeFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/repository/NodeFactory.java?view=diff&rev=565766&r1=565765&r2=565766
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/NodeFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/NodeFactory.java Tue Aug 14 07:09:21 2007
@@ -28,9 +28,4 @@
      */
     String ROLE = NodeFactory.class.getName();
     
-    /**
-     * @param session The session.
-     */
-    void setSession(Session session);
-
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItem.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItem.java?view=diff&rev=565766&r1=565765&r2=565766
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItem.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItem.java Tue Aug 14 07:09:21 2007
@@ -22,4 +22,9 @@
  */
 public interface RepositoryItem {
     
+    /**
+     * @return The session this item belongs to.
+     */
+    Session getSession();
+    
 }

Modified: lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStore.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStore.java?view=diff&rev=565766&r1=565765&r2=565766
==============================================================================
--- lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStore.java (original)
+++ lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStore.java Tue Aug 14 07:09:21 2007
@@ -32,6 +32,7 @@
 import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.cms.site.Link;
 import org.apache.lenya.cms.site.SiteException;
 import org.apache.lenya.cms.site.SiteNode;
@@ -297,5 +298,9 @@
             return node.hasLink(language);
         }
         return false;
+    }
+
+    public Session getSession() {
+        return getRepositoryNode().getSession();
     }
 }

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java?view=diff&rev=565766&r1=565765&r2=565766
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java Tue Aug 14 07:09:21 2007
@@ -29,7 +29,6 @@
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.lenya.cms.cocoon.source.SourceUtil;
 import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.repository.NodeFactory;
@@ -487,7 +486,6 @@
             NodeFactory factory = null;
             try {
                 factory = (NodeFactory) manager.lookup(NodeFactory.ROLE);
-                factory.setSession(session);
                 this.repositoryNode = (org.apache.lenya.cms.repository.Node)
                     session.getRepositoryItem(factory, this.sourceUri);
             } catch (Exception e) {
@@ -642,6 +640,10 @@
             return node.hasLink(language);
         }
         return false;
+    }
+
+    public Session getSession() {
+        return getRepositoryNode().getSession();
     }
 
 }

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java?view=diff&rev=565766&r1=565765&r2=565766
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java Tue Aug 14 07:09:21 2007
@@ -101,6 +101,7 @@
             if (repoNode.exists() /* && repoNode.getLastModified() > this.lastModified */) {
                 long lastModified = repoNode.getLastModified();
                 org.w3c.dom.Document xml = DocumentHelper.readDocument(repoNode.getInputStream());
+
                 NamespaceHelper helper = new NamespaceHelper(NAMESPACE, "", xml);
                 Assert.isTrue("document element is site", xml.getDocumentElement().getLocalName()
                         .equals("site"));
@@ -170,6 +171,11 @@
         try {
             Node repoNode = getRepositoryNode();
             NamespaceHelper helper = new NamespaceHelper(NAMESPACE, "", "site");
+
+            int revision = getRevision(repoNode) + 1;
+            helper.getDocument().getDocumentElement().setAttribute("revision",
+                    Integer.toString(revision));
+
             saveNodes(getRoot(), helper, helper.getDocument().getDocumentElement());
             helper.save(repoNode.getOutputStream());
             this.lastModified = repoNode.getLastModified();
@@ -181,6 +187,14 @@
 
     }
 
+    protected int getRevision(Node repoNode) {
+        int revision = 0;
+        if (repoNode.getHistory().getRevisionNumbers().length > 0) {
+            revision = repoNode.getHistory().getLatestRevision().getNumber();
+        }
+        return revision;
+    }
+
     protected void saveNodes(TreeNode parent, NamespaceHelper helper, Element parentElement)
             throws SiteException {
         SiteNode[] children = parent.getChildren();
@@ -391,17 +405,15 @@
         return this.area.getPublication();
     }
 
-    protected Session getSession() {
+    public Session getSession() {
         return this.area.getPublication().getFactory().getSession();
     }
 
     public Node getRepositoryNode() {
         NodeFactory factory = null;
         try {
-            Session session = getSession();
             factory = (NodeFactory) manager.lookup(NodeFactory.ROLE);
-            factory.setSession(session);
-            return (Node) session.getRepositoryItem(factory, getSourceUri());
+            return (Node) getSession().getRepositoryItem(factory, getSourceUri());
         } catch (Exception e) {
             throw new RuntimeException("Creating repository node failed: ", e);
         } finally {

Modified: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeFactory.java?view=diff&rev=565766&r1=565765&r2=565766
==============================================================================
--- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeFactory.java (original)
+++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeFactory.java Tue Aug 14 07:09:21 2007
@@ -32,7 +32,6 @@
         ThreadSafe {
 
     private ServiceManager manager;
-    private Session session;
 
     /**
      * Ctor.
@@ -40,18 +39,8 @@
     public SourceNodeFactory() {
     }
 
-    /**
-     * @param session The session.
-     */
-    public void setSession(Session session) {
-        this.session = session;
-    }
-
     public RepositoryItem buildItem(Session session, String key) throws RepositoryException {
-        if (this.session == null) {
-            throw new RepositoryException("The session has not been set!");
-        }
-        Node node = new SourceNode(this.session, key, this.manager, getLogger());
+        Node node = new SourceNode(session, key, this.manager, getLogger());
         return node;
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.