[Bedework-commit] caldavimpl r67 - in trunk: . boeingexchange/src/edu/rpi/cct/bedework/caldav/exchange bwcaldav/src/org/bedework/caldav/bwserver domino/src/edu/rpi/cct/bedework/caldav/domino google/src/edu/rpi/cct/bedework/caldav/google

svnadmin at bedework.org svnadmin at bedework.org
Wed Sep 15 11:05:14 EDT 2010


Author: douglm
Date: 2010-09-15 11:05:13 -0400 (Wed, 15 Sep 2010)
New Revision: 67

Modified:
   trunk/boeingexchange/src/edu/rpi/cct/bedework/caldav/exchange/BexchangeSysIntfImpl.java
   trunk/build.xml
   trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwSysIntfImpl.java
   trunk/domino/src/edu/rpi/cct/bedework/caldav/domino/DominoSysIntfImpl.java
   trunk/google/src/edu/rpi/cct/bedework/caldav/google/GoogleSysIntfImpl.java
Log:
Pay some attention to the ACCEPT values or the data type in the calendar-data element. Allow for different default content-types for caldav and web service.

Implement generation of XML and produce that when appropriate

Modified: trunk/boeingexchange/src/edu/rpi/cct/bedework/caldav/exchange/BexchangeSysIntfImpl.java
===================================================================
--- trunk/boeingexchange/src/edu/rpi/cct/bedework/caldav/exchange/BexchangeSysIntfImpl.java	2010-09-09 14:24:09 UTC (rev 66)
+++ trunk/boeingexchange/src/edu/rpi/cct/bedework/caldav/exchange/BexchangeSysIntfImpl.java	2010-09-15 15:05:13 UTC (rev 67)
@@ -61,6 +61,7 @@
 import edu.rpi.cmt.access.Acl;
 import edu.rpi.cmt.access.Acl.CurrentAccess;
 import edu.rpi.cmt.timezones.Timezones;
+import edu.rpi.sss.util.xml.XmlEmit;
 
 import net.fortuna.ical4j.model.Calendar;
 import net.fortuna.ical4j.model.component.VFreeBusy;
@@ -225,6 +226,13 @@
   }
 
   /* (non-Javadoc)
+   * @see org.bedework.caldav.server.sysinterface.SysIntf#getDefaultContentType()
+   */
+  public String getDefaultContentType() throws WebdavException {
+    return "text/calendar";
+  }
+
+  /* (non-Javadoc)
    * @see org.bedework.caldav.server.SysIntf#getPrincipal()
    */
   public AccessPrincipal getPrincipal() throws WebdavException {
@@ -484,12 +492,9 @@
     throw new WebdavException("unimplemented");
   }
 
-  /* (non-Javadoc)
-   * @see org.bedework.caldav.server.sysinterface.SysIntf#getFreeBusy(org.bedework.caldav.server.CalDAVCollection, int, org.bedework.caldav.util.TimeRange)
-   */
-  public Calendar getFreeBusy(final CalDAVCollection col,
-                              final int depth,
-                              final TimeRange timeRange) throws WebdavException {
+  public CalDAVEvent getFreeBusy(final CalDAVCollection col,
+                                 final int depth,
+                                 final TimeRange timeRange) throws WebdavException {
     /* Create a url something like:
      *  http://t1.egenconsulting.com:80/servlet/Freetime/John?start-min=2006-07-11T12:00:00Z&start-max=2006-07-16T12:00:00Z
      */
@@ -746,12 +751,10 @@
     throw new WebdavException("unimplemented");
   }
 
-  /* (non-Javadoc)
-   * @see org.bedework.caldav.server.SysIntf#writeCalendar(java.util.Collection, int, java.io.Writer)
-   */
   public void writeCalendar(final Collection<CalDAVEvent> evs,
                             final int method,
-                            final Writer wtr) throws WebdavException {
+                            final XmlEmit xml,
+                            final String contentType) throws WebdavException {
     throw new WebdavException("unimplemented");
   }
 

Modified: trunk/build.xml
===================================================================
--- trunk/build.xml	2010-09-09 14:24:09 UTC (rev 66)
+++ trunk/build.xml	2010-09-15 15:05:13 UTC (rev 67)
@@ -36,8 +36,10 @@
     <mkdir dir="${lib.dir}" />
 
     <getJar name="commons-httpclient" version="3.0" />
+  	<!--
     <getJar name="gdata-calendar" version="1.0" />
     <getJar name="gdata-client" version="1.0" />
+    -->
     <getJar name="ical4j" version="head-20100601" />
     <getJar name="log4j" version="1.2.8" />
     <getJar name="servletapi" version="2.4" />
@@ -56,14 +58,16 @@
     <getJar name="rpiaccess" version="3.6" project="access" />
     <getJar name="rpiutil" version="3.6" project="rpiutil" />
 
+    <property name="org.bedework.caldav.bwcaldav.base"
+              location="${project.home}/bwcaldav" />
+  	<!--
     <property name="org.bedework.caldav.boeingexchange.base"
               location="${project.home}/boeingexchange" />
-    <property name="org.bedework.caldav.bwcaldav.base"
-              location="${project.home}/bwcaldav" />
     <property name="org.bedework.caldav.domino.base"
               location="${project.home}/domino" />
     <property name="org.bedework.caldav.google.base"
               location="${project.home}/google" />
+              -->
 
     <mkdir dir="${dist.home}" />
 
@@ -81,17 +85,19 @@
     <fileset id="buildjar.resource.files" refid="empty.fileset" />
     <fileset id="buildjar.generated.java.sources" refid="empty.fileset" />
 
+    <property name="bwcaldav.jar"
+              location="${dist.home}/${edu.rpi.cmt.caldav.bwcaldav.jar}-${project.version}.jar" />
+
+  	<!--
     <property name="boeingexchange.jar"
               location="${dist.home}/${edu.rpi.cmt.caldav.boeingexchange.jar}-${project.version}.jar" />
 
-    <property name="bwcaldav.jar"
-              location="${dist.home}/${edu.rpi.cmt.caldav.bwcaldav.jar}-${project.version}.jar" />
-
     <property name="domino.jar"
               location="${dist.home}/${edu.rpi.cmt.caldav.domino.jar}-${project.version}.jar" />
 
     <property name="google.jar"
               location="${dist.home}/${edu.rpi.cmt.caldav.google.jar}-${project.version}.jar" />
+              -->
 
     <!-- ==================== Compilation Classpath ==================== -->
 
@@ -151,10 +157,11 @@
      This target builds jar files ready for the deploy target.
      =================================================================== -->
 
-  <target name="build-source" depends="bld.bwcaldav,
+  <target name="build-source" depends="bld.bwcaldav" />
+  	<!--
                                        bld.boeingexchange,
                                        bld.domino,
-                                       bld.google" />
+                                       bld.google" /> -->
 
 <!-- ==================== Javadoc Target ===============================
      The "javadoc" target creates Javadoc API documentation for the Java
@@ -168,10 +175,13 @@
     <property name="destdir" location="${dist.home}/docs/api"/>
     <mkdir dir="${destdir}"/>
 
+  	<!--
     <javadoc sourcepath="${org.bedework.caldav.boeingexchange.base}/src:
                          ${org.bedework.caldav.bwcaldav.base}/src:
                          ${org.bedework.caldav.domino.base}/src:
                          ${org.bedework.caldav.google.base}/src:"
+  	-->
+    <javadoc sourcepath="${org.bedework.caldav.bwcaldav.base}/src"
            classpathref="compile.classpath"
                 destdir="${destdir}"
            packagenames="org.bedework.*,
@@ -195,18 +205,19 @@
   <!-- ===================== internal build targets ====================
        ================================================================= -->
 
+  <target name="bld.bwcaldav" >
+      <ant antfile="${org.bedework.caldav.bwcaldav.base}/build.xml"
+           inheritrefs="true"
+           target="build" />
+  </target>
+
+	<!--
   <target name="bld.boeingexchange" >
     <echo message="org.bedework.build.caldav.bexchange=${org.bedework.build.caldav.bexchange}" />
       <ant antfile="${org.bedework.caldav.boeingexchange.base}/build.xml" inheritrefs="true"
            target="build" />
   </target>
 
-  <target name="bld.bwcaldav" >
-      <ant antfile="${org.bedework.caldav.bwcaldav.base}/build.xml"
-           inheritrefs="true"
-           target="build" />
-  </target>
-
   <target name="bld.domino" >
       <ant antfile="${org.bedework.caldav.domino.base}/build.xml" inheritrefs="true"
            target="build" />
@@ -216,4 +227,5 @@
       <ant antfile="${org.bedework.caldav.google.base}/build.xml" inheritrefs="true"
            target="build" />
   </target>
+  -->
 </project>

Modified: trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwSysIntfImpl.java
===================================================================
--- trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwSysIntfImpl.java	2010-09-09 14:24:09 UTC (rev 66)
+++ trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwSysIntfImpl.java	2010-09-15 15:05:13 UTC (rev 67)
@@ -88,9 +88,11 @@
 import edu.rpi.cmt.access.Acl.CurrentAccess;
 import edu.rpi.cmt.calendar.IcalDefs;
 import edu.rpi.cmt.calendar.IcalDefs.IcalComponentType;
+import edu.rpi.sss.util.xml.XmlEmit;
 import edu.rpi.sss.util.xml.XmlUtil;
 import edu.rpi.sss.util.xml.tagdefs.CaldavTags;
 import edu.rpi.sss.util.xml.tagdefs.WebdavTags;
+import edu.rpi.sss.util.xml.tagdefs.XcalTags;
 
 import net.fortuna.ical4j.model.Calendar;
 import net.fortuna.ical4j.model.DateTime;
@@ -135,7 +137,7 @@
 
   private long reqInTime;
 
-  //private CalDAVConfig conf;
+  private CalDAVConfig conf;
 
   /* (non-Javadoc)
    * @see org.bedework.caldav.server.sysinterface.SysIntf#init(javax.servlet.http.HttpServletRequest, java.lang.String, org.bedework.caldav.util.CalDAVConfig, boolean)
@@ -145,14 +147,14 @@
                    final CalDAVConfig conf,
                    final boolean debug) throws WebdavException {
     try {
-      //this.conf = conf;
+      this.conf = conf;
       this.debug = debug;
 
       urlHandler = new UrlHandler(req, !conf.getCalWS());
 
       // Call to set up ThreadLocal variables
 
-      CalSvcI svc = getSvci(account);
+      CalSvcI svc = getSvci(account, conf);
       svci.postNotification(new HttpEvent(SysCode.CALDAV_IN));
       reqInTime = System.currentTimeMillis();
 
@@ -195,6 +197,17 @@
   }
 
   /* (non-Javadoc)
+   * @see org.bedework.caldav.server.sysinterface.SysIntf#getDefaultContentType()
+   */
+  public String getDefaultContentType() throws WebdavException {
+    if (conf.getCalWS()) {
+      return XcalTags.mimetype;
+    }
+
+    return "text/calendar";
+  }
+
+  /* (non-Javadoc)
    * @see org.bedework.caldav.server.SysIntf#getPrincipal()
    */
   public AccessPrincipal getPrincipal() throws WebdavException {
@@ -795,9 +808,9 @@
   /* (non-Javadoc)
    * @see org.bedework.caldav.server.sysinterface.SysIntf#getFreeBusy(org.bedework.caldav.server.CalDAVCollection, int, org.bedework.caldav.util.TimeRange)
    */
-  public Calendar getFreeBusy(final CalDAVCollection col,
-                              final int depth,
-                              final TimeRange timeRange) throws WebdavException {
+  public CalDAVEvent getFreeBusy(final CalDAVCollection col,
+                                 final int depth,
+                                 final TimeRange timeRange) throws WebdavException {
     try {
       BwCalendar bwCol = unwrap(col);
 
@@ -853,15 +866,9 @@
                                                   null);
       }
 
-      VFreeBusy vfreeBusy = VFreeUtil.toVFreeBusy(fb);
-      if (vfreeBusy != null) {
-        Calendar ical = IcalTranslator.newIcal(Icalendar.methodTypeNone);
-        ical.getComponents().add(vfreeBusy);
 
-        return ical;
-      }
-
-      return null;
+      EventInfo ei = new EventInfo(fb);
+      return new BwCalDAVEvent(this, ei);
     } catch (CalFacadeException cfe) {
       throw new WebdavException(cfe);
     } catch (WebdavException wde) {
@@ -1335,23 +1342,61 @@
     }
   }
 
-  /* (non-Javadoc)
-   * @see org.bedework.caldav.server.SysIntf#writeCalendar(java.util.Collection, int, java.io.Writer)
-   */
   public void writeCalendar(final Collection<CalDAVEvent> evs,
-                            final int method,
-                            final Writer wtr) throws WebdavException {
+                            final MethodEmitted method,
+                            final XmlEmit xml,
+                            final Writer wtr,
+                            final String contentType) throws WebdavException {
     try {
       Collection<EventInfo> bwevs = new ArrayList<EventInfo>();
 
+      int meth = Icalendar.methodTypeNone;
+
+      if (method == MethodEmitted.publish) {
+        meth = Icalendar.methodTypePublish;
+      }
       for (CalDAVEvent cde: evs) {
         BwCalDAVEvent bcde = (BwCalDAVEvent)cde;
 
+        if (method == MethodEmitted.eventMethod) {
+          meth = getEvent(bcde).getScheduleMethod();
+        }
+
         bwevs.add(bcde.getEvinfo());
       }
 
-      Calendar ical = trans.toIcal(bwevs, method);
-      IcalTranslator.writeCalendar(ical, wtr);
+      String ctype = contentType;
+      if ((ctype == null) ||
+          (!ctype.equals("text/calendar") &&
+           !ctype.equals(XcalTags.mimetype))) {
+        ctype = getDefaultContentType();
+      }
+
+      if (ctype.equals("text/calendar")) {
+        Calendar ical = trans.toIcal(bwevs, meth);
+        if (xml == null) {
+          IcalTranslator.writeCalendar(ical, wtr);
+        } else {
+          xml.cdataValue(toIcalString(ical));
+        }
+
+        return;
+      }
+
+      if (ctype.equals(XcalTags.mimetype)) {
+
+        XmlEmit x;
+        if (xml == null) {
+          x = new XmlEmit();
+          x.startEmit(wtr);
+        } else {
+          x = xml;
+        }
+        trans.writeXmlCalendar(bwevs, meth, x);
+        return;
+      }
+    } catch (WebdavException we) {
+      throw we;
     } catch (Throwable t) {
       throw new WebdavException(t);
     }
@@ -1567,24 +1612,19 @@
     return svci;
   }
 
-  private CalSvcI getSvci(final String account) throws WebdavException {
+  private CalSvcI getSvci(final String account,
+                          final CalDAVConfig conf) throws WebdavException {
     try {
       /* account is what we authenticated with.
        * user, if non-null, is the user calendar we want to access.
        */
       DbConfig dbconf = new DbConfig();
 
-      CalSvcIPars pars = new CalSvcIPars(account,
-                                         null,    // calsuite
-                                         false,   // publicAdmin
+      CalSvcIPars pars = CalSvcIPars.getCaldavPars(account,
                                          "root".equals(account) || // allow SuperUser
                                          "admin".equals(account),   // allow SuperUser
-                                         false,  // service
-                                         false,  // adminCanEditAllPublicCategories
-                                         false,  // adminCanEditAllPublicLocations
-                                         false,  // adminCanEditAllPublicSponsors
-                                         true,    // sessionless
-                                         dbconf);
+                                         dbconf,
+                                         conf.getTimezonesByReference());
       svci = new CalSvcFactoryDefault().getSvc(pars);
 
       svci.open();

Modified: trunk/domino/src/edu/rpi/cct/bedework/caldav/domino/DominoSysIntfImpl.java
===================================================================
--- trunk/domino/src/edu/rpi/cct/bedework/caldav/domino/DominoSysIntfImpl.java	2010-09-09 14:24:09 UTC (rev 66)
+++ trunk/domino/src/edu/rpi/cct/bedework/caldav/domino/DominoSysIntfImpl.java	2010-09-15 15:05:13 UTC (rev 67)
@@ -68,6 +68,7 @@
 import edu.rpi.cmt.access.Acl.CurrentAccess;
 import edu.rpi.cmt.calendar.IcalDefs;
 import edu.rpi.cmt.timezones.Timezones;
+import edu.rpi.sss.util.xml.XmlEmit;
 import edu.rpi.sss.util.xml.XmlUtil;
 
 import net.fortuna.ical4j.model.Calendar;
@@ -228,6 +229,13 @@
   }
 
   /* (non-Javadoc)
+   * @see org.bedework.caldav.server.sysinterface.SysIntf#getDefaultContentType()
+   */
+  public String getDefaultContentType() throws WebdavException {
+    return "text/calendar";
+  }
+
+  /* (non-Javadoc)
    * @see org.bedework.caldav.server.SysIntf#getPrincipal()
    */
   public AccessPrincipal getPrincipal() throws WebdavException {
@@ -787,12 +795,10 @@
     throw new WebdavException("unimplemented");
   }
 
-  /* (non-Javadoc)
-   * @see org.bedework.caldav.server.SysIntf#writeCalendar(java.util.Collection, int, java.io.Writer)
-   */
   public void writeCalendar(final Collection<CalDAVEvent> evs,
                             final int method,
-                            final Writer wtr) throws WebdavException {
+                            final XmlEmit xml,
+                            final String contentType) throws WebdavException {
     throw new WebdavException("unimplemented");
   }
 

Modified: trunk/google/src/edu/rpi/cct/bedework/caldav/google/GoogleSysIntfImpl.java
===================================================================
--- trunk/google/src/edu/rpi/cct/bedework/caldav/google/GoogleSysIntfImpl.java	2010-09-09 14:24:09 UTC (rev 66)
+++ trunk/google/src/edu/rpi/cct/bedework/caldav/google/GoogleSysIntfImpl.java	2010-09-15 15:05:13 UTC (rev 67)
@@ -63,6 +63,7 @@
 import edu.rpi.cmt.access.Acl.CurrentAccess;
 import edu.rpi.cmt.calendar.IcalDefs;
 import edu.rpi.cmt.timezones.Timezones;
+import edu.rpi.sss.util.xml.XmlEmit;
 
 import net.fortuna.ical4j.model.Calendar;
 import net.fortuna.ical4j.model.component.VFreeBusy;
@@ -148,6 +149,13 @@
   }
 
   /* (non-Javadoc)
+   * @see org.bedework.caldav.server.sysinterface.SysIntf#getDefaultContentType()
+   */
+  public String getDefaultContentType() throws WebdavException {
+    return "text/calendar";
+  }
+
+  /* (non-Javadoc)
    * @see org.bedework.caldav.server.SysIntf#getPrincipal()
    */
   public AccessPrincipal getPrincipal() throws WebdavException {
@@ -726,12 +734,10 @@
     throw new WebdavException("unimplemented");
   }
 
-  /* (non-Javadoc)
-   * @see org.bedework.caldav.server.SysIntf#writeCalendar(java.util.Collection, int, java.io.Writer)
-   */
   public void writeCalendar(final Collection<CalDAVEvent> evs,
                             final int method,
-                            final Writer wtr) throws WebdavException {
+                            final XmlEmit xml,
+                            final String contentType) throws WebdavException {
     throw new WebdavException("unimplemented");
   }
 



More information about the Bedework-commit mailing list