[Yanel-commits] rev 25035 -
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:07:57 CEST 2007
Author: michi
Date: 2007-06-11 23:07:56 +0200 (Mon, 11 Jun 2007)
New Revision: 25035
Modified:
public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/DataRepoSitetreeResource.java
Log:
viewid implemented
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:07:19 UTC (rev 25034)
+++ public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/DataRepoSitetreeResource.java 2007-06-11 21:07:56 UTC (rev 25035)
@@ -9,11 +9,15 @@
import org.wyona.yanel.core.attributes.viewable.View;
import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
+import org.apache.log4j.Category;
+
/**
*
*/
public class DataRepoSitetreeResource extends Resource implements ViewableV2 {
+ private static Category log = Category.getInstance(DataRepoSitetreeResource.class);
+
/**
*
*/
@@ -24,6 +28,7 @@
*
*/
public String getMimeType(String viewId) throws Exception {
+ if (viewId != null && viewId.equals("xml")) return "application/xml";
return "application/xhtml+xml";
}
@@ -45,11 +50,16 @@
*
*/
public View getView(String viewId) throws Exception {
+
StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?>");
- sb.append("<sitetree/>");
+ if (viewId != null && viewId.equals("xml")) {
+ sb.append("<sitetree/>");
+ } 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>");
+ }
View view = new View();
- view.setMimeType("application/xml");
+ view.setMimeType(getMimeType(viewId));
view.setInputStream(new java.io.StringBufferInputStream(sb.toString()));
return view;
}
@@ -58,6 +68,16 @@
*
*/
public ViewDescriptor[] getViewDescriptors() {
- return null;
+ 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;
+ }
}
}
More information about the Yanel-commits
mailing list