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

michi at wyona.com michi at wyona.com
Fri Jan 19 00:27:19 CET 2007


Author: michi
Date: 2007-01-19 00:27:18 +0100 (Fri, 19 Jan 2007)
New Revision: 21903

Modified:
   public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java
Log:
also save the ICS

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	2007-01-18 23:26:40 UTC (rev 21902)
+++ public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java	2007-01-18 23:27:18 UTC (rev 21903)
@@ -165,7 +165,8 @@
      * Parse ICS and write events as XML into repository
      */
     public void write(InputStream in) throws Exception {
-        java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(in));
+        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;
         CalendarEvent event = null;
         log.debug("Parse ICS and write events as XML into repository ...");
@@ -189,6 +190,20 @@
     }
 
     /**
+     * Save/Write the actual ICS
+     */
+    private InputStream writeICS(InputStream in) throws Exception {
+        org.wyona.yarep.core.Path path = new org.wyona.yarep.core.Path(getPath().toString());
+        OutputStream out = getRealm().getRepository().getOutputStream(path);
+        byte[] buf = new byte[8192];
+        int bytesR;
+        while ((bytesR = in.read(buf)) != -1) {
+            out.write(buf, 0, bytesR);
+        }
+        return getRealm().getRepository().getInputStream(path);
+    }
+
+    /**
      *
      */
     public OutputStream getOutputStream() throws Exception {




More information about the Yanel-commits mailing list