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 2010/11/26 17:37:57 UTC

svn commit: r1039451 - in /lenya/contributions/2_0_X/modules/atom: java/src/org/apache/lenya/modules/atom/ jx/

Author: andreas
Date: Fri Nov 26 16:37:57 2010
New Revision: 1039451

URL: http://svn.apache.org/viewvc?rev=1039451&view=rev
Log:
Firedocs: Show only assets in assets link tree.

Modified:
    lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/AssetsView.java
    lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/AtomUtil.java
    lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/ChildrenView.java
    lenya/contributions/2_0_X/modules/atom/jx/assets.jx
    lenya/contributions/2_0_X/modules/atom/jx/entry.jx
    lenya/contributions/2_0_X/modules/atom/jx/workspace.jx

Modified: lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/AssetsView.java
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/AssetsView.java?rev=1039451&r1=1039450&r2=1039451&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/AssetsView.java (original)
+++ lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/AssetsView.java Fri Nov 26 16:37:57 2010
@@ -21,8 +21,8 @@ import org.apache.avalon.framework.servi
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.lenya.cms.publication.Area;
 import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.site.SiteNode;
 import org.apache.lenya.modules.atom.AtomUtil.DocumentFilter;
 
 public class AssetsView extends ChildrenView {
@@ -34,19 +34,32 @@ public class AssetsView extends Children
     public AssetsView(ServiceManager manager, Area area) {
         super(manager, area);
     }
-
+    
     protected DocumentFilter getFilter() {
         return new DocumentFilter() {
             public boolean matches(Document doc) {
-                try {
-                    return doc.getResourceType().getName().equals(Assets.ASSET_RESOURCE_TYPE);
-                } catch (DocumentException e) {
-                    throw new RuntimeException(e);
-                }
+                return containsAsset(doc);
             }
         };
     }
 
+    protected boolean containsAsset(final Document doc) {
+        try {
+            if (doc.getResourceType().getName().equals(Assets.ASSET_RESOURCE_TYPE)) {
+                return true;
+            }
+            final String lang = doc.getLanguage();
+            for (final SiteNode child : doc.getLink().getNode().getChildren()) {
+                if (child.hasLink(lang) && containsAsset(child.getLink(lang).getDocument())) {
+                    return true;
+                }
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return false;
+    }
+
     public String[] getAssetMimeTypes() throws Exception {
         ServiceSelector selector = null;
         ResourceType resourceType = null;
@@ -63,7 +76,7 @@ public class AssetsView extends Children
             }
         }
     }
-    
+
     public String getUri() {
         return "assets.xml";
     }

Modified: lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/AtomUtil.java
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/AtomUtil.java?rev=1039451&r1=1039450&r2=1039451&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/AtomUtil.java (original)
+++ lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/AtomUtil.java Fri Nov 26 16:37:57 2010
@@ -33,9 +33,9 @@ public class AtomUtil {
      * @return A list of {@link Document}s.
      * @throws SiteException if an error occurs.
      */
-    protected static List getChildList(SiteNode[] nodes, DocumentFilter filter, boolean recursive)
+    protected static List<Document> getChildList(SiteNode[] nodes, DocumentFilter filter, boolean recursive)
             throws SiteException {
-        List children = new ArrayList();
+        List<Document> children = new ArrayList<Document>();
         for (int i = 0; i < nodes.length; i++) {
             String[] languages = nodes[i].getLanguages();
             for (int l = 0; l < languages.length; l++) {

Modified: lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/ChildrenView.java
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/ChildrenView.java?rev=1039451&r1=1039450&r2=1039451&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/ChildrenView.java (original)
+++ lenya/contributions/2_0_X/modules/atom/java/src/org/apache/lenya/modules/atom/ChildrenView.java Fri Nov 26 16:37:57 2010
@@ -33,7 +33,7 @@ public class ChildrenView implements Res
     protected ServiceManager manager;
     private Document document;
     private Area area;
-    
+
     public ChildrenView(ServiceManager manager, Document doc) {
         this(manager);
         Assert.notNull("document", doc);
@@ -46,21 +46,23 @@ public class ChildrenView implements Res
         this.area = area;
     }
 
+    protected Document getDocument() {
+        return this.document;
+    }
+
+    protected Area getArea() {
+        return this.area;
+    }
+
     private ChildrenView(ServiceManager manager) {
         Assert.notNull("manager", manager);
         this.manager = manager;
     }
-    
+
     public Document[] getDocuments() throws Exception {
-        List children;
-        if (this.document == null) {
-            SiteNode[] nodes = this.area.getSite().getTopLevelNodes();
-            children = AtomUtil.getChildList(nodes, getFilter(), false);
-        } else {
-            SiteNode node = this.document.getLink().getNode();
-            SiteNode[] nodes = node.getChildren();
-            children = AtomUtil.getChildList(nodes, getFilter(), false);
-        }
+        final SiteNode[] nodes = this.document == null ? this.area.getSite().getTopLevelNodes()
+                : this.document.getLink().getNode().getChildren();
+        final List<Document> children = AtomUtil.getChildList(nodes, getFilter(), false);
         return (Document[]) children.toArray(new Document[children.size()]);
     }
 

Modified: lenya/contributions/2_0_X/modules/atom/jx/assets.jx
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/atom/jx/assets.jx?rev=1039451&r1=1039450&r2=1039451&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/atom/jx/assets.jx (original)
+++ lenya/contributions/2_0_X/modules/atom/jx/assets.jx Fri Nov 26 16:37:57 2010
@@ -21,7 +21,7 @@
     <accept>${mimeType}</accept>
   </jx:forEach>
   <jx:forEach var="doc" items="${view.getDocuments()}">
-    <member href="${doc.getCanonicalWebappURL()}?lenya.usecase=atom.entry"
+    <member href="${doc.getCanonicalWebappURL()}?lenya.usecase=atom.entry&amp;workspace=assets"
       title="${doc.getMetaData('http://purl.org/dc/elements/1.1/').getFirstValue('title')}"/>
   </jx:forEach>
 </collection>

Modified: lenya/contributions/2_0_X/modules/atom/jx/entry.jx
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/atom/jx/entry.jx?rev=1039451&r1=1039450&r2=1039451&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/atom/jx/entry.jx (original)
+++ lenya/contributions/2_0_X/modules/atom/jx/entry.jx Fri Nov 26 16:37:57 2010
@@ -46,7 +46,15 @@
   <link rel="edit" type="application/atom+xml" href="${docUrl}?lenya.usecase=atom.entry"/>
   <link rel="lock" type="application/atomcoll+xml" href="${docUrl}?lenya.usecase=atom.locks"/>
   <link rel="assets" type="application/atomcoll+xml" href="${docUrl}?lenya.usecase=atom.assets"/>
-  <link rel="children" type="application/atomcoll+xml" href="${docUrl}?lenya.usecase=atom.children"/>
+  <jx:set var="workspace" value="${cocoon.request.getParameter('workspace')}"/>
+  <jx:choose>
+    <jx:when test="${workspace != null &amp;&amp; workspace.equals('assets')}">
+      <link rel="children" type="application/atomcoll+xml" href="${docUrl}?lenya.usecase=atom.assets"/>
+    </jx:when>
+    <jx:otherwise>
+      <link rel="children" type="application/atomcoll+xml" href="${docUrl}?lenya.usecase=atom.children"/>
+    </jx:otherwise>
+  </jx:choose>
   <link rel="edit-media" type="${document.getMimeType()}" href="${docUrl}?lenya.usecase=atom.content"/>
   
   <jx:set var="formats" value="${Packages.java.util.Arrays.asList(document.getResourceType().getFormats())}"/>

Modified: lenya/contributions/2_0_X/modules/atom/jx/workspace.jx
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/atom/jx/workspace.jx?rev=1039451&r1=1039450&r2=1039451&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/atom/jx/workspace.jx (original)
+++ lenya/contributions/2_0_X/modules/atom/jx/workspace.jx Fri Nov 26 16:37:57 2010
@@ -35,7 +35,7 @@
   </workspace>
   <workspace>
     <atom:title>Assets</atom:title>
-    <collection href="${url}?lenya.usecase=atom.assets">
+    <collection href="${url}?lenya.usecase=atom.assets&amp;workspace=assets">
       <atom:title>Global Assets</atom:title>
       <accept>image/png</accept>
       <accept>image/jpeg</accept>



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