[Yanel-commits] rev 38964 - public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/calendar

michi at wyona.com michi at wyona.com
Mon Sep 29 11:05:53 CEST 2008


Author: michi
Date: 2008-09-29 11:05:53 +0200 (Mon, 29 Sep 2008)
New Revision: 38964

Modified:
   public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/calendar/CalendarResource.java
Log:
do not open output stream if input stream is empty

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	2008-09-29 09:03:46 UTC (rev 38963)
+++ public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/calendar/CalendarResource.java	2008-09-29 09:05:53 UTC (rev 38964)
@@ -249,15 +249,15 @@
     private InputStream writeICS(InputStream in) throws Exception {
         log.error("DEBUG: Write ICS as a whole to the repository: " + getPath());
         org.wyona.yarep.core.Path path = new org.wyona.yarep.core.Path(getPath());
-        OutputStream out = getRealm().getRepository().getOutputStream(path);
+
+        OutputStream out;
         byte[] buf = new byte[8192];
         int bytesR;
-
         bytesR = in.read(buf);
         if (bytesR <= 0) {
-            // out.close();
-            throw new Exception("InputStream seems to be empty!");
+            throw new Exception("InputStream seems to be empty! Current calendar will not be overwritten!");
         } else {
+            out = getRealm().getRepository().getOutputStream(path);
             out.write(buf, 0, bytesR);
         }
 



More information about the Yanel-commits mailing list