[Yanel-commits] rev 33550 -
public/yanel/trunk/src/contributions/resources/yanel-user/src/java/org/wyona/yanel/impl/resources
michi at wyona.com
michi at wyona.com
Mon Mar 17 23:04:25 CET 2008
Author: michi
Date: 2008-03-17 23:04:25 +0100 (Mon, 17 Mar 2008)
New Revision: 33550
Modified:
public/yanel/trunk/src/contributions/resources/yanel-user/src/java/org/wyona/yanel/impl/resources/YanelUserResource.java
Log:
XML viewId added
Modified: public/yanel/trunk/src/contributions/resources/yanel-user/src/java/org/wyona/yanel/impl/resources/YanelUserResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/yanel-user/src/java/org/wyona/yanel/impl/resources/YanelUserResource.java 2008-03-17 22:04:02 UTC (rev 33549)
+++ public/yanel/trunk/src/contributions/resources/yanel-user/src/java/org/wyona/yanel/impl/resources/YanelUserResource.java 2008-03-17 22:04:25 UTC (rev 33550)
@@ -100,13 +100,21 @@
* @see org.wyona.yanel.core.api.attributes.ViewableV2#getViewDescriptors()
*/
public ViewDescriptor[] getViewDescriptors() {
- return null;
+ 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;
}
/**
* @see org.wyona.yanel.core.api.attributes.ViewableV2#getMimeType(java.lang.String)
*/
public String getMimeType(String viewId) {
+ if (viewId != null) {
+ if (viewId.equals("xml")) return "application/xml";
+ }
return MIME_TYPE;
}
@@ -121,13 +129,11 @@
public View getView(String viewId) throws Exception {
View defaultView = new View();
- File xslFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile()
- .getAbsolutePath(), "xslt" + File.separator + "yanel-user-profile.xsl");
- File xmlFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile()
- .getAbsolutePath(), "xml" + File.separator + "yanel-user-profile.xml");
+ File xmlFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xml" + File.separator + "yanel-user-profile.xml");
try {
+ File xslFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xslt" + File.separator + "yanel-user-profile.xsl");
Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(xslFile));
String action = determineAction(request);
@@ -194,11 +200,14 @@
}
transformer.setParameter("allGroupsString", allGroupsString);
}
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- transformer.transform(new javax.xml.transform.stream.StreamSource(xmlFile), new StreamResult(baos));
-
- defaultView.setMimeType(MIME_TYPE);
- defaultView.setInputStream(new java.io.ByteArrayInputStream(baos.toByteArray()));
+ defaultView.setMimeType(getMimeType(viewId));
+ if (viewId != null && viewId.equals("xml")) {
+ defaultView.setInputStream(new java.io.FileInputStream(xmlFile));
+ } else {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ transformer.transform(new javax.xml.transform.stream.StreamSource(xmlFile), new StreamResult(baos));
+ defaultView.setInputStream(new java.io.ByteArrayInputStream(baos.toByteArray()));
+ }
} catch (Exception e) {
// TODO: Improve exception handling
log.error(e.getMessage(), e);
More information about the Yanel-commits
mailing list