[Yanel-commits] rev 25038 - public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources

michi at wyona.com michi at wyona.com
Mon Jun 11 23:38:32 CEST 2007


Author: michi
Date: 2007-06-11 23:38:31 +0200 (Mon, 11 Jun 2007)
New Revision: 25038

Modified:
   public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/DataRepoSitetreeResource.java
Log:
building sitetree started

Modified: public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/DataRepoSitetreeResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/DataRepoSitetreeResource.java	2007-06-11 21:37:19 UTC (rev 25037)
+++ public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/DataRepoSitetreeResource.java	2007-06-11 21:38:31 UTC (rev 25038)
@@ -8,6 +8,8 @@
 import org.wyona.yanel.core.api.attributes.ViewableV2;
 import org.wyona.yanel.core.attributes.viewable.View;
 import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
+import org.wyona.yanel.core.navigation.Node;
+import org.wyona.yanel.core.navigation.Sitetree;
 
 import org.apache.log4j.Category;
 
@@ -53,7 +55,8 @@
 
         StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?>");
         if (viewId != null && viewId.equals("xml")) {
-            sb.append("<sitetree/>");
+            sb.append(getSitetreeAsXML());
+            //sb.append(getSitetreeAsXML(getPath().toString()));
         } else {
             sb.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"><head><title>Browse Data Repository Sitetree</title></head><body><a href=\"?yanel.resource.viewid=xml\">Show XML</a></body></html>");
         }
@@ -80,4 +83,31 @@
             return null;
         }
     }
+
+    /**
+     *
+     */
+    private String getSitetreeAsXML() {
+    //private String getSitetreeAsXML(String path) {
+        String path = "/"; 
+        StringBuffer sb = new StringBuffer("<sitetree>");
+        Sitetree sitetree = (Sitetree) getYanel().getBeanFactory().getBean("repo-navigation");
+        Node node = sitetree.getNode(getRealm(), path);
+        if (node.isCollection()) {
+            sb.append("<collection path=\"" + path + "\">");
+            Node[] children = node.getChildren();
+            for (int i = 0; i < children.length; i++) {
+                if (children[i].isCollection()) {
+                    sb.append("<collection path=\"" + children[i].getPath() + "\"/>");
+                } else {
+                    sb.append("<resource path=\"" + children[i].getPath() + "\"/>");
+                }
+            }
+            sb.append("</collection>");
+        } else {
+            sb.append("<resource path=\"" + path + "\"/>");
+        }
+        sb.append("</sitetree>");
+        return sb.toString();
+    }
 }




More information about the Yanel-commits mailing list