[Yanel-commits] rev 47967 -
public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/calendar
michi at wyona.com
michi at wyona.com
Sun Mar 7 17:37:18 CET 2010
Author: michi
Date: 2010-03-07 17:37:18 +0100 (Sun, 07 Mar 2010)
New Revision: 47967
Modified:
public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/calendar/CalendarResource.java
Log:
create node if does not exist yet
Modified: public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/calendar/CalendarResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/calendar/CalendarResource.java 2010-03-07 16:27:54 UTC (rev 47966)
+++ public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/calendar/CalendarResource.java 2010-03-07 16:37:18 UTC (rev 47967)
@@ -218,6 +218,7 @@
* Parse ICS and write events as XML into repository
*/
public void write(InputStream in) throws Exception {
+ Repository dataRepo = getRealm().getRepository();
java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(writeICS(in)));
//java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(in));
String line;
@@ -227,8 +228,12 @@
if (line.startsWith("BEGIN:VEVENT")) {
event = new CalendarEvent();
} else if (line.startsWith("END:VEVENT")) {
- //log.error("DEBUG: Write event " + event.getUID() + ", " + event.toXML());
- Writer out = getRealm().getRepository().getWriter(new org.wyona.yarep.core.Path(getResourceConfigProperty("events-path") + "/" + event.getUID() + ".xml"));
+ String eventPath = getResourceConfigProperty("events-path") + "/" + event.getUID() + ".xml";
+ log.warn("DEBUG: Write event " + eventPath + ", " + event.toXML());
+ if (!dataRepo.existsNode(eventPath)) {
+ org.wyona.yarep.util.YarepUtil.addNodes(dataRepo, eventPath, org.wyona.yarep.core.NodeType.RESOURCE);
+ }
+ Writer out = dataRepo.getWriter(new org.wyona.yarep.core.Path(getResourceConfigProperty("events-path") + "/" + event.getUID() + ".xml"));
out.write(event.toXML());
out.close();
event = null;
More information about the Yanel-commits
mailing list