Changeset 508

Show
Ignore:
Timestamp:
05/28/06 16:24:07
Author:
douglm
Message:

Mostly fixes to the caldav REPORT calendar-query

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/BwCalendar.java

    r477 r508  
    169169                    int calType) { 
    170170    super(owner, publick, creator, access); 
    171     this.name = name
    172     this.path = path
    173     this.summary = summary
    174     this.description = description
    175     this.mailListId = mailListId
    176     this.calendarCollection = calendarCollection
     171    setName(name)
     172    setPath(path)
     173    setSummary(summary)
     174    setDescription(description)
     175    setMailListId(mailListId)
     176    setCalendarCollection(calendarCollection)
    177177    setCalendar(parent); 
    178     this.children = children
    179     this.calType = calType
     178    setChildren(children)
     179    setCalType(calType)
    180180  } 
    181181 
  • trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWIntf.java

    r507 r508  
    7575 
    7676import edu.rpi.cct.uwcal.caldav.filter.Filter; 
     77import edu.rpi.cct.uwcal.caldav.calquery.CalendarData; 
    7778import edu.rpi.cct.uwcal.caldav.calquery.FreeBusyQuery; 
    7879 
     
    9697import java.util.ArrayList; 
    9798import java.util.Collection; 
    98 import java.util.Enumeration; 
    9999import java.util.HashMap; 
    100100import java.util.Iterator; 
     
    393393  } 
    394394 
    395   public Enumeration getProperties(WebdavNsNode node) 
    396       throws WebdavIntfException { 
     395  public Iterator iterateProperties(WebdavNsNode node) throws WebdavIntfException { 
    397396    try { 
    398397      CaldavBwNode uwnode = getBwnode(node); 
    399398 
    400       return WebdavProperty.getEnumeration(uwnode.getProperties(namespace)); 
     399      return WebdavProperty.iterator(uwnode.getProperties(namespace)); 
    401400    } catch (WebdavIntfException we) { 
    402401      throw we; 
     
    10941093        xml.property(tag, pr.getPval()); 
    10951094        closePropstat(); 
     1095      } else if (tag.equals(CaldavTags.calendarData)) { 
     1096        // pr should be a CalendarData object 
     1097        if (!(pr instanceof CalendarData)) { 
     1098          // XXX software error 
     1099        } else { 
     1100          CalendarData caldata = (CalendarData)pr; 
     1101          String content = null; 
     1102          openPropstat(); 
     1103          int status = HttpServletResponse.SC_OK; 
     1104 
     1105          try { 
     1106            content = caldata.process(node); 
     1107          } catch (WebdavException wde) { 
     1108            status = wde.getStatusCode();; 
     1109            if (debug && (status != HttpServletResponse.SC_NOT_FOUND)) { 
     1110              error(wde); 
     1111            } 
     1112          } 
     1113 
     1114          if (status != HttpServletResponse.SC_OK) { 
     1115            xml.emptyTag(tag); 
     1116          } else { 
     1117            /* Output the (transformed) node. 
     1118             */ 
     1119 
     1120            xml.property(CaldavTags.calendarData, content); 
     1121          } 
     1122          closePropstat(status); 
     1123        } 
    10961124      } else if (tag.equals(CaldavTags.calendarDescription)) { 
    10971125        if ((cal != null) && (cal.getDescription() != null)) { 
     
    13001328   */ 
    13011329  public CalSvcI getSvci() throws WebdavIntfException { 
    1302     boolean publicMode = (account == null); 
    1303  
    13041330    if (svci != null) { 
    13051331      if (!svci.isOpen()) { 
     
    13231349                                         account, 
    13241350                                         envPrefix, 
    1325                                          publicMode, 
     1351                                         false,   // publicAdmin 
    13261352                                         true,    // caldav 
    13271353                                         null, // synchId 
  • trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWServlet.java

    r507 r508  
    108108    methods.put("MKCALENDAR", new MkcalendarMethod()); 
    109109    methods.put("OPTIONS", new CalDavOptionsMethod()); 
     110    methods.put("PROPFIND", new CaldavPropFindMethod()); 
    110111    methods.put("REPORT", new ReportMethod()); 
    111112  } 
  • trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavComponentNode.java

    r426 r508  
    5959 
    6060import org.bedework.calsvci.CalSvcI; 
     61import org.bedework.davdefs.CaldavTags; 
    6162import org.bedework.icalendar.ComponentWrapper; 
    6263import org.bedework.icalendar.IcalTranslator; 
    6364//import org.bedework.icalendar.IcalUtil; 
    6465 
     66import edu.rpi.cct.uwcal.caldav.calquery.CalendarData; 
    6567import edu.rpi.cct.webdav.servlet.shared.WebdavIntfException; 
    6668import edu.rpi.cct.webdav.servlet.shared.WebdavProperty; 
     
    298300    addProp(al, ICalTags.hasAttachment, "0"); 
    299301 
     302    /* Default property calendar-data returns all of the object */ 
     303    al.add(new CalendarData(CaldavTags.calendarData, debug)); 
     304 
    300305    return al; 
    301306  } 
  • trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/ReportMethod.java

    r490 r508  
    9393  /* The parsed results go here. We see: 
    9494   *  1. Free-busy request 
    95    *  2. Query - optional props + optional calendar data + filter 
    96    *  3. Multi-get - optional props + optional calendar data + one or more hrefs 
     95   *  2. Query - optional props + filter 
     96   *  3. Multi-get - optional props + one or more hrefs 
    9797   */ 
    9898 
    9999  private FreeBusyQuery freeBusy; 
    100100  private PropFindMethod.PropRequest preq; 
    101   private CalendarData caldata; 
     101  //private CalendarData caldata; 
    102102  private Filter filter; 
    103103  private ArrayList hrefs; 
    104104 
     105  CalendarData caldata; 
     106 
     107  // ENUM 
    105108  private final static int reportTypeQuery = 0; 
    106109  private final static int reportTypeMultiGet = 1; 
     
    209212        } else { 
    210213          /* Two possibilities: 
    211                <!ELEMENT calendar-multiget 
    212                             (DAV:allprop | DAV:propname | DAV:prop)? 
    213                             calendar-data? DAV:href+
    214  
    215                <!ELEMENT calendar-query 
    216                        (DAV:allprop | DAV:propname | DAV:prop)? 
    217                        calendar-data? filter
     214               <!ELEMENT calendar-multiget ((DAV:allprop | 
     215                                      DAV:propname | 
     216                                      DAV:prop)?, DAV:href+)
     217 
     218               <!ELEMENT calendar-query ((DAV:allprop | 
     219                                    DAV:propname | 
     220                                    DAV:prop)?, filter, timezone?)
    218221           */ 
    219222 
     
    229232            } 
    230233            preq = pr; 
    231           } else if (nodeMatches(curnode, CaldavTags.calendarData)) { 
    232             if (caldata != null) { 
    233               if (debug) { 
    234                 trace("REPORT: caldata not null"); 
    235               } 
    236               throw new WebdavBadRequest(); 
    237             } 
    238             caldata = new CalendarData(debug); 
    239             caldata.parse(curnode); 
    240234          } else if ((reportType == reportTypeQuery) && 
    241235                     nodeMatches(curnode, CaldavTags.filter)) { 
     
    282276        } 
    283277      } else if (reportType == reportTypeQuery) { 
    284         if (caldata == null) { 
    285           // same as empty element? 
    286           caldata = new CalendarData(debug); 
    287         } 
    288278        if (filter == null) { 
    289279          // filter required 
    290280          throw new WebdavBadRequest(); 
     281        } 
     282      } 
     283 
     284      if (preq != null) { 
     285        // Look for a calendar-data property 
     286        Iterator it = preq.iterateProperties(); 
     287        while (it.hasNext()) { 
     288          Object o = it.next(); 
     289          if (o instanceof CalendarData) { 
     290            caldata = (CalendarData)o; 
     291          } 
    291292        } 
    292293      } 
     
    298299          freeBusy.dump(); 
    299300        } else if (reportType == reportTypeQuery) { 
    300           // Query - optional props + optional calendar data + filter 
    301           if (caldata != null) { 
    302             caldata.dump(); 
    303           } else { 
    304             trace("No caldata"); 
    305           } 
    306  
     301          // Query - optional props + filter 
    307302          filter.dump(); 
    308303        } else if (reportType == reportTypeMultiGet) { 
    309           // Multi-get - optional props + optional calendar data + one or more hrefs 
    310           if (caldata != null) { 
    311             caldata.dump(); 
    312           } else { 
    313             trace("No caldata"); 
    314           } 
     304          // Multi-get - optional props + one or more hrefs 
    315305 
    316306          Iterator it = hrefs.iterator(); 
     
    363353        int retrieveRecur; 
    364354 
    365         if (caldata.getErs() != null) { 
     355        if (caldata == null) { 
     356          retrieveRecur = CalFacadeDefs.retrieveRecurMaster; 
     357        } else if (caldata.getErs() != null) { 
    366358          /* expand XXX use range */ 
    367359          retrieveRecur = CalFacadeDefs.retrieveRecurExpanded; 
     
    513505            WebdavMethods.propFind); 
    514506    int status = node.getStatus(); 
    515     String content = null; 
    516507 
    517508    openTag(WebdavTags.response); 
    518  
    519     if (status == HttpServletResponse.SC_OK) { 
    520       if ((reportType == reportTypeQuery) || 
    521           (reportType == reportTypeMultiGet)) { 
    522         try { 
    523           content = caldata.process(node); 
    524         } catch (WebdavException wde) { 
    525           status = wde.getStatusCode();; 
    526           if (debug && (status != HttpServletResponse.SC_NOT_FOUND)) { 
    527             error(wde); 
    528           } 
    529         } 
    530       } 
    531     } 
    532509 
    533510    if (status != HttpServletResponse.SC_OK) { 
     
    541518    } else { 
    542519      pm.doNodeProperties(node, preq); 
    543  
    544       /* Output the (transformed) node. 
    545        */ 
    546  
    547       property(CaldavTags.calendarData, content); 
    548520    } 
    549521 
  • trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/calquery/CalendarData.java

    r423 r508  
    6565import edu.rpi.cct.webdav.servlet.shared.WebdavException; 
    6666import edu.rpi.cct.webdav.servlet.shared.WebdavNsNode; 
     67import edu.rpi.cct.webdav.servlet.shared.WebdavProperty; 
     68import edu.rpi.sss.util.xml.QName; 
    6769import edu.rpi.sss.util.xml.XmlUtil; 
    6870 
     
    8890 *   @author Mike Douglass   douglm@rpi.edu 
    8991 */ 
    90 public class CalendarData
     92public class CalendarData extends WebdavProperty
    9193  /* 
    9294      <!ELEMENT calendar-data ((comp?, (expand | 
     
    118120      <!ATTLIST expand-recurrence-set start CDATA #REQUIRED 
    119121                                      end CDATA #REQUIRED> 
     122---------------------------------------------------------------------- 
     123         <!ELEMENT calendar-data ((comp?, (expand | 
     124                                           limit-recurrence-set)?, 
     125                                           limit-freebusy-set?) | 
     126                                  #PCDATA)?> 
     127         PCDATA value: iCalendar object 
     128 
     129         <!ATTLIST calendar-data content-type CDATA "text/calendar"> 
     130                                 version CDATA "2.0"> 
     131         content-type value: a MIME media type 
     132         version value: a version string 
     133 
     134         <!ELEMENT comp ((allprop | prop*), (allcomp | comp*))> 
     135 
     136         <!ATTLIST comp name CDATA #REQUIRED> 
     137         name value: a calendar component name 
     138 
     139         <!ELEMENT allcomp EMPTY> 
     140 
     141         <!ELEMENT allprop EMPTY> 
     142 
     143         <!ELEMENT prop EMPTY> 
     144 
     145         <!ATTLIST prop name CDATA #REQUIRED 
     146                     novalue (yes | no) "no"> 
     147         name value: a calendar property name 
     148         novalue value: "yes" or "no" 
     149 
     150         <!ELEMENT expand EMPTY> 
     151 
     152         <!ATTLIST expand start CDATA #REQUIRED 
     153                         end   CDATA #REQUIRED> 
     154         start value: an iCalendar "date with UTC time" 
     155         end value: an iCalendar "date with UTC time" 
     156 
     157         <!ELEMENT limit-recurrence-set EMPTY> 
     158 
     159         <!ATTLIST limit-recurrence-set start CDATA #REQUIRED 
     160                                       end   CDATA #REQUIRED> 
     161         start value: an iCalendar "date with UTC time" 
     162         end value: an iCalendar "date with UTC time" 
     163 
     164         <!ELEMENT limit-freebusy-set EMPTY> 
     165 
     166         <!ATTLIST limit-freebusy-set start CDATA #REQUIRED 
     167                                     end   CDATA #REQUIRED> 
     168         start value: an iCalendar "date with UTC time" 
     169         end value: an iCalendar "date with UTC time" 
    120170 
    121171   */ 
     
    132182  /** Constructor 
    133183   * 
     184   * @param tag  QName name 
    134185   * @param debug 
    135186   */ 
    136   public CalendarData(boolean debug) { 
     187  public CalendarData(QName tag, 
     188                      boolean debug) { 
     189    super(tag, null); 
    137190    this.debug = debug; 
    138191  } 
  • trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/common/PropFindMethod.java

    r418 r508  
    7171import java.util.ArrayList; 
    7272import java.util.Collection; 
    73 import java.util.Enumeration; 
    7473import java.util.Iterator; 
    7574import javax.servlet.http.HttpServletRequest; 
     
    8483   */ 
    8584  public static class PropRequest { 
     85    // ENUM 
    8686    //private static final int reqPropNone = 0; 
    8787    private static final int reqProp = 1; 
     
    9797    /** For the prop element we build a Collection of WebdavProperty 
    9898     */ 
    99     Collection props; 
     99    private Collection props; 
     100 
     101    /** 
     102     * @return Iterator 
     103     */ 
     104    public Iterator iterateProperties() { 
     105      if (props == null) { 
     106        return new ArrayList().iterator(); 
     107      } 
     108 
     109      return props.iterator(); 
     110    } 
    100111  } 
    101112 
     
    214225      Element propnode = children[i]; 
    215226 
    216       WebdavProperty prop = new WebdavProperty( 
    217                new QName(propnode.getNamespaceURI(), 
    218                          propnode.getLocalName()), 
    219                          null); 
     227      WebdavProperty prop = makeProp(propnode); 
    220228 
    221229      if (debug) { 
     
    228236 
    229237    return pr; 
     238  } 
     239 
     240  /** Override this to create namespace specific property objects. 
     241   * 
     242   * @param propnode 
     243   * @return WebdavProperty 
     244   * @throws WebdavException 
     245   */ 
     246  public WebdavProperty makeProp(Element propnode) throws WebdavException { 
     247    return new WebdavProperty(new QName(propnode.getNamespaceURI(), 
     248                                        propnode.getLocalName()), 
     249                                        null); 
    230250  } 
    231251 
     
    307327  } 
    308328 
    309   /* Build the response for a single node for a propfind request 
    310    */ 
    311   /** 
     329  /** Build the response for a single node for a propfind request 
     330   * 
    312331   * @param node 
    313332   * @param preq 
     
    368387   */ 
    369388  private void doNodeNsProperties(WebdavNsNode node) throws WebdavException { 
    370     Enumeration en = getNsIntf().getProperties(node); 
     389    Iterator it = getNsIntf().iterateProperties(node); 
    371390    WebdavNsIntf intf = getNsIntf(); 
    372391 
    373     while (en.hasMoreElements()) { 
    374       WebdavProperty prop = (WebdavProperty)en.nextElement(); 
     392    while (it.hasNext()) { 
     393      WebdavProperty prop = (WebdavProperty)it.next(); 
    375394 
    376395      intf.generatePropValue(node, prop); 
  • trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsIntf.java

    r418 r508  
    6666import java.io.Serializable; 
    6767import java.net.URL; 
    68 import java.util.Enumeration; 
    6968import java.util.HashMap; 
    7069import java.util.Iterator; 
     
    389388   * included. 
    390389   * 
    391    * @param node             node in question 
    392    * @return Enumeration     proeprties 
    393    * @throws WebdavIntfException 
    394    */ 
    395   public abstract Enumeration getProperties(WebdavNsNode node) 
     390   * @param node          node in question 
     391   * @return Iterator     over proprrties 
     392   * @throws WebdavIntfException 
     393   */ 
     394  public abstract Iterator iterateProperties(WebdavNsNode node) 
    396395      throws WebdavIntfException; 
    397396 
     
    601600   */ 
    602601  public void generatePropValue(WebdavNsNode node, 
    603                                 WebdavProperty pr) throws WebdavIntfException { 
     602                               WebdavProperty pr) throws WebdavIntfException { 
    604603    QName tag = pr.getTag(); 
    605604    String ns = tag.getNamespaceURI(); 
     
    612611        xml.emptyTag(tag); 
    613612        closePropstat(HttpServletResponse.SC_NOT_FOUND); 
     613        return; 
    614614      } 
    615615 
  • trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/shared/WebdavProperty.java

    r2 r508  
    5959import java.io.Serializable; 
    6060import java.util.Collection; 
    61 import java.util.Enumeration
     61import java.util.Iterator
    6262 
    6363/** One of these for each property in a request. 
     
    108108  } 
    109109 
    110   /** Convenience method to provide an enumeration of these objects 
     110  /** Convenience method to provide an Iterator over these objects 
    111111   * 
    112112   * @param c 
    113    * @return Enumeration 
     113   * @return Iterator 
    114114   */ 
    115   public static Enumeration getEnumeration(Collection c) { 
     115  public static Iterator iterator(Collection c) { 
    116116    WebdavProperty[] ps = (WebdavProperty[])c.toArray( 
    117117            new WebdavProperty[c.size()]); 
    118     return new PropertyEnumeration(ps); 
     118    return new PropertyIterator(ps); 
    119119  } 
    120120 
    121   private static class PropertyEnumeration implements Enumeration
     121  private static class PropertyIterator implements Iterator
    122122    WebdavProperty[] ps = null; 
    123123    int index; 
     
    127127     * @param ps 
    128128     */ 
    129     public PropertyEnumeration(WebdavProperty[] ps) { 
     129    public PropertyIterator(WebdavProperty[] ps) { 
    130130      this.ps = ps; 
    131131    } 
    132132 
    133     public boolean hasMoreElements() { 
     133    public boolean hasNext() { 
    134134      if ((ps == null) || 
    135135          (index >= ps.length)) { 
     
    140140    } 
    141141 
    142     public Object nextElement() { 
     142    public Object next() { 
    143143      if ((ps == null) || 
    144144          (index >= ps.length)) { 
     
    151151      return p; 
    152152    } 
     153 
     154    public void remove() { 
     155      throw new RuntimeException("Unimplemented"); 
     156    } 
    153157  } 
    154158} 
  • trunk/calendar3/caldav/war/WEB-INF/userweb.xml

    r310 r508  
    7373  <login-config> 
    7474    <auth-method>BASIC</auth-method> 
    75     <realm-name>rpiLdap</realm-name> 
     75    <realm-name>@SECURITY-DOMAIN@</realm-name> 
    7676  </login-config> 
    7777 
  • trunk/calendar3/config/configs/democal.properties

    r469 r508  
    190190org.bedework.app.Usercaldav.context.root=ucaldav 
    191191 
    192 org.bedework.app.Usercaldav.security.domain=null 
    193 org.bedework.app.Usercaldav.security.prefix=null 
     192org.bedework.app.Usercaldav.security.domain=demo 
     193org.bedework.app.Usercaldav.security.prefix=demo 
    194194org.bedework.app.Usercaldav.transport.guarantee=NONE 
    195195 
  • trunk/calendar3/test/caldavTestData/eg/content/eg02.xml

    r507 r508  
    44  <D:prop> 
    55    <D:getetag/> 
     6    <C:calendar-data> 
     7      <C:comp name="VCALENDAR"> 
     8        <C:allprop/> 
     9        <C:comp name="VEVENT"> 
     10          <C:prop name="X-ABC-GUID"/> 
     11          <C:prop name="UID"/> 
     12          <C:prop name="DTSTART"/> 
     13          <C:prop name="DTEND"/> 
     14          <C:prop name="DURATION"/> 
     15          <C:prop name="EXDATE"/> 
     16          <C:prop name="EXRULE"/> 
     17          <C:prop name="RDATE"/> 
     18          <C:prop name="RRULE"/> 
     19          <C:prop name="LOCATION"/> 
     20          <C:prop name="SUMMARY"/> 
     21        </C:comp> 
     22        <C:comp name="VTIMEZONE"> 
     23          <C:allprop/> 
     24          <C:allcomp/> 
     25        </C:comp> 
     26      </C:comp> 
     27    </C:calendar-data> 
    628  </D:prop> 
    7   <C:calendar-data> 
    8     <C:comp name="VCALENDAR"> 
    9       <C:allprop/> 
    10       <C:comp name="VEVENT"> 
    11         <C:prop name="X-ABC-GUID"/> 
    12         <C:prop name="UID"/> 
    13         <C:prop name="DTSTART"/> 
    14         <C:prop name="DTEND"/> 
    15         <C:prop name="DURATION"/> 
    16         <C:prop name="EXDATE"/> 
    17         <C:prop name="EXRULE"/> 
    18         <C:prop name="RDATE"/> 
    19         <C:prop name="RRULE"/> 
    20         <C:prop name="LOCATION"/> 
    21         <C:prop name="SUMMARY"/> 
    22       </C:comp> 
    23       <C:comp name="VTIMEZONE"> 
    24         <C:allprop/> 
    25         <C:allcomp/> 
    26       </C:comp> 
    27     </C:comp> 
    28   </C:calendar-data> 
    2929  <C:filter> <!-- a comment --> 
    3030    <C:comp-filter name="VCALENDAR"> 
    3131      <C:comp-filter name="VEVENT"> 
    32         <C:time-range start="20060601T000000Z
    33                       end="20060630T235959Z"/> 
     32        <C:time-range start="@NOW@
     33                      end="@NEXTWEEK@"/> 
    3434      </C:comp-filter> 
    3535    </C:comp-filter>