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 2007/05/02 11:06:06 UTC

svn commit: r534361 - in /lenya/trunk/src/modules-core/workflow: java/src/org/apache/lenya/cms/workflow/usecases/Publish.java resources/i18n/cmsui.xml resources/i18n/cmsui_de.xml

Author: andreas
Date: Wed May  2 02:06:06 2007
New Revision: 534361

URL: http://svn.apache.org/viewvc?view=rev&rev=534361
Log:
Publish usecase: add info message for broken links. This fixes bug 42303.

Modified:
    lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java
    lenya/trunk/src/modules-core/workflow/resources/i18n/cmsui.xml
    lenya/trunk/src/modules-core/workflow/resources/i18n/cmsui_de.xml

Modified: lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java?view=diff&rev=534361&r1=534360&r2=534361
==============================================================================
--- lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java (original)
+++ lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java Wed May  2 02:06:06 2007
@@ -96,6 +96,33 @@
         setParameter(SEND_NOTIFICATION, Boolean.TRUE);
         
         setParameter(UNPUBLISHED_LINKS, new LinkList(this.manager, getSourceDocument()));
+        
+    }
+    
+    protected boolean hasBrokenLinks() {
+        LinkManager linkMgr = null;
+        LinkResolver resolver = null;
+        try {
+            linkMgr = (LinkManager) this.manager.lookup(LinkManager.ROLE);
+            resolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE);
+            org.apache.lenya.cms.linking.Link[] links = linkMgr.getLinksFrom(getSourceDocument());
+            for (int i = 0; i < links.length; i++) {
+                LinkTarget target = resolver.resolve(getSourceDocument(), links[i].getUri());
+                if (!target.exists()) {
+                    return true;
+                }
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (linkMgr != null) {
+                this.manager.release(linkMgr);
+            }
+            if (resolver != null) {
+                this.manager.release(resolver);
+            }
+        }
+        return false;
     }
     
     /**
@@ -188,6 +215,10 @@
                             DublinCoreHelper.getTitle(doc) };
                     addErrorMessage("missing-document", params);
                 }
+            }
+            
+            if (hasBrokenLinks()) {
+                addInfoMessage("publish-broken-links");
             }
         }
     }

Modified: lenya/trunk/src/modules-core/workflow/resources/i18n/cmsui.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/workflow/resources/i18n/cmsui.xml?view=diff&rev=534361&r1=534360&r2=534361
==============================================================================
--- lenya/trunk/src/modules-core/workflow/resources/i18n/cmsui.xml (original)
+++ lenya/trunk/src/modules-core/workflow/resources/i18n/cmsui.xml Wed May  2 02:06:06 2007
@@ -42,6 +42,7 @@
   
   <message key="unpublished-links">Links to unpublished documents:</message>
   <message key="links-to-document">Links from other documents:</message>
+  <message key="publish-broken-links">The document contains broken links.</message>
   
   <message key="notify-reviewers">Notify reviewers</message>
   

Modified: lenya/trunk/src/modules-core/workflow/resources/i18n/cmsui_de.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/workflow/resources/i18n/cmsui_de.xml?view=diff&rev=534361&r1=534360&r2=534361
==============================================================================
--- lenya/trunk/src/modules-core/workflow/resources/i18n/cmsui_de.xml (original)
+++ lenya/trunk/src/modules-core/workflow/resources/i18n/cmsui_de.xml Wed May  2 02:06:06 2007
@@ -42,6 +42,7 @@
   
   <message key="unpublished-links">Links zu nicht publizierten Dokumenten:</message>
   <message key="links-to-document">Links von anderen Dokumenten:</message>
+  <message key="publish-broken-links">Das Dokument enthält Links zu nicht existierenden Dokumenten.</message>
   
   <message key="notify-reviewers">Prüfer benachrichtigen</message>
   



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