[Yanel-commits] rev 21219 -
public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources
michi at wyona.com
michi at wyona.com
Thu Dec 28 16:23:33 CET 2006
Author: michi
Date: 2006-12-28 16:23:32 +0100 (Thu, 28 Dec 2006)
New Revision: 21219
Modified:
public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java
Log:
aggregate events
Modified: public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java 2006-12-28 11:53:40 UTC (rev 21218)
+++ public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java 2006-12-28 15:23:32 UTC (rev 21219)
@@ -46,28 +46,37 @@
public View getView(String viewId) throws Exception {
org.wyona.yarep.core.Repository dataRepo = getRealm().getRepository();
org.wyona.yarep.core.Path[] children = dataRepo.getChildren(new org.wyona.yarep.core.Path(getPath().toString()));
+
+ StringBuffer calendar = new StringBuffer("<?xml version=\"1.0\"?>\n<calendar>");
for (int i = 0; i < children.length; i++) {
log.error("DEBUG: Child: " + children[i]);
if (dataRepo.isResource(children[i])) {
- java.io.InputStream in = dataRepo.getInputStream(children[i]);
- StringBuffer event = new StringBuffer();
+ java.io.InputStream in = dataRepo.getInputStream(children[i]);
+ StringBuffer event = new StringBuffer();
- byte[] buffer = new byte[8192];
- int bytesRead;
- while ((bytesRead = in.read(buffer)) != -1) {
- event.append(new String(buffer));
- }
+ byte[] buffer = new byte[8192];
+ int bytesRead;
+ while ((bytesRead = in.read(buffer)) != -1) {
+ event.append(new String(buffer));
+ }
- log.error("DEBUG: Event: " + event);
+ log.error("DEBUG: Event: " + event);
+ int endOfProcessingInstruction = event.indexOf("?>");
+ if (endOfProcessingInstruction > 0) {
+ calendar.append(event.toString().substring(endOfProcessingInstruction + 2));
+ } else {
+ log.error("No processing instruction: " + children[i]);
+ }
}
}
+ calendar.append("</calendar>");
//response.getOutputStream();
View view = new View();
//view.setResponse(false);
- view.setMimeType("text/plain");
- view.setInputStream(new java.io.StringBufferInputStream("Hello Calendar"));
+ view.setMimeType("application/xml");
+ view.setInputStream(new java.io.StringBufferInputStream(calendar.toString()));
return view;
}
More information about the Yanel-commits
mailing list