svn commit: r567725 - in /lenya/trunk/src: impl/java/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/repository/ modules/sitetree/java/src/org/apache/lenya/cms/site/tree/ modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/ modules/so...

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Mon Aug 20 08:10:20 2007
New Revision: 567725

URL: http://svn.apache.org/viewvc?rev=567725&view=rev
Log:
Use SharedItemStore specifically for the site tree. This avoids the problem that the SharedItemStore is filled with Document and other objects. The DelegatingSiteTree can be shared.

Added:
    lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingLink.java
    lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingNode.java
    lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingSiteTree.java
Modified:
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationFactory.java
    lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItemFactory.java
    lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.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/tree/SiteTree.java
    lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java
    lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeSiteManager.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?rev=567725&r1=567724&r2=567725&view=diff
==============================================================================
--- 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 Mon Aug 20 08:10:20 2007
@@ -317,10 +317,6 @@
         return getPubManager().getPublications(this);
     }
 
-    public boolean isSharable() {
-        return false;
-    }
-
     private PublicationManager pubManager;
 
     protected PublicationManager getPubManager() {

Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationFactory.java?rev=567725&r1=567724&r2=567725&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationFactory.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationFactory.java Mon Aug 20 08:10:20 2007
@@ -49,8 +49,4 @@
         return Publication.ITEM_TYPE;
     }
 
-    public boolean isSharable() {
-        return true;
-    }
-
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItemFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItemFactory.java?rev=567725&r1=567724&r2=567725&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItemFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/RepositoryItemFactory.java Mon Aug 20 08:10:20 2007
@@ -35,9 +35,4 @@
      */
     RepositoryItem buildItem(Session session, String key) throws RepositoryException;
     
-    /**
-     * @return if the items can be shared by different read-only sessions.
-     */
-    boolean isSharable();
-    
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java?rev=567725&r1=567724&r2=567725&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java Mon Aug 20 08:10:20 2007
@@ -187,13 +187,8 @@
      */
     public RepositoryItem getRepositoryItem(RepositoryItemFactory factory, String key)
             throws RepositoryException {
-
-        if (!isModifiable() && factory.isSharable()) {
-            return getSharedItemStore().getRepositoryItem(factory, key);
-        } else {
-            RepositoryItemFactoryWrapper wrapper = new RepositoryItemFactoryWrapper(factory, this);
-            return (RepositoryItem) getIdentityMap().get(wrapper, key);
-        }
+        RepositoryItemFactoryWrapper wrapper = new RepositoryItemFactoryWrapper(factory, this);
+        return (RepositoryItem) getIdentityMap().get(wrapper, key);
     }
 
     public void registerNew(Transactionable object) throws TransactionException {

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?rev=567725&r1=567724&r2=567725&view=diff
==============================================================================
--- 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 Mon Aug 20 08:10:20 2007
@@ -646,4 +646,9 @@
         return getRepositoryNode().getSession();
     }
 
+    public SiteNode[] preOrder() {
+        List preOrder = getRootNode().preOrder();
+        return (SiteNode[]) preOrder.toArray(new SiteNode[preOrder.size()]);
+    }
+
 }

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java?rev=567725&r1=567724&r2=567725&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java Mon Aug 20 08:10:20 2007
@@ -19,6 +19,7 @@
 package org.apache.lenya.cms.site.tree;
 
 import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.SiteNode;
 import org.apache.lenya.cms.site.SiteStructure;
 
 /**
@@ -47,5 +48,10 @@
      * @throws SiteException if the moving failed.
      */
     void moveDown(String path) throws SiteException;
+
+    /**
+     * @return The nodes in pre order.
+     */
+    SiteNode[] preOrder();
 
 }

Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingLink.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingLink.java?rev=567725&view=auto
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingLink.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingLink.java Mon Aug 20 08:10:20 2007
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.site.tree2;
+
+import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.site.AbstractLink;
+
+/**
+ * Site tree link which delegates all operations to a shared link.
+ */
+public class DelegatingLink extends AbstractLink {
+    
+    /**
+     * @param factory The document factory.
+     * @param node The node which this link belongs to.
+     * @param label The label.
+     * @param language The language.
+     */
+    public DelegatingLink(DocumentFactory factory, DelegatingNode node, String label, String language) {
+        super(factory, node, label, language);
+    }
+
+    public void delete() {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setLabel(String label) {
+        throw new UnsupportedOperationException();
+    }
+
+}

Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingNode.java?rev=567725&view=auto
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingNode.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingNode.java Mon Aug 20 08:10:20 2007
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.site.tree2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lenya.cms.site.Link;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.SiteNode;
+import org.apache.lenya.cms.site.SiteStructure;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
+
+/**
+ * Site tree node which delegates all operations to a shared tree node.
+ */
+public class DelegatingNode implements SiteNode, TreeNode {
+    
+    private SiteNode node;
+    private DelegatingSiteTree tree;
+
+    /**
+     * @param tree The tree.
+     * @param delegate The delegate node.
+     */
+    public DelegatingNode(DelegatingSiteTree tree, SiteNode delegate) {
+        this.node = delegate;
+        this.tree = tree;
+    }
+
+    public void delete() {
+        throw new UnsupportedOperationException();
+    }
+    
+    private List children;
+    private List preOrder;
+    
+    public SiteNode[] getChildren() {
+        if (this.children == null) {
+            SiteNode[] delegateChildren = this.node.getChildren();
+            this.children = new ArrayList();
+            for (int i = 0; i < delegateChildren.length; i++) {
+                this.children.add(this.tree.getNode(delegateChildren[i]));
+            }
+        }
+        return (SiteNode[]) this.children.toArray(new SiteNode[this.children.size()]);
+    }
+
+    public String getHref() {
+        return this.node.getHref();
+    }
+
+    public String[] getLanguages() {
+        return this.node.getLanguages();
+    }
+
+    public Link getLink(String language) throws SiteException {
+        return this.tree.getLink(this.node.getLink(language));
+    }
+
+    public String getName() {
+        return this.node.getName();
+    }
+
+    public SiteNode getParent() throws SiteException {
+        return this.tree.getNode(this.node.getParent());
+    }
+
+    public String getPath() {
+        return this.node.getPath();
+    }
+
+    public SiteStructure getStructure() {
+        return this.tree;
+    }
+
+    public String getSuffix() {
+        return this.node.getSuffix();
+    }
+
+    public String getUuid() {
+        return this.node.getUuid();
+    }
+
+    public boolean hasLink(String language) {
+        return this.node.hasLink(language);
+    }
+
+    public boolean hasLink() {
+        return this.node.hasLink();
+    }
+
+    public boolean isTopLevel() {
+        return this.node.isTopLevel();
+    }
+
+    public boolean isVisible() {
+        return this.node.isVisible();
+    }
+
+    public void setVisible(boolean visibleInNav) {
+        throw new UnsupportedOperationException();
+    }
+
+    public SiteNode addChild(String name, boolean visible) {
+        throw new UnsupportedOperationException();
+    }
+
+    public SiteNode addChild(String nodeName, String followingNodeName, boolean visible) {
+        throw new UnsupportedOperationException();
+    }
+
+    public SiteTreeImpl getTree() {
+        throw new UnsupportedOperationException();
+    }
+
+    public void moveDown(String name) {
+        throw new UnsupportedOperationException();
+    }
+
+    public void moveUp(String name) {
+        throw new UnsupportedOperationException();
+    }
+
+    public SiteNode[] preOrder() {
+        if (this.preOrder == null) {
+            SiteNode[] delegates = ((TreeNode) this.node).preOrder();
+            this.preOrder = new ArrayList();
+            for (int i = 0; i < delegates.length; i++) {
+                this.preOrder.add(this.tree.getNode(delegates[i]));
+            }
+        }
+        return (SiteNode[]) this.preOrder.toArray(new SiteNode[this.preOrder.size()]);
+    }
+
+    public SiteTreeNode[] getNextSiblings() {
+        SiteNode[] delegates = ((TreeNode) this.node).getNextSiblings();
+        SiteTreeNode[] nodes = new SiteTreeNode[delegates.length];
+        for (int i = 0; i < delegates.length; i++) {
+            nodes[i] = this.tree.getNode(delegates[i]);
+        }
+        return nodes;
+    }
+
+    public SiteTreeNode[] getPrecedingSiblings() {
+        SiteNode[] delegates = ((TreeNode) this.node).getPrecedingSiblings();
+        SiteTreeNode[] nodes = new SiteTreeNode[delegates.length];
+        for (int i = 0; i < delegates.length; i++) {
+            nodes[i] = this.tree.getNode(delegates[i]);
+        }
+        return nodes;
+    }
+
+}

Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingSiteTree.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingSiteTree.java?rev=567725&view=auto
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingSiteTree.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/DelegatingSiteTree.java Mon Aug 20 08:10:20 2007
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.site.tree2;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.lenya.cms.publication.Area;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.NodeFactory;
+import org.apache.lenya.cms.repository.RepositoryException;
+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;
+import org.apache.lenya.cms.site.SiteStructure;
+import org.apache.lenya.cms.site.tree.SiteTree;
+
+/**
+ * Site tree implementation which delegates all operations to a shared site tree.
+ */
+public class DelegatingSiteTree implements SiteStructure, SiteTree {
+    
+    private SiteTreeImpl tree;
+    private Area area;
+    private ServiceManager manager;
+    private Map links = new HashMap();
+    private Map nodes = new HashMap();
+    private List nodeList;
+    private List topLevelNodes;
+    private List preOrder;
+    private String sourceUri;
+
+    /**
+     * @param manager The service manager.
+     * @param area The area which this tree belongs to.
+     * @param tree The tree to delegate to.
+     */
+    public DelegatingSiteTree(ServiceManager manager, Area area, SiteTreeImpl tree) {
+        this.tree = tree;
+        this.area = area;
+        this.manager = manager;
+    }
+
+    public Link add(String path, Document doc) throws SiteException {
+        throw new UnsupportedOperationException();
+    }
+
+    public SiteNode add(String path) throws SiteException {
+        throw new UnsupportedOperationException();
+    }
+
+    public SiteNode add(String path, String followingSiblingPath) throws SiteException {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean contains(String path) {
+        return this.tree.contains(path);
+    }
+
+    public boolean contains(String path, String language) {
+        return this.tree.contains(path, language);
+    }
+
+    public boolean containsByUuid(String uuid, String language) {
+        return this.tree.containsByUuid(uuid, language);
+    }
+
+    public boolean containsInAnyLanguage(String uuid) {
+        return this.tree.containsInAnyLanguage(uuid);
+    }
+
+    public String getArea() {
+        return this.area.getName();
+    }
+    
+    public Link getByUuid(String uuid, String language) throws SiteException {
+        Link delegate = this.tree.getByUuid(uuid, language);
+        return getLink(delegate);
+    }
+
+    protected Link getLink(Link delegate) {
+        Link link = (Link) this.links.get(delegate);
+        if (link == null) {
+            link = new DelegatingLink(this.area.getPublication().getFactory(), getNode(delegate.getNode()),
+                    delegate.getLabel(), delegate.getLanguage());
+        }
+        return link;
+    }
+    
+    protected DelegatingNode getNode(SiteNode delegate) {
+        DelegatingNode node = (DelegatingNode) this.nodes.get(delegate);
+        if (node == null) {
+            node = new DelegatingNode(this, delegate);
+            this.nodes.put(delegate, node);
+        }
+        return node;
+    }
+
+    public SiteNode getNode(String path) throws SiteException {
+        return getNode(this.tree.getNode(path));
+    }
+
+    public SiteNode[] getNodes() {
+        if (this.nodeList == null) {
+            SiteNode[] delegates = this.tree.getNodes();
+            this.nodeList = new ArrayList();
+            for (int i = 0; i < delegates.length; i++) {
+                this.nodeList.add(getNode(delegates[i]));
+            }
+        }
+        return (SiteNode[]) this.nodeList.toArray(new SiteNode[this.nodeList.size()]);
+    }
+
+    public Publication getPublication() {
+        return this.area.getPublication();
+    }
+
+    public SiteNode[] getTopLevelNodes() {
+        if (this.topLevelNodes == null) {
+            SiteNode[] delegates = this.tree.getTopLevelNodes();
+            this.topLevelNodes = new ArrayList();
+            for (int i = 0; i < delegates.length; i++) {
+                this.topLevelNodes.add(getNode(delegates[i]));
+            }
+        }
+        return (SiteNode[]) this.topLevelNodes.toArray(new SiteNode[this.topLevelNodes.size()]);
+    }
+
+    public Session getSession() {
+        return this.area.getPublication().getSession();
+    }
+
+    private NodeFactory nodeFactory;
+    
+    protected NodeFactory getNodeFactory() {
+        if (this.nodeFactory == null) {
+            try {
+                this.nodeFactory = (NodeFactory) this.manager.lookup(NodeFactory.ROLE);
+            } catch (ServiceException e) {
+                throw new RuntimeException("Creating repository node failed: ", e);
+            }
+        }
+        return this.nodeFactory;
+    }
+
+    public Node getRepositoryNode() {
+        try {
+            return (Node) getSession().getRepositoryItem(getNodeFactory(), getSourceUri());
+        } catch (RepositoryException e) {
+            throw new RuntimeException("Creating repository node failed: ", e);
+        }
+    }
+
+    protected String getSourceUri() {
+        if (this.sourceUri == null) {
+            String baseUri = this.area.getPublication().getContentURI(this.area.getName());
+            this.sourceUri = baseUri + "/sitetree.xml";
+        }
+        return this.sourceUri;
+    }
+
+    public void moveDown(String path) throws SiteException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void moveUp(String path) throws SiteException {
+        throw new UnsupportedOperationException();
+    }
+
+    public SiteNode[] preOrder() {
+        if (this.preOrder == null) {
+            SiteNode[] delegates = this.tree.preOrder();
+            this.preOrder = new ArrayList();
+            for (int i = 0; i < delegates.length; i++) {
+                this.preOrder.add(getNode(delegates[i]));
+            }
+        }
+        return (SiteNode[]) this.preOrder.toArray(new SiteNode[this.preOrder.size()]);
+    }
+
+}

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java?rev=567725&r1=567724&r2=567725&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java Mon Aug 20 08:10:20 2007
@@ -29,6 +29,7 @@
 import org.apache.lenya.cms.repository.RepositoryItem;
 import org.apache.lenya.cms.repository.RepositoryItemFactory;
 import org.apache.lenya.cms.repository.Session;
+import org.apache.lenya.cms.repository.SharedItemStore;
 import org.apache.lenya.cms.site.tree.SiteTree;
 
 /**
@@ -54,12 +55,28 @@
         String[] snippets = key.split(":");
         String publicationId = snippets[0];
         String areaName = snippets[1];
-        SiteTreeImpl tree;
+        SiteTree tree;
         try {
             DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
             Publication publication = factory.getPublication(publicationId);
             Area  area = publication.getArea(areaName);
-            tree = new SiteTreeImpl(this.manager, area, getLogger());
+            
+            if (session.isModifiable() || session instanceof SharedItemStore) {
+                tree = new SiteTreeImpl(this.manager, area, getLogger());
+            }
+            else {
+                SharedItemStore store = null;
+                try {
+                    store = (SharedItemStore) this.manager.lookup(SharedItemStore.ROLE);
+                    SiteTreeImpl sharedTree = (SiteTreeImpl) store.getRepositoryItem(this, key);
+                    tree = new DelegatingSiteTree(this.manager, area, sharedTree);
+                }
+                finally {
+                    if (store != null) {
+                        this.manager.release(store);
+                    }
+                }
+            }
         } catch (Exception e) {
             throw new RepositoryException(e);
         }
@@ -68,10 +85,6 @@
 
     public String getItemType() {
         return SiteTree.IDENTIFIABLE_TYPE;
-    }
-
-    public boolean isSharable() {
-        return true;
     }
 
 }

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeSiteManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeSiteManager.java?rev=567725&r1=567724&r2=567725&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeSiteManager.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeSiteManager.java Mon Aug 20 08:10:20 2007
@@ -34,6 +34,7 @@
 import org.apache.lenya.cms.site.SiteException;
 import org.apache.lenya.cms.site.SiteNode;
 import org.apache.lenya.cms.site.SiteStructure;
+import org.apache.lenya.cms.site.tree.SiteTree;
 import org.apache.lenya.cms.site.tree.SiteTreeNode;
 
 /**
@@ -42,20 +43,20 @@
 public class TreeSiteManager extends AbstractSiteManager {
 
     /**
-     * Returns the sitetree for a specific area of this publication. Sitetrees
-     * are created on demand and are cached.
+     * Returns the sitetree for a specific area of this publication. Sitetrees are created on demand
+     * and are cached.
      * 
      * @param area The area.
      * @return A site tree.
      * @throws SiteException if an error occurs.
      */
-    protected SiteTreeImpl getTree(Area area) throws SiteException {
+    protected SiteTree getTree(Area area) throws SiteException {
 
         String key = getKey(area);
-        SiteTreeImpl sitetree;
+        SiteTree sitetree;
         RepositoryItemFactory factory = new SiteTreeFactory(this.manager, getLogger());
         try {
-            sitetree = (SiteTreeImpl) area.getPublication().getFactory().getSession()
+            sitetree = (SiteTree) area.getPublication().getFactory().getSession()
                     .getRepositoryItem(factory, key);
         } catch (Exception e) {
             throw new SiteException(e);
@@ -85,7 +86,7 @@
     }
 
     public void copy(Document srcDoc, Document destDoc) throws SiteException {
-        SiteTreeImpl destinationTree = getTree(destDoc.area());
+        SiteTree destinationTree = getTree(destDoc.area());
 
         try {
             TreeNodeImpl sourceNode = (TreeNodeImpl) srcDoc.getLink().getNode();
@@ -155,7 +156,7 @@
         String path = locator.getPath();
 
         Publication pub;
-        SiteTreeImpl tree;
+        SiteTree tree;
         try {
             pub = factory.getPublication(locator.getPublicationId());
             tree = getTree(pub.getArea(locator.getArea()));
@@ -201,7 +202,7 @@
         } catch (PublicationException e) {
             throw new SiteException(e);
         }
-        SiteTreeImpl tree = getTree(areaObj);
+        SiteTree tree = getTree(areaObj);
         SiteNode[] preOrder = tree.preOrder();
         List docs = new ArrayList();
         for (int i = 0; i < preOrder.length; i++) {
@@ -270,7 +271,7 @@
         if (contains(document)) {
             throw new SiteException("The document [" + document + "] is already contained!");
         }
-        SiteTreeImpl tree = getTree(document.area());
+        SiteTreeImpl tree = (SiteTreeImpl) getTree(document.area());
         TreeNodeImpl node = (TreeNodeImpl) tree.getNode(path);
         node.setUuid(document.getUUID());
         tree.save();

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?rev=567725&r1=567724&r2=567725&view=diff
==============================================================================
--- 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 Mon Aug 20 08:10:20 2007
@@ -55,8 +55,4 @@
         this.manager = manager;
     }
 
-    public boolean isSharable() {
-        return false;
-    }
-
 }
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.