Changeset 871
- Timestamp:
- 07/26/06 16:42:22
- Files:
-
- freebusy/trunk/build.xml (modified) (1 diff)
- freebusy/trunk/deployment/freebusyAggregator/webapp/build.xml (modified) (1 diff)
- freebusy/trunk/fbclient/src/org/bedework/fbclient/CalDavClient.java (modified) (4 diffs)
- freebusy/trunk/webclient/build.xml (modified) (1 diff)
- freebusy/trunk/webclient/src/org/bedework/fbaggregator/FbAggForm.java (modified) (3 diffs)
- freebusy/trunk/webclient/src/org/bedework/fbaggregator/FreeBusyAggregator.java (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freebusy/trunk/build.xml
r795 r871 58 58 =================================================================== --> 59 59 60 <target name="b ld.all"60 <target name="build-all" 61 61 depends="init,bld.fbclient, 62 62 bld.fbwebclient" freebusy/trunk/deployment/freebusyAggregator/webapp/build.xml
r795 r871 15 15 <dirname property="this.dir" file="${ant.file}"/> 16 16 17 <property name="app.sou.dir" location="${org.bedework. fbwebclient.base}" />17 <property name="app.sou.dir" location="${org.bedework.project.freebusy}/webclient" /> 18 18 19 19 <!-- Flag as struts --> freebusy/trunk/fbclient/src/org/bedework/fbclient/CalDavClient.java
r756 r871 26 26 package org.bedework.fbclient; 27 27 28 import org.bedework. caldav.client.api.CaldavClientIo;29 import org.bedework. caldav.client.api.CaldavReq;30 import org.bedework. caldav.client.api.CaldavResp;28 import org.bedework.http.client.dav.DavClient; 29 import org.bedework.http.client.dav.DavReq; 30 import org.bedework.http.client.dav.DavResp; 31 31 32 32 import org.apache.commons.httpclient.NoHttpResponseException; … … 71 71 72 72 /** */ 73 public CaldavResp cdresp;73 public DavResp cdresp; 74 74 } 75 75 … … 89 89 * @throws Throwable 90 90 */ 91 public Response send( CaldavReq r, FBUserInfo ui) throws Throwable {92 CaldavClientIocio = 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()); 93 93 Response resp = new Response(); 94 94 resp.ui = ui; … … 128 128 } 129 129 130 private CaldavClientIogetCio(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); 132 132 133 133 if (cio == null) { 134 cio = new CaldavClientIo(host, port, 30 * 1000, secure, debug);134 cio = new DavClient(host, port, 30 * 1000, secure, debug); 135 135 136 136 cioTable.put(host + port + secure, cio); freebusy/trunk/webclient/build.xml
r674 r871 36 36 <pathelement location="${log4j.jar}"/> 37 37 38 <pathelement location="${org.bedework.rpiutil.jar}"/> 39 38 40 <!-- Include the location of the compiled calendar classes --> 39 41 <pathelement location="${org.bedework.calfacadeshared.jar}"/> 40 <pathelement location="${org.bedework.common.jar}"/>41 42 <pathelement location="${org.bedework.calenv.jar}"/> 42 43 <pathelement location="${org.bedework.caldavClientApi.jar}"/> freebusy/trunk/webclient/src/org/bedework/fbaggregator/FbAggForm.java
r777 r871 34 34 35 35 import java.util.Collection; 36 import java.util.List;37 36 38 37 /** … … 64 63 private Collection failedResponses; 65 64 66 private ListtimeZoneIds;65 private Collection timeZoneIds; 67 66 68 67 private String currentTimeZoneId; … … 215 214 * @param val 216 215 */ 217 public void setTimeZoneIds( Listval) {216 public void setTimeZoneIds(Collection val) { 218 217 timeZoneIds = val; 219 218 } 220 219 221 220 /** 222 * @return List223 */ 224 public ListgetTimeZoneIds() {221 * @return Collection 222 */ 223 public Collection getTimeZoneIds() { 225 224 return timeZoneIds; 226 225 } freebusy/trunk/webclient/src/org/bedework/fbaggregator/FreeBusyAggregator.java
r789 r871 28 28 import net.fortuna.ical4j.model.Calendar; 29 29 import net.fortuna.ical4j.model.DateTime; 30 import net.fortuna.ical4j.model.Dur; 31 import net.fortuna.ical4j.model.ParameterList; 30 32 import net.fortuna.ical4j.model.Period; 31 32 import org.bedework.caldav.client.api.BwIcalTrans; 33 import org.bedework.caldav.client.api.CaldavReq; 33 import net.fortuna.ical4j.model.PropertyList; 34 import net.fortuna.ical4j.model.component.VEvent; 35 import net.fortuna.ical4j.model.parameter.TzId; 36 import net.fortuna.ical4j.model.property.Attendee; 37 import net.fortuna.ical4j.model.property.Description; 38 import net.fortuna.ical4j.model.property.DtStart; 39 import net.fortuna.ical4j.model.property.Duration; 40 import net.fortuna.ical4j.model.property.Location; 41 import net.fortuna.ical4j.model.property.Summary; 42 import net.fortuna.ical4j.model.property.Uid; 43 import net.fortuna.ical4j.model.property.Url; 44 45 import org.bedework.caldav.server.SAICalCallback; 34 46 import org.bedework.calfacade.BwDateTime; 35 47 import org.bedework.calfacade.BwDuration; … … 37 49 import org.bedework.calfacade.BwFreeBusyComponent; 38 50 import org.bedework.calfacade.CalFacadeException; 51 import org.bedework.calfacade.timezones.CalTimezones; 52 import org.bedework.calfacade.timezones.ResourceTimezones; 39 53 import org.bedework.calfacade.util.CalFacadeUtil; 40 54 import org.bedework.calfacade.util.Granulator; … … 43 57 import org.bedework.fbclient.CalDavClient; 44 58 import org.bedework.fbclient.FBUserInfo; 59 import org.bedework.http.client.dav.DavReq; 60 import org.bedework.icalendar.IcalTranslator; 45 61 46 62 import org.apache.log4j.Logger; 63 import org.hibernate.Hibernate; 64 import org.hibernate.id.Configurable; 65 import org.hibernate.id.UUIDHexGenerator; 47 66 48 67 import java.io.InputStream; … … 53 72 import java.util.Collection; 54 73 import java.util.Iterator; 55 import java.util. List;74 import java.util.Properties; 56 75 57 76 import javax.servlet.http.HttpServletResponse; … … 66 85 private boolean debug = true; 67 86 87 private transient UUIDHexGenerator uuidGen; 88 68 89 private transient Logger log; 69 90 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"; 71 97 72 98 private static final int fbtb = BwFreeBusyComponent.typeBusy; … … 201 227 public void open() throws Throwable { 202 228 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 } 207 232 } 208 233 … … 235 260 } 236 261 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; 245 309 } 246 310 247 311 /** 248 * @return Listof time zone ids312 * @return Collectionof time zone ids 249 313 * @throws Throwable 250 314 */ 251 public ListgetTimeZoneIds() throws Throwable {252 return trans.getTimeZoneIds();315 public Collection getTimeZoneIds() throws Throwable { 316 return ((ResourceTimezones)getTimezones()).getTimezoneIds(); 253 317 } 254 318 … … 259 323 */ 260 324 public String getDefaultTimeZoneId() throws Throwable { 261 return trans.getDefaultTimeZone().getID();325 return getTimezones().getDefaultTimeZone().getID(); 262 326 } 263 327 … … 272 336 date += "T000000"; 273 337 } 274 return CalFacadeUtil.getDateTime(date, trans.getTimezones());338 return CalFacadeUtil.getDateTime(date, getTimezones()); 275 339 } 276 340 … … 383 447 */ 384 448 public void close() { 385 try {386 trans.close();387 } catch (Throwable t) {388 }389 449 } 390 450 … … 392 452 * Private methods 393 453 * ==================================================================== */ 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 } 394 463 395 464 private FbResponse getFreeBusy(FBUserInfo ui, … … 397 466 CalDavClient cd, 398 467 BwDuration granularity) throws Throwable { 399 CaldavReq r = makeFreeBusyRequest(start, end, ui);468 DavReq r = makeFreeBusyRequest(start, end, ui); 400 469 CalDavClient.Response resp = cd.send(r, ui); 401 470 … … 422 491 InputStream in = resp.cdresp.getContentStream(); 423 492 424 Collection fbs = trans. getFreeBusy(new InputStreamReader(in));493 Collection fbs = trans.fromIcal(null, new InputStreamReader(in)); 425 494 426 495 Iterator fbit = fbs.iterator(); … … 489 558 } 490 559 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; 494 563 495 564 if (ui.getAuthUser() == null) { 496 req = new CaldavReq();565 req = new DavReq(); 497 566 } else { 498 req = new CaldavReq(ui.getAuthUser(), ui.getAuthPw());567 req = new DavReq(ui.getAuthUser(), ui.getAuthPw()); 499 568 } 500 569 … … 526 595 gpp.startDt = start; 527 596 gpp.dur = granularity; 528 gpp.tzcache = trans.getTimezones();597 gpp.tzcache = getTimezones(); 529 598 530 599 BwDateTime bwend = end; … … 593 662 } 594 663 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 595 682 protected Logger getLogger() { 596 683 if (log == null) {
