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/09/14 17:26:00 UTC

svn commit: r443382 - /lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java

Author: andreas
Date: Thu Sep 14 08:25:59 2006
New Revision: 443382

URL: http://svn.apache.org/viewvc?view=rev&rev=443382
Log:
Publish: don't expect all site nodes to have links

Modified:
    lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java

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?view=diff&rev=443382&r1=443381&r2=443382
==============================================================================
--- 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 Thu Sep 14 08:25:59 2006
@@ -37,8 +37,10 @@
 import org.apache.lenya.cms.publication.Proxy;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.site.Link;
 import org.apache.lenya.cms.site.NodeIterator;
 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.site.SiteStructure;
@@ -154,14 +156,10 @@
 
                         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];
+                            Link link = getExistingLink(path, document);
+                            if (link != null) {
+                                missingDocuments.add(link.getDocument());
                             }
-                            missingDocuments.add(authoringNode.getLink(language).getDocument());
                         }
 
                     }
@@ -182,6 +180,25 @@
                 setParameter(MISSING_DOCUMENTS, missingDocuments);
             }
         }
+    }
+    
+    /**
+     * Returns a link of a certain node, preferrably in the document's language, or <code>null</code> if
+     * the node has no links.
+     * @param path The path of the node.
+     * @param document The document.
+     * @return A link or <code>null</code>.
+     * @throws SiteException if an error occurs.
+     */
+    protected Link getExistingLink(String path, Document document) throws SiteException {
+        SiteNode node = document.area().getSite().getNode(path);
+        Link link = null;
+        if (node.hasLink(document.getLanguage())) {
+            link = node.getLink(document.getLanguage());
+        } else if (node.getLanguages().length > 0){
+            link = node.getLink(node.getLanguages()[0]);
+        }
+        return link;
     }
 
     /**



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