You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/08/14 17:57:48 UTC

svn commit: r431374 - in /lenya/trunk/src: impl/java/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/site/ java/org/apache/lenya/cms/site/simple/ java/org/apache/lenya/cms/site/topicmap/ modules-core/s...

Author: andreas
Date: Mon Aug 14 08:57:47 2006
New Revision: 431374

URL: http://svn.apache.org/viewvc?rev=431374&view=rev
Log:
Changed SiteManager to avoid handling non-existing nodes, removed obsolete placeholder feature

Modified:
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java
    lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/MoveSubsite.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/TreeSiteManager.java
    lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
    lenya/trunk/src/webapp/lenya/config/cocoon-xconf/metadata/document.xconf

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?rev=431374&r1=431373&r2=431374&view=diff
==============================================================================
--- 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 Mon Aug 14 08:57:47 2006
@@ -82,12 +82,6 @@
     public static final String METADATA_EXTENSION = "extension";
 
     /**
-     * Determines if the document is just a placeholder in the trash and archive areas.
-     * @see org.apache.lenya.cms.site.usecases.MoveSubsite
-     */
-    public static final String METADATA_PLACEHOLDER = "placeholder";
-
-    /**
      * Creates a new instance of DefaultDocument.
      * @param manager The service manager.
      * @param map The identity map the document belongs to.
@@ -448,29 +442,6 @@
 
     public String[] getMetaDataNamespaceUris() throws MetaDataException {
         return getRepositoryNode().getMetaDataNamespaceUris();
-    }
-
-    public boolean isPlaceholder() {
-        try {
-            MetaData meta = getMetaData(METADATA_NAMESPACE);
-            String value = meta.getFirstValue(METADATA_PLACEHOLDER);
-            if (value == null) {
-                return false;
-            } else {
-                return Boolean.valueOf(value).booleanValue();
-            }
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    public void setPlaceholder() {
-        try {
-            MetaData meta = getMetaData(METADATA_NAMESPACE);
-            meta.setValue(METADATA_PLACEHOLDER, "true");
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
     }
 
     public String getMimeType() throws DocumentException {

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java?rev=431374&r1=431373&r2=431374&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java Mon Aug 14 08:57:47 2006
@@ -202,16 +202,6 @@
     String getSourceExtension();
     
     /**
-     * @return if this is placeholder document (in trash / archive areas).
-     */
-    boolean isPlaceholder();
-    
-    /**
-     *  Set if this is placeholder document (in trash / archive areas).
-     */
-    void setPlaceholder();
-    
-    /**
      * Sets the mime type of this document.
      * @param mimeType The mime type.
      * @throws DocumentException if an error occurs.

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java?rev=431374&r1=431373&r2=431374&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java Mon Aug 14 08:57:47 2006
@@ -65,11 +65,11 @@
      * Returns the resources which are required by a certain resource.
      * 
      * @param map The identity map to operate on.
-     * @param resource The depending resource.
+     * @param locator The depending locator.
      * @return An array of resources.
      * @throws SiteException if an error occurs.
      */
-    SiteNode[] getRequiredResources(DocumentFactory map, SiteNode resource) throws SiteException;
+    DocumentLocator[] getRequiredResources(DocumentFactory map, DocumentLocator locator) throws SiteException;
 
     /**
      * Returns the resources which require a certain resource.
@@ -124,7 +124,7 @@
      * @throws SiteException when something went wrong.
      */
     void copy(Document sourceDocument, Document destinationDocument) throws SiteException;
-
+    
     /**
      * Sets the label of a certain document.
      * 

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java?rev=431374&r1=431373&r2=431374&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteStructure.java Mon Aug 14 08:57:47 2006
@@ -96,5 +96,13 @@
      */
     Link add(String path, Document doc) throws SiteException;
 
+    /**
+     * Adds a site node.
+     * @param path The path.
+     * @return A site node.
+     * @throws SiteException if the path is already contained.
+     */
+    SiteNode add(String path) throws SiteException;
+
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java?rev=431374&r1=431373&r2=431374&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java Mon Aug 14 08:57:47 2006
@@ -274,4 +274,9 @@
         }
     }
 
+    public SiteNode add(String path) throws SiteException {
+        throw new SiteException("This operation is not supported by [" + getClass().getName()
+                + "]!");
+    }
+
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java?rev=431374&r1=431373&r2=431374&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java Mon Aug 14 08:57:47 2006
@@ -59,15 +59,6 @@
     }
 
     /**
-     * @see org.apache.lenya.cms.site.SiteManager#getRequiredResources(org.apache.lenya.cms.publication.DocumentFactory,
-     *      org.apache.lenya.cms.site.SiteNode)
-     */
-    public SiteNode[] getRequiredResources(DocumentFactory map, SiteNode resource)
-            throws SiteException {
-        return new SiteNode[0];
-    }
-
-    /**
      * @see org.apache.lenya.cms.site.SiteManager#getRequiringResources(org.apache.lenya.cms.publication.DocumentFactory,
      *      org.apache.lenya.cms.site.SiteNode)
      */
@@ -248,6 +239,16 @@
         } catch (TransactionException e) {
             throw new SiteException(e);
         }
+    }
+
+    public DocumentLocator[] getRequiredResources(DocumentFactory map, DocumentLocator locator)
+            throws SiteException {
+        return new DocumentLocator[0];
+    }
+
+    public void move(SiteNode source, String destinationPath) throws SiteException {
+        throw new SiteException("This operation is not supported by [" + getClass().getName()
+                + "]!");
     }
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java?rev=431374&r1=431373&r2=431374&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java Mon Aug 14 08:57:47 2006
@@ -41,16 +41,6 @@
     }
 
     /**
-     * @see org.apache.lenya.cms.site.SiteManager#getRequiredResources(org.apache.lenya.cms.publication.DocumentFactory,
-     *      org.apache.lenya.cms.site.SiteNode)
-     */
-    public SiteNode[] getRequiredResources(DocumentFactory map, SiteNode resource)
-            throws SiteException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /**
      * @see org.apache.lenya.cms.site.SiteManager#getRequiringResources(org.apache.lenya.cms.publication.DocumentFactory,
      *      org.apache.lenya.cms.site.SiteNode)
      */
@@ -77,14 +67,6 @@
     }
 
     /**
-     * @see org.apache.lenya.cms.site.SiteManager#getUUID(org.apache.lenya.cms.publication.Document)
-     */
-    public String getUUID(Document resource) throws SiteException {
-        // TODO: Implement this method ...
-        return null;
-    }
-
-    /**
      * @see org.apache.lenya.cms.site.SiteManager#containsInAnyLanguage(org.apache.lenya.cms.publication.Document)
      */
     public boolean containsInAnyLanguage(Document resource) throws SiteException {
@@ -102,23 +84,6 @@
     }
 
     /**
-     * @see org.apache.lenya.cms.site.SiteManager#delete(org.apache.lenya.cms.publication.Document)
-     */
-    public void delete(Document document) throws SiteException {
-        // TODO Auto-generated method stub
-
-    }
-
-    /**
-     * @see org.apache.lenya.cms.site.SiteManager#setLabel(org.apache.lenya.cms.publication.Document,
-     *      java.lang.String)
-     */
-    public void setLabel(Document document, String label) throws SiteException {
-        // TODO Auto-generated method stub
-
-    }
-
-    /**
      * @see org.apache.lenya.cms.site.SiteManager#setVisibleInNav(org.apache.lenya.cms.publication.Document,
      *      boolean)
      */
@@ -157,24 +122,22 @@
         return true;
     }
 
-    public String getPath(DocumentFactory factory, Publication pub, String area, String uuid) throws SiteException {
+    public void set(String path, Document document) throws SiteException {
         // TODO Auto-generated method stub
-        return null;
     }
 
-    public String getUUID(DocumentFactory factory, Publication pub, String area, String path) throws SiteException {
-        // TODO Auto-generated method stub
-        return null;
+    public DocumentLocator[] getRequiredResources(DocumentFactory map, DocumentLocator locator)
+            throws SiteException {
+        return new DocumentLocator[0];
     }
 
-    public boolean contains(DocumentFactory factory, DocumentLocator locator) throws SiteException {
-        // TODO Auto-generated method stub
-        return false;
+    public void move(SiteNode source, String destinationPath) throws SiteException {
+        throw new SiteException("This operation is not supported by [" + getClass().getName()
+                + "]!");
     }
 
-    public void set(String path, Document document) throws SiteException {
+    public void setLabel(Document document, String label) throws SiteException {
         // TODO Auto-generated method stub
-        
     }
 
 }

Modified: lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/MoveSubsite.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/MoveSubsite.java?rev=431374&r1=431373&r2=431374&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/MoveSubsite.java (original)
+++ lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/MoveSubsite.java Mon Aug 14 08:57:47 2006
@@ -16,26 +16,19 @@
  */
 package org.apache.lenya.cms.site.usecases;
 
-import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
+import java.util.Set;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentBuildException;
-import org.apache.lenya.cms.publication.DocumentException;
-import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.DocumentLocator;
 import org.apache.lenya.cms.publication.DocumentManager;
 import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.util.DocumentHelper;
+import org.apache.lenya.cms.publication.PublicationException;
 import org.apache.lenya.cms.publication.util.DocumentSet;
-import org.apache.lenya.cms.site.NodeSet;
-import org.apache.lenya.cms.site.SiteException;
-import org.apache.lenya.cms.site.SiteManager;
-import org.apache.lenya.cms.site.SiteNode;
+import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.site.SiteStructure;
 import org.apache.lenya.cms.site.SiteUtil;
 import org.apache.lenya.cms.usecase.DocumentUsecase;
 import org.apache.lenya.cms.usecase.UsecaseException;
@@ -94,55 +87,31 @@
     protected abstract String getEvent();
 
     /**
-     * Lock the following objects:
-     * <ul>
-     * <li>all involved documents in the document's area</li>
-     * <li>the target versions of these documents</li>
-     * <li>the document area's site structure</li>
-     * <li>the target site structure</li>
-     * </ul>
-     * @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock()
+     * Lock all source documents and the site structure repository nodes because changes to the site
+     * structure would compromise the operation.
      */
-    protected org.apache.lenya.cms.repository.Node[] getNodesToLock() throws UsecaseException {
-        List nodes = new ArrayList();
-        Document doc = getSourceDocument();
+    protected Node[] getNodesToLock() throws UsecaseException {
         try {
-            DocumentSet sources = SiteUtil.getSubSite(this.manager, doc);
-            Map targets = SiteUtil.getTransferedSubSite(this.manager,
-                    doc,
-                    getTargetArea(),
-                    SiteUtil.MODE_CHANGE_ID);
-
-            Document[] docs = sources.getDocuments();
-            for (int i = 0; i < docs.length; i++) {
-                nodes.add(docs[i].getRepositoryNode());
-                nodes.addAll(AssetUtil.getAssetNodes(docs[i], this.manager, getLogger()));
-
-                Document target = (Document) targets.get(docs[i]);
-                nodes.add(target.getRepositoryNode());
-                nodes.addAll(AssetUtil.getCopiedAssetNodes(docs[i],
-                        target,
-                        this.manager,
-                        getLogger()));
-            }
-
-            DocumentSet furtherDocs = new DocumentSet();
-            furtherDocs.addAll(getTargetDocsToCopy());
-            furtherDocs.addAll(getSourceDocsToDelete(sources));
-            docs = furtherDocs.getDocuments();
+            
+            Set nodes = new HashSet();
+            
+            SiteStructure sourceSite = getSourceDocument().area().getSite();
+            SiteStructure targetSite = getSourceDocument().getPublication()
+                    .getArea(getTargetArea())
+                    .getSite();
+            
+            nodes.add(sourceSite.getRepositoryNode());
+            nodes.add(targetSite.getRepositoryNode());
+            
+            Document[] docs  = SiteUtil.getSubSite(this.manager, getSourceDocument()).getDocuments();
             for (int i = 0; i < docs.length; i++) {
                 nodes.add(docs[i].getRepositoryNode());
             }
-
-            nodes.add(SiteUtil.getSiteStructure(this.manager, doc).getRepositoryNode());
-            nodes.add(SiteUtil.getSiteStructure(this.manager,
-                    getDocumentFactory(),
-                    doc.getPublication(),
-                    getTargetArea()).getRepositoryNode());
-        } catch (Exception e) {
+            
+            return (Node[]) nodes.toArray(new Node[nodes.size()]);
+        } catch (PublicationException e) {
             throw new UsecaseException(e);
         }
-        return (org.apache.lenya.cms.repository.Node[]) nodes.toArray(new org.apache.lenya.cms.repository.Node[nodes.size()]);
     }
 
     /**
@@ -150,192 +119,40 @@
      */
     protected void doExecute() throws Exception {
 
+        String targetArea = getTargetArea();
         Document doc = getSourceDocument();
-        DocumentSet sources = SiteUtil.getSubSite(this.manager, doc);
-        DocumentFactory map = getDocumentFactory();
-
-        DocumentLocator loc = doc.getLocator().getAreaVersion(getTargetArea());
-        loc = SiteUtil.getAvailableLocator(this.manager, map, loc);
-
-        DocumentSet docsToCopy = getTargetDocsToCopy();
-
-        DocumentManager documentManager = null;
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
-        try {
-
-            WorkflowUtil.invoke(this.manager, getSession(), getLogger(), sources, getEvent(), true);
-
-            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
+        Document[] sources = SiteUtil.getSubSite(this.manager, doc).getDocuments();
+        SiteStructure targetSite = doc.getPublication().getArea(targetArea).getSite();
 
-            SiteUtil.sortAscending(this.manager, docsToCopy);
-            Document[] targetDocs = docsToCopy.getDocuments();
-            for (int i = 0; i < targetDocs.length; i++) {
-                DocumentLocator sourceLoc = targetDocs[i].getLocator()
-                        .getAreaVersion(doc.getArea());
-                Document sourceDoc = map.get(sourceLoc);
-                Document existingSourceDoc = DocumentHelper.getExistingLanguageVersion(sourceDoc,
-                        doc.getLanguage());
-                DocumentLocator targetLoc = existingSourceDoc.getLocator()
-                        .getAreaVersion(getTargetArea());
-                documentManager.copyDocument(existingSourceDoc, targetLoc);
-                if (!targetLoc.getArea().equals(Publication.AUTHORING_AREA)) {
-                    Document targetDoc = getDocumentFactory().get(targetLoc);
-                    targetDoc.setPlaceholder();
-                }
-            }
-
-            Map targetMap = SiteUtil.getTransferedSubSite(this.manager,
-                    doc,
-                    getTargetArea(),
-                    SiteUtil.MODE_CHANGE_ID);
-            DocumentSet targets = new DocumentSet();
-            Document[] docs = sources.getDocuments();
-            for (int i = 0; i < docs.length; i++) {
-                targets.add((Document) targetMap.get(docs[i]));
-            }
-            documentManager.move(sources, targets);
-
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(doc.getPublication().getSiteManagerHint());
-
-            DocumentSet docsToDelete = getSourceDocsToDelete(sources);
-            documentManager.delete(docsToDelete);
-
-        } finally {
-            if (documentManager != null) {
-                this.manager.release(documentManager);
-            }
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
-            }
+        DocumentLocator targetParent = doc.getLocator().getAreaVersion(targetArea);
+        while (!targetSite.contains(targetParent.getPath()) && !targetParent.getPath().equals("")) {
+            targetSite.add(targetParent.getPath());
         }
 
-        setTargetDocument(getDocumentFactory().get(loc));
-
-    }
-
-    /**
-     * @return All target documents that are required by the moved documents and have to be copied.
-     * @throws ServiceException if an error occurs.
-     * @throws SiteException if an error occurs.
-     * @throws DocumentBuildException if an error occurs.
-     * @throws DocumentException 
-     */
-    protected DocumentSet getTargetDocsToCopy() throws ServiceException, SiteException,
-            DocumentBuildException, DocumentException {
-        Document doc = getSourceDocument();
-        DocumentFactory map = getDocumentFactory();
-        DocumentSet docsToCopy = new DocumentSet();
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
+        DocumentManager docManager = null;
         try {
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(doc.getPublication().getSiteManagerHint());
+            docManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
 
-            SiteNode node = doc.getLink().getNode();
-            SiteNode[] requiredNodes = siteManager.getRequiredResources(map, node);
-            for (int i = 0; i < requiredNodes.length; i++) {
-                Document targetDoc = map.get(getSourceDocument().getPublication(),
-                        getTargetArea(),
-                        requiredNodes[i].getPath(),
-                        doc.getLanguage());
-                if (!siteManager.containsInAnyLanguage(targetDoc)) {
-                    docsToCopy.add(targetDoc);
-                }
+            for (int i = 0; i < sources.length; i++) {
+                WorkflowUtil.invoke(this.manager,
+                        getSession(),
+                        getLogger(),
+                        sources[i],
+                        getEvent(),
+                        true);
+                docManager.copyToArea(sources[i], getTargetArea());
+                sources[i].getLink().delete();
+                docManager.delete(sources[i]);
             }
+
         } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
+            if (docManager != null) {
+                this.manager.release(docManager);
             }
         }
-        return docsToCopy;
-    }
-
-    /**
-     * @param sources The sources to be moved.
-     * @return All placeholder source documents that can be deleted..
-     * @throws ServiceException if an error occurs.
-     * @throws SiteException if an error occurs.
-     * @throws DocumentBuildException if an error occurs.
-     * @throws DocumentException
-     */
-    protected DocumentSet getSourceDocsToDelete(DocumentSet sources) throws ServiceException,
-            SiteException, DocumentBuildException, DocumentException {
-        DocumentSet docsToDelete = new DocumentSet();
-        Document doc = getSourceDocument();
-        DocumentFactory map = getDocumentFactory();
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
-        try {
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(doc.getPublication().getSiteManagerHint());
 
-            NodeSet nodesToDelete = new NodeSet();
+        setTargetDocument(doc.getAreaVersion(targetArea));
 
-            SiteNode sourceNode = doc.getLink().getNode();
-            SiteNode[] requiredSourceNodes = siteManager.getRequiredResources(map, sourceNode);
-            for (int i = 0; i < requiredSourceNodes.length; i++) {
-                SiteNode node = requiredSourceNodes[i];
-                boolean delete = true;
-
-                Document requiredDoc = map.get(node.getStructure().getPublication(),
-                        node.getStructure().getArea(),
-                        node.getPath());
-                String[] languages = requiredDoc.getLanguages();
-                for (int l = 0; l < languages.length; l++) {
-                    Document langVersion = requiredDoc.getTranslation(languages[l]);
-                    if (!sources.contains(langVersion) && !langVersion.isPlaceholder()) {
-                        delete = false;
-                    }
-                }
-
-                SiteNode[] requiringNodes = siteManager.getRequiringResources(map, node);
-
-                for (int j = 0; j < requiringNodes.length; j++) {
-                    SiteNode n = requiringNodes[j];
-                    Document reqDoc = map.get(n.getStructure().getPublication(), n.getStructure()
-                            .getArea(), n.getPath());
-                    languages = reqDoc.getLanguages();
-                    for (int l = 0; l < languages.length; l++) {
-                        Document langVersion = reqDoc.getTranslation(languages[l]);
-                        if (!sources.contains(langVersion) && !langVersion.isPlaceholder()) {
-                            delete = false;
-                        }
-                    }
-                }
-                if (delete) {
-                    nodesToDelete.add(node);
-                }
-            }
-
-            SiteNode[] nodes = nodesToDelete.getNodes();
-            for (int i = 0; i < nodes.length; i++) {
-                SiteNode n = nodes[i];
-                Document d = map.get(n.getStructure().getPublication(),
-                        n.getStructure().getArea(),
-                        n.getPath());
-                String[] languages = d.getLanguages();
-                for (int l = 0; l < languages.length; l++) {
-                    Document langVersion = d.getTranslation(languages[l]);
-                    docsToDelete.add(langVersion);
-                }
-            }
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
-            }
-        }
-        return docsToDelete;
     }
 
 }

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=431374&r1=431373&r2=431374&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 14 08:57:47 2006
@@ -278,7 +278,9 @@
         NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "", this.document);
         Element child = helper.createElement(SiteTreeNodeImpl.NODE_NAME);
         child.setAttribute(SiteTreeNodeImpl.ID_ATTRIBUTE_NAME, id);
-        child.setAttribute(SiteTreeNodeImpl.UUID_ATTRIBUTE_NAME, uuid);
+        if (uuid != null) {
+            child.setAttribute(SiteTreeNodeImpl.UUID_ATTRIBUTE_NAME, uuid);
+        }
 
         if (visibleInNav) {
             child.setAttribute(SiteTreeNodeImpl.VISIBLEINNAV_ATTRIBUTE_NAME, "true");
@@ -675,6 +677,11 @@
         SiteTreeLink label = new SiteTreeLink(doc.getFactory(), node, "", doc.getLanguage());
         node.addLabel(label);
         return label;
+    }
+
+    public SiteNode add(String path) throws SiteException {
+        SiteTreeNode node = addNode(path, null, true, null, "", false);
+        return node;
     }
 
     public boolean containsInAnyLanguage(String uuid) {

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java?rev=431374&r1=431373&r2=431374&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java Mon Aug 14 08:57:47 2006
@@ -114,14 +114,17 @@
         return getAncestors(dependingResource).contains(requiredResource);
     }
 
-    /**
-     * @see org.apache.lenya.cms.site.SiteManager#getRequiredResources(org.apache.lenya.cms.publication.DocumentFactory,
-     *      org.apache.lenya.cms.site.SiteNode)
-     */
-    public SiteNode[] getRequiredResources(DocumentFactory map, SiteNode resource)
+    public DocumentLocator[] getRequiredResources(DocumentFactory map, final DocumentLocator loc)
             throws SiteException {
-        List ancestors = getAncestors(resource);
-        return (SiteNode[]) ancestors.toArray(new SiteNode[ancestors.size()]);
+        
+        List ancestors = new ArrayList();
+        DocumentLocator locator = loc;
+        while (locator.getParent() != null) {
+            DocumentLocator parent = locator.getParent();
+            ancestors.add(parent);
+            locator = parent;
+        }
+        return (DocumentLocator[]) ancestors.toArray(new DocumentLocator[ancestors.size()]);
     }
 
     /**
@@ -254,43 +257,6 @@
     }
 
     /**
-     * @see org.apache.lenya.cms.site.SiteManager#delete(org.apache.lenya.cms.publication.Document)
-     */
-    public void delete(Document document) throws SiteException {
-        SiteTree tree = getTree(document.getFactory(),
-                document.getPublication(),
-                document.getArea());
-
-        try {
-            Link link = document.getLink();
-            SiteTreeNode node = (SiteTreeNode) link.getNode();
-
-            if (node.getLanguages().length == 1 && node.getChildren().length > 0) {
-                throw new SiteException("Cannot delete last language version of document ["
-                        + document + "] because this node has children.");
-            }
-
-            node.removeLabel(document.getLanguage());
-
-            if (node.getLanguages().length == 0) {
-                tree.removeNode(document.getPath());
-            } else {
-                tree.save();
-            }
-        } catch (DocumentException e) {
-            throw new SiteException(e);
-        }
-    }
-
-    /**
-     * @see org.apache.lenya.cms.site.SiteManager#getLabel(org.apache.lenya.cms.publication.Document)
-     */
-    public String getLabel(Document document) throws SiteException {
-        Label label = getLabelObject(document);
-        return label.getLabel();
-    }
-
-    /**
      * @see org.apache.lenya.cms.site.SiteManager#setLabel(org.apache.lenya.cms.publication.Document,
      *      java.lang.String)
      */
@@ -504,13 +470,13 @@
         }
     }
 
-    protected String getPath(DocumentFactory factory, Publication pub, String area, String uuid, String language)
-            throws SiteException {
+    protected String getPath(DocumentFactory factory, Publication pub, String area, String uuid,
+            String language) throws SiteException {
         SiteTree tree = getTree(factory, pub, area);
         SiteNode node = tree.getByUuid(uuid, language).getNode();
         if (node == null) {
-            throw new SiteException("No node found for [" + pub.getId() + ":" + area + ":" + uuid + ":" + language
-                    + "]");
+            throw new SiteException("No node found for [" + pub.getId() + ":" + area + ":" + uuid
+                    + ":" + language + "]");
         }
         return node.getPath();
     }
@@ -526,7 +492,8 @@
         return node.getUuid();
     }
 
-    protected boolean contains(DocumentFactory factory, DocumentLocator locator) throws SiteException {
+    protected boolean contains(DocumentFactory factory, DocumentLocator locator)
+            throws SiteException {
         Publication pub;
         try {
             pub = factory.getPublication(locator.getPublicationId());

Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java?rev=431374&r1=431373&r2=431374&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java Mon Aug 14 08:57:47 2006
@@ -134,6 +134,8 @@
 
             Publication publication = document.getPublication();
             DocumentFactory map = document.getFactory();
+            SiteStructure authoringSite = document.area().getSite();
+            SiteStructure liveSite = publication.getArea(Publication.LIVE_AREA).getSite();
 
             List missingDocuments = new ArrayList();
 
@@ -143,31 +145,25 @@
                 selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
                 siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
 
-                String path = document.getPath();
-                SiteStructure structure = siteManager.getSiteStructure(getDocumentFactory(),
-                        publication,
-                        Publication.LIVE_AREA);
-                SiteNode liveNode = structure.getNode(path);
-                SiteNode[] requiredNodes = siteManager.getRequiredResources(map, liveNode);
-
-                for (int i = 0; i < requiredNodes.length; i++) {
-
-                    DocumentSet liveDocs = SiteUtil.getExistingDocuments(this.manager,
-                            map,
-                            requiredNodes[i]);
-                    if (liveDocs.isEmpty()) {
-                        Document authoringDoc = map.get(requiredNodes[i].getStructure()
-                                .getPublication(),
-                                Publication.AUTHORING_AREA,
-                                requiredNodes[i].getPath());
-                        if (authoringDoc.exists()) {
-                            missingDocuments.add(authoringDoc);
-                        } else {
-                            missingDocuments.add(authoringDoc.getTranslation(authoringDoc.getPublication()
-                                    .getDefaultLanguage()));
+                if (!liveSite.contains(document.getPath())) {
+                    DocumentLocator liveLoc = document.getLocator()
+                            .getAreaVersion(Publication.LIVE_AREA);
+                    DocumentLocator[] requiredNodes = siteManager.getRequiredResources(map, liveLoc);
+                    for (int i = 0; i < requiredNodes.length; i++) {
+
+                        String path = requiredNodes[i].getPath();
+                        if (!liveSite.contains(path)) {
+                            SiteNode authoringNode = authoringSite.getNode(path);
+                            String language;
+                            if (authoringNode.hasLink(document.getLanguage())) {
+                                language = document.getLanguage();
+                            } else {
+                                language = authoringNode.getLanguages()[0];
+                            }
+                            missingDocuments.add(authoringNode.getLink(language).getDocument());
                         }
-                    }
 
+                    }
                 }
             } catch (Exception e) {
                 throw new RuntimeException(e);

Modified: lenya/trunk/src/webapp/lenya/config/cocoon-xconf/metadata/document.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/config/cocoon-xconf/metadata/document.xconf?rev=431374&r1=431373&r2=431374&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/config/cocoon-xconf/metadata/document.xconf (original)
+++ lenya/trunk/src/webapp/lenya/config/cocoon-xconf/metadata/document.xconf Mon Aug 14 08:57:47 2006
@@ -29,7 +29,6 @@
       <element name="mimeType" multiple="false"/>
       <element name="expires" multiple="false"/>
       <element name="extension" multiple="false"/>
-      <element name="placeholder" multiple="false"/>
     </component-instance>
   </xconf>
   



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