Changeset 469
- Timestamp:
- 05/12/06 12:37:23
- Files:
-
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java (modified) (2 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java (modified) (2 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java (modified) (1 diff)
- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/ReportMethod.java (modified) (5 diffs)
- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (modified) (2 diffs)
- trunk/calendar3/config/configs/democal.options.xml (modified) (1 diff)
- trunk/calendar3/config/configs/democal.properties (modified) (1 diff)
- trunk/calendar3/icalendar/src/org/bedework/icalendar/IcalTranslator.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java
r466 r469 285 285 286 286 public BwCalendar getSpecialCalendar(BwUser user, 287 int calType) throws CalFacadeException { 287 int calType, 288 boolean create) throws CalFacadeException { 288 289 StringBuffer sb = new StringBuffer(); 289 290 String name; … … 316 317 BwCalendar cal = getCalendar(sb.toString(), privRead); 317 318 318 if ( cal != null) {319 if ((cal != null) || !create) { 319 320 return cal; 320 321 } trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
r466 r469 871 871 872 872 public BwCalendar getSpecialCalendar(BwUser user, 873 int calType) throws CalFacadeException { 874 return calendars.getSpecialCalendar(user, calType); 873 int calType, 874 boolean create) throws CalFacadeException { 875 return calendars.getSpecialCalendar(user, calType, create); 875 876 } 876 877 … … 1123 1124 1124 1125 public Collection getDeletedProxies() throws CalFacadeException { 1125 BwCalendar cal = getSpecialCalendar(user, BwCalendar.calTypeDeleted );1126 BwCalendar cal = getSpecialCalendar(user, BwCalendar.calTypeDeleted, false); 1126 1127 1127 1128 if (cal == null) { 1128 // Not supported 1129 // Not supported or never deleted anything 1129 1130 return new ArrayList(); 1130 1131 } trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java
r466 r469 473 473 474 474 public BwCalendar getSpecialCalendar(BwUser user, 475 int calType) throws CalFacadeException { 475 int calType, 476 boolean create) throws CalFacadeException { 476 477 throw new CalFacadeUnimplementedException(); 477 478 } trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java
r466 r469 188 188 * @param user 189 189 * @param calType int special calendar type. 190 * @param create true if we shoudl create it if non-existant. 190 191 * @return BwCalendar null for unknown calendar 191 192 * @throws CalFacadeException 192 193 */ 193 194 public BwCalendar getSpecialCalendar(BwUser user, 194 int calType) throws CalFacadeException; 195 int calType, 196 boolean create) throws CalFacadeException; 195 197 196 198 /** Add a calendar object trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/ReportMethod.java
r423 r469 76 76 import org.w3c.dom.Element; 77 77 78 import java.io.Reader; 79 import java.io.Writer; 78 80 import java.util.ArrayList; 79 81 import java.util.Collection; … … 140 142 } 141 143 142 processResp(req, resp, depth); 144 if (reportType == reportTypeFreeBusy) { 145 processFbResp(req, resp); 146 } else { 147 processResp(req, resp, depth); 148 } 143 149 } 144 150 … … 386 392 } 387 393 } 388 } else if (reportType == reportTypeFreeBusy) {389 try {390 nodes = intf.getFreeBusy(node, freeBusy);391 } catch (WebdavException wde) {392 if (debug) {393 trace("intf.getFreeBusy exception");394 }395 status = wde.getStatusCode();396 }397 394 } else if (reportType == reportTypeExpandProperty) { 398 395 } … … 417 414 418 415 flush(); 416 } 417 418 /** Handle free/busy response 419 * 420 * @param req 421 * @param resp 422 * @param depth 423 * @throws WebdavException 424 */ 425 public void processFbResp(HttpServletRequest req, 426 HttpServletResponse resp) throws WebdavException { 427 resp.setStatus(HttpServletResponse.SC_OK); 428 resp.setContentType("text/calendar; charset=UTF-8"); 429 430 String resourceUri = getResourceUri(req); 431 432 CaldavBWIntf intf = (CaldavBWIntf)getNsIntf(); 433 WebdavNsNode node = intf.getNode(resourceUri); 434 435 int status = HttpServletResponse.SC_OK; 436 437 Collection nodes = null; 438 439 try { 440 nodes = intf.getFreeBusy(node, freeBusy); 441 } catch (WebdavException wde) { 442 if (debug) { 443 trace("intf.getFreeBusy exception"); 444 } 445 status = wde.getStatusCode(); 446 } 447 448 if (status != HttpServletResponse.SC_OK) { 449 if (debug) { 450 trace("REPORT status " + status); 451 } 452 // Entire request failed. 453 node.setStatus(status); 454 doNode(node); 455 } else if (nodes != null) { 456 Iterator it = nodes.iterator(); 457 458 // XXX Only one node? 459 while (it.hasNext()) { 460 WebdavNsNode curnode = (WebdavNsNode)it.next(); 461 462 if (!(node instanceof CaldavCalNode)) { 463 if (debug) { 464 trace("Expected CaldavCalNode - got " + node); 465 } 466 status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; 467 } else { 468 CaldavCalNode cnode = (CaldavCalNode)node; 469 470 Writer out; 471 try { 472 out = resp.getWriter(); 473 } catch (Throwable t) { 474 throw new WebdavException(t); 475 } 476 477 /** Get the content now to set up length, type etc. 478 */ 479 Reader in = getNsIntf().getContent(node); 480 resp.setContentLength(node.getContentLen()); 481 if (in == null) { 482 if (debug) { 483 debugMsg("status: " + HttpServletResponse.SC_NO_CONTENT); 484 } 485 486 resp.setStatus(HttpServletResponse.SC_NO_CONTENT); 487 } else { 488 if (debug) { 489 debugMsg("send content - length=" + node.getContentLen()); 490 } 491 492 writeContent(in, out); 493 } 494 } 495 } 496 } 497 498 flush(); 499 } 500 501 // XXX Make the following part of the interface. 502 503 /** size of buffer used for copying content to response. 504 */ 505 private static final int bufferSize = 4096; 506 507 private void writeContent(Reader in, Writer out) 508 throws WebdavException { 509 try { 510 char[] buff = new char[bufferSize]; 511 int len; 512 513 while (true) { 514 len = in.read(buff); 515 516 if (len < 0) { 517 break; 518 } 519 520 out.write(buff, 0, len); 521 } 522 } catch (Throwable t) { 523 throw new WebdavException(t); 524 } finally { 525 try { 526 in.close(); 527 } catch (Throwable t) {} 528 try { 529 out.close(); 530 } catch (Throwable t) {} 531 } 419 532 } 420 533 … … 440 553 } 441 554 } 442 } else if (reportType == reportTypeFreeBusy) {443 if (!(node instanceof CaldavCalNode)) {444 if (debug) {445 trace("Expected CaldavCalNode - got " + node);446 }447 status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;448 } else {449 CaldavCalNode cnode = (CaldavCalNode)node;450 451 content = cnode.getContentString();452 }453 555 } 454 556 } trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
r466 r469 1702 1702 event.setDeleted(true); 1703 1703 event.setCalendar(getCal().getSpecialCalendar(event.getOwner(), 1704 BwCalendar.calTypeTrash)); 1704 BwCalendar.calTypeTrash, 1705 true)); 1705 1706 updateEvent(event); 1706 1707 return; … … 1712 1713 1713 1714 // Where does the ref go? Not in the same calendar - we have no access 1714 // Put it in the trash - but don't delete on empty trash1715 1715 1716 1716 BwCalendar cal = getCal().getSpecialCalendar(getUser(), 1717 BwCalendar.calTypeTrash); 1717 BwCalendar.calTypeDeleted, 1718 true); 1718 1719 proxy.setOwner(getUser()); 1719 1720 proxy.setDeleted(true); trunk/calendar3/config/configs/democal.options.xml
r463 r469 38 38 <defaultUserViewName>All</defaultUserViewName> 39 39 40 <publicUser> user</publicUser>40 <publicUser>public-user</publicUser> 41 41 42 42 <httpConnectionsPerUser>10</httpConnectionsPerUser> trunk/calendar3/config/configs/democal.properties
r468 r469 214 214 org.bedework.app.dumpres.description=Bedework dump/restore utility 215 215 org.bedework.app.dumpres.version=3.1 216 org.bedework.app.dumpres.dumpfile=${calendar.dir}/dumprestore/initcaldata.xml217 216 org.bedework.app.dumpres.hibernate.dialect=org.hibernate.dialect.HSQLDialect 218 217 org.bedework.app.dumpres.jdbcdriver=org.hsqldb.jdbcDriver trunk/calendar3/icalendar/src/org/bedework/icalendar/IcalTranslator.java
r418 r469 57 57 import org.bedework.calfacade.BwCalendar; 58 58 import org.bedework.calfacade.BwEvent; 59 import org.bedework.calfacade.BwFreeBusy; 59 60 import org.bedework.calfacade.BwUser; 60 61 import org.bedework.calfacade.CalFacadeException; … … 69 70 import net.fortuna.ical4j.model.Calendar; 70 71 import net.fortuna.ical4j.model.component.VEvent; 72 import net.fortuna.ical4j.model.component.VFreeBusy; 71 73 import net.fortuna.ical4j.model.component.VTimeZone; 72 74 import net.fortuna.ical4j.model.Component; … … 81 83 import java.io.StringWriter; 82 84 import java.io.Serializable; 85 import java.util.ArrayList; 83 86 import java.util.Collection; 84 87 import java.util.HashMap; … … 260 263 } 261 264 262 /** Convert the given string representation of an Icalendar object to an EventVO 263 * 264 * <p>Because an icalendar object can contain 0 or more VEvents we return 265 * a collection of events which may be empty. 265 /** Convert the given string representation of an Icalendar object to a 266 * Collection of Calendar objects 266 267 * 267 268 * @param cal calendar … … 272 273 public Collection fromIcal(BwCalendar cal, String val) throws CalFacadeException { 273 274 return fromIcal(cal, new StringReader(val)); 274 /*275 try {276 CalendarBuilder bldr = new CalendarBuilder(new CalendarParserImpl());277 278 UnfoldingReader ufrdr = new UnfoldingReader(new StringReader(val), true);279 280 //return fromIcal(cal, bldr.build(new UnfoldingReader(new StringReader(val))));281 return fromIcal(cal, bldr.build(ufrdr));282 } catch (ParserException pe) {283 if (debug) {284 error(pe);285 }286 throw new IcalMalformedException(pe.getMessage());287 } catch (CalFacadeException cfe) {288 throw cfe;289 } catch (Throwable t) {290 throw new CalFacadeException(t);291 }*/292 275 } 293 276 … … 326 309 */ 327 310 public Collection fromIcal(BwCalendar cal, Calendar val) throws CalFacadeException { 328 Vector objs = new Vector();311 ArrayList objs = new ArrayList(); 329 312 330 313 if (val == null) { … … 344 327 if (ev != null) { 345 328 objs.add(ev); 329 } 330 } else if (o instanceof VFreeBusy) { 331 BwFreeBusy fb = BwFreeBusyUtil.toFreeBusy(cb, 332 (VFreeBusy)o, 333 debug); 334 335 if (fb != null) { 336 objs.add(fb); 346 337 } 347 338 } else if (o instanceof VTimeZone) {
