Changeset 871

Show
Ignore:
Timestamp:
07/26/06 16:42:22
Author:
douglm
Message:

Fixes to freebusy aggregator

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freebusy/trunk/build.xml

    r795 r871  
    5858     =================================================================== --> 
    5959 
    60   <target name="bld.all" 
     60  <target name="build-all" 
    6161          depends="init,bld.fbclient, 
    6262                   bld.fbwebclient" 
  • freebusy/trunk/deployment/freebusyAggregator/webapp/build.xml

    r795 r871  
    1515    <dirname property="this.dir" file="${ant.file}"/> 
    1616 
    17     <property name="app.sou.dir" location="${org.bedework.fbwebclient.base}" /> 
     17    <property name="app.sou.dir" location="${org.bedework.project.freebusy}/webclient" /> 
    1818 
    1919    <!-- Flag as struts --> 
  • freebusy/trunk/fbclient/src/org/bedework/fbclient/CalDavClient.java

    r756 r871  
    2626package org.bedework.fbclient; 
    2727 
    28 import org.bedework.caldav.client.api.CaldavClientIo
    29 import org.bedework.caldav.client.api.CaldavReq; 
    30 import org.bedework.caldav.client.api.CaldavResp; 
     28import org.bedework.http.client.dav.DavClient
     29import org.bedework.http.client.dav.DavReq; 
     30import org.bedework.http.client.dav.DavResp; 
    3131 
    3232import org.apache.commons.httpclient.NoHttpResponseException; 
     
    7171 
    7272    /** */ 
    73     public CaldavResp cdresp; 
     73    public DavResp cdresp; 
    7474  } 
    7575 
     
    8989   * @throws Throwable 
    9090   */ 
    91   public Response send(CaldavReq r, FBUserInfo ui) throws Throwable { 
    92     CaldavClientIo cio = getCio(ui.getHost(), ui.getPort(), ui.getSecure()); 
     91  public Response send(DavReq r, FBUserInfo ui) throws Throwable { 
     92    DavClient cio = getCio(ui.getHost(), ui.getPort(), ui.getSecure()); 
    9393    Response resp = new Response(); 
    9494    resp.ui = ui; 
     
    128128  } 
    129129 
    130   private CaldavClientIo getCio(String host, int port, boolean secure) throws Throwable { 
    131     CaldavClientIo cio = (CaldavClientIo)cioTable.get(host + port + secure); 
     130  private DavClient getCio(String host, int port, boolean secure) throws Throwable { 
     131    DavClient cio = (DavClient)cioTable.get(host + port + secure); 
    132132 
    133133    if (cio == null) { 
    134       cio = new CaldavClientIo(host, port, 30 * 1000, secure, debug); 
     134      cio = new DavClient(host, port, 30 * 1000, secure, debug); 
    135135 
    136136      cioTable.put(host + port + secure, cio); 
  • freebusy/trunk/webclient/build.xml

    r674 r871  
    3636      <pathelement location="${log4j.jar}"/> 
    3737 
     38      <pathelement location="${org.bedework.rpiutil.jar}"/> 
     39 
    3840      <!-- Include the location of the compiled calendar classes --> 
    3941      <pathelement location="${org.bedework.calfacadeshared.jar}"/> 
    40       <pathelement location="${org.bedework.common.jar}"/> 
    4142      <pathelement location="${org.bedework.calenv.jar}"/> 
    4243      <pathelement location="${org.bedework.caldavClientApi.jar}"/> 
  • freebusy/trunk/webclient/src/org/bedework/fbaggregator/FbAggForm.java

    r777 r871  
    3434 
    3535import java.util.Collection; 
    36 import java.util.List; 
    3736 
    3837/** 
     
    6463  private Collection failedResponses; 
    6564 
    66   private List timeZoneIds; 
     65  private Collection timeZoneIds; 
    6766 
    6867  private String currentTimeZoneId; 
     
    215214   * @param val 
    216215   */ 
    217   public void setTimeZoneIds(List val) { 
     216  public void setTimeZoneIds(Collection val) { 
    218217    timeZoneIds = val; 
    219218  } 
    220219 
    221220  /** 
    222    * @return List 
    223    */ 
    224   public List getTimeZoneIds() { 
     221   * @return Collection 
     222   */ 
     223  public Collection getTimeZoneIds() { 
    225224    return timeZoneIds; 
    226225  } 
  • freebusy/trunk/webclient/src/org/bedework/fbaggregator/FreeBusyAggregator.java

    r789 r871  
    2828import net.fortuna.ical4j.model.Calendar; 
    2929import net.fortuna.ical4j.model.DateTime; 
     30import net.fortuna.ical4j.model.Dur; 
     31import net.fortuna.ical4j.model.ParameterList; 
    3032import net.fortuna.ical4j.model.Period; 
    31  
    32 import org.bedework.caldav.client.api.BwIcalTrans; 
    33 import org.bedework.caldav.client.api.CaldavReq; 
     33import net.fortuna.ical4j.model.PropertyList; 
     34import net.fortuna.ical4j.model.component.VEvent; 
     35import net.fortuna.ical4j.model.parameter.TzId; 
     36import net.fortuna.ical4j.model.property.Attendee; 
     37import net.fortuna.ical4j.model.property.Description; 
     38import net.fortuna.ical4j.model.property.DtStart; 
     39import net.fortuna.ical4j.model.property.Duration; 
     40import net.fortuna.ical4j.model.property.Location; 
     41import net.fortuna.ical4j.model.property.Summary; 
     42import net.fortuna.ical4j.model.property.Uid; 
     43import net.fortuna.ical4j.model.property.Url; 
     44 
     45import org.bedework.caldav.server.SAICalCallback; 
    3446import org.bedework.calfacade.BwDateTime; 
    3547import org.bedework.calfacade.BwDuration; 
     
    3749import org.bedework.calfacade.BwFreeBusyComponent; 
    3850import org.bedework.calfacade.CalFacadeException; 
     51import org.bedework.calfacade.timezones.CalTimezones; 
     52import org.bedework.calfacade.timezones.ResourceTimezones; 
    3953import org.bedework.calfacade.util.CalFacadeUtil; 
    4054import org.bedework.calfacade.util.Granulator; 
     
    4357import org.bedework.fbclient.CalDavClient; 
    4458import org.bedework.fbclient.FBUserInfo; 
     59import org.bedework.http.client.dav.DavReq; 
     60import org.bedework.icalendar.IcalTranslator; 
    4561 
    4662import org.apache.log4j.Logger; 
     63import org.hibernate.Hibernate; 
     64import org.hibernate.id.Configurable; 
     65import org.hibernate.id.UUIDHexGenerator; 
    4766 
    4867import java.io.InputStream; 
     
    5372import java.util.Collection; 
    5473import java.util.Iterator; 
    55 import java.util.List
     74import java.util.Properties
    5675 
    5776import javax.servlet.http.HttpServletResponse; 
     
    6685  private boolean debug = true; 
    6786 
     87  private transient UUIDHexGenerator uuidGen; 
     88 
    6889  private transient Logger log; 
    6990 
    70   private transient BwIcalTrans trans; 
     91  private transient IcalTranslator trans; 
     92 
     93  private transient ResourceTimezones timezones; 
     94 
     95  // XXX get from properties 
     96  private static String defaultTimezone = "America/New_York"; 
    7197 
    7298  private static final int fbtb = BwFreeBusyComponent.typeBusy; 
     
    201227  public void open() throws Throwable { 
    202228    if (trans == null) { 
    203       trans = new BwIcalTrans("org.bedework.app.freebusy.", debug); 
    204     } 
    205  
    206     trans.open(); 
     229      trans = new IcalTranslator(new SAICalCallback(getTimezones(), null), 
     230                                 debug); 
     231    } 
    207232  } 
    208233 
     
    235260    } 
    236261 
    237     return trans.makeMeeting(startDt, 
    238                              tzid, 
    239                              duration, 
    240                              summary, 
    241                              description, 
    242                              location, 
    243                              uri, 
    244                              attendees); 
     262    String guid = getGuid(); 
     263 
     264    Calendar vcal = IcalTranslator.newIcal(); 
     265 
     266    VEvent ev = new VEvent(); 
     267 
     268    vcal.getComponents().add(ev); 
     269 
     270    PropertyList props = ev.getProperties(); 
     271 
     272    TzId tz = new TzId(tzid); 
     273    ParameterList aList = new ParameterList(); 
     274 
     275    aList.add(tz); 
     276 
     277    props.add(new DtStart(aList, startDt)); 
     278 
     279    props.add(new Duration(new Dur(0, 0, duration, 0))); 
     280 
     281    props.add(new Uid(guid)); 
     282 
     283    if (summary != null) { 
     284      props.add(new Summary(summary)); 
     285    } 
     286 
     287    if (description != null) { 
     288      props.add(new Description(description)); 
     289    } 
     290 
     291    if (location != null) { 
     292      props.add(new Location(location)); 
     293    } 
     294 
     295    if (uri != null) { 
     296      props.add(new Url(uri)); 
     297    } 
     298 
     299    if (attendees != null) { 
     300      it = attendees.iterator(); 
     301      while (it.hasNext()) { 
     302        String a = (String)it.next(); 
     303        Attendee att = new Attendee("MAILTO:" + a); 
     304        props.add(att); 
     305      } 
     306    } 
     307 
     308    return vcal; 
    245309  } 
    246310 
    247311  /** 
    248    * @return List of time zone ids 
     312   * @return Collectionof time zone ids 
    249313   * @throws Throwable 
    250314   */ 
    251   public List getTimeZoneIds() throws Throwable { 
    252     return trans.getTimeZoneIds(); 
     315  public Collection getTimeZoneIds() throws Throwable { 
     316    return ((ResourceTimezones)getTimezones()).getTimezoneIds(); 
    253317  } 
    254318 
     
    259323   */ 
    260324  public String getDefaultTimeZoneId() throws Throwable { 
    261     return trans.getDefaultTimeZone().getID(); 
     325    return getTimezones().getDefaultTimeZone().getID(); 
    262326  } 
    263327 
     
    272336      date += "T000000"; 
    273337    } 
    274     return CalFacadeUtil.getDateTime(date, trans.getTimezones()); 
     338    return CalFacadeUtil.getDateTime(date, getTimezones()); 
    275339  } 
    276340 
     
    383447   */ 
    384448  public void close() { 
    385     try { 
    386       trans.close(); 
    387     } catch (Throwable t) { 
    388     } 
    389449  } 
    390450 
     
    392452   *                         Private methods 
    393453   * ==================================================================== */ 
     454 
     455  private CalTimezones getTimezones() throws Throwable { 
     456    if (timezones == null) { 
     457      timezones = new ResourceTimezones(debug, null); 
     458      timezones.setDefaultTimeZoneId(defaultTimezone); 
     459    } 
     460 
     461    return timezones; 
     462  } 
    394463 
    395464  private FbResponse getFreeBusy(FBUserInfo ui, 
     
    397466                                 CalDavClient cd, 
    398467                                 BwDuration granularity) throws Throwable { 
    399     CaldavReq r = makeFreeBusyRequest(start, end, ui); 
     468    DavReq r = makeFreeBusyRequest(start, end, ui); 
    400469    CalDavClient.Response resp = cd.send(r, ui); 
    401470 
     
    422491      InputStream in = resp.cdresp.getContentStream(); 
    423492 
    424       Collection fbs = trans.getFreeBusy(new InputStreamReader(in)); 
     493      Collection fbs = trans.fromIcal(null, new InputStreamReader(in)); 
    425494 
    426495      Iterator fbit = fbs.iterator(); 
     
    489558  } 
    490559 
    491   private CaldavReq makeFreeBusyRequest(BwDateTime start, BwDateTime end, 
    492                                   FBUserInfo ui) throws Throwable { 
    493     CaldavReq req; 
     560  private DavReq makeFreeBusyRequest(BwDateTime start, BwDateTime end, 
     561                                     FBUserInfo ui) throws Throwable { 
     562    DavReq req; 
    494563 
    495564    if (ui.getAuthUser() == null) { 
    496       req = new CaldavReq(); 
     565      req = new DavReq(); 
    497566    } else { 
    498       req = new CaldavReq(ui.getAuthUser(), ui.getAuthPw()); 
     567      req = new DavReq(ui.getAuthUser(), ui.getAuthPw()); 
    499568    } 
    500569 
     
    526595    gpp.startDt = start; 
    527596    gpp.dur = granularity; 
    528     gpp.tzcache = trans.getTimezones(); 
     597    gpp.tzcache = getTimezones(); 
    529598 
    530599    BwDateTime bwend = end; 
     
    593662  } 
    594663 
     664  private String getGuid() { 
     665    return "CAL-" + (String)getUuidGen().generate(null, null) + 
     666           "freebusy.bedework.org"; 
     667  } 
     668 
     669  /* Use the hibernate uid generator */ 
     670  private UUIDHexGenerator getUuidGen() { 
     671    if (uuidGen != null) { 
     672      return uuidGen; 
     673    } 
     674 
     675    Properties uidprops = new Properties(); 
     676    uidprops.setProperty("separator", "-"); 
     677    uuidGen = new UUIDHexGenerator(); 
     678    ((Configurable)uuidGen).configure(Hibernate.STRING, uidprops, null); 
     679    return uuidGen; 
     680  } 
     681 
    595682  protected Logger getLogger() { 
    596683    if (log == null) {