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

michi at wyona.com michi at wyona.com
Sat Apr 5 12:48:59 CEST 2008


Author: michi
Date: 2008-04-05 12:48:58 +0200 (Sat, 05 Apr 2008)
New Revision: 34862

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

Modified: public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/navigation/DataRepoSitetreeResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/navigation/DataRepoSitetreeResource.java	2008-04-05 10:37:34 UTC (rev 34861)
+++ public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/navigation/DataRepoSitetreeResource.java	2008-04-05 10:48:58 UTC (rev 34862)
@@ -10,13 +10,14 @@
 import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
 import org.wyona.yanel.core.navigation.Node;
 import org.wyona.yanel.core.navigation.Sitetree;
+import org.wyona.yanel.impl.resources.BasicXMLResource;
 
 import org.apache.log4j.Logger;
 
 /**
  *
  */
-public class DataRepoSitetreeResource extends Resource implements ViewableV2 {
+public class DataRepoSitetreeResource extends BasicXMLResource {
 
     private static Logger log = Logger.getLogger(DataRepoSitetreeResource.class);
 
@@ -29,14 +30,6 @@
     /**
      *
      */
-    public String getMimeType(String viewId) throws Exception {
-        if (viewId != null && viewId.equals("xml")) return "application/xml";
-        return "application/xhtml+xml";
-    }
-
-    /**
-     *
-     */
     public long getSize() throws Exception {
         return -1;
     }
@@ -51,40 +44,15 @@
     /**
      *
      */
-    public View getView(String viewId) throws Exception {
-
+    public java.io.InputStream getContentXML(String viewId) throws Exception {
         StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?>");
-        if (viewId != null && viewId.equals("xml")) {
-            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><br/><br/>This content is being generated by the resource <![CDATA[" + getResourceTypeUniversalName() + "]]></body></html>");
-        }
+        sb.append(getSitetreeAsXML());
+        //sb.append(getSitetreeAsXML(getPath().toString()));
 
-        View view = new View();
-        view.setMimeType(getMimeType(viewId));
-        view.setInputStream(new java.io.StringBufferInputStream(sb.toString()));
-        return view;
+        return new java.io.StringBufferInputStream(sb.toString());
     }
 
     /**
-     *
-     */
-    public ViewDescriptor[] getViewDescriptors() {
-        try {
-            ViewDescriptor[] vd = new ViewDescriptor[2];
-            vd[0] = new ViewDescriptor("default");
-            vd[0].setMimeType(getMimeType(null));
-            vd[1] = new ViewDescriptor("xml");
-            vd[1].setMimeType(getMimeType("xml"));
-            return vd;
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    /**
      * Get sitetree as XML
      */
     private String getSitetreeAsXML() {



More information about the Yanel-commits mailing list