Skip to content

Commit

Permalink
Merge branch 'master' into max-file-size_38
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwechner committed Dec 22, 2013
2 parents 6f8928a + 5dc9784 commit dcd4ee2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/resources/calendar/resource.xml
Expand Up @@ -14,6 +14,7 @@ Calendar resource based on ICS format, whereas the calendar can also be generate
<property name="categories"/>
<property name="user-ids"/>

<!-- Path where events as individual XML documents are located -->
<property name="events-path"/>
<!--
<property name="yarep-repository-id"/>
Expand Down
Expand Up @@ -20,7 +20,8 @@

import org.wyona.yanel.impl.resources.calendar.CalendarEvent;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

import java.io.File;
import java.io.InputStream;
Expand All @@ -41,7 +42,7 @@
*/
public class CalendarResource extends Resource implements ViewableV2, ModifiableV2, CreatableV2 {

private static Logger log = Logger.getLogger(CalendarResource.class);
private static Logger log = LogManager.getLogger(CalendarResource.class);

/**
*
Expand Down Expand Up @@ -247,15 +248,21 @@ public void write(InputStream in) throws Exception {
String eventPath = getResourceConfigProperty("events-path") + "/" + event.getUID() + ".xml";
log.debug("Write event as XML '" + eventPath + "' ...");
Node eventNode = null;
boolean eventNodeExists = false;
if (!dataRepo.existsNode(eventPath)) {
eventNode = org.wyona.yarep.util.YarepUtil.addNodes(dataRepo, eventPath, org.wyona.yarep.core.NodeType.RESOURCE);
} else {
eventNode = getRealm().getRepository().getNode(eventPath);
eventNodeExists = true;
}

OutputStream out = eventNode.getOutputStream();
XMLHelper.writeDocument(event.toXML(), out);
out.close();
boolean overwrite = true; // TODO: Make configurable
if (!eventNodeExists || overwrite) {
eventNode.setMimeType("application/xml");
OutputStream out = eventNode.getOutputStream();
XMLHelper.writeDocument(event.toXML(), out);
out.close();
}

event = null;
} else {
Expand Down

0 comments on commit dcd4ee2

Please sign in to comment.