Changeset 360
- Timestamp:
- 04/10/06 22:53:39
- Files:
-
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java (modified) (7 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java (modified) (3 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java (modified) (2 diffs)
- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java
r336 r360 82 82 * @throws CalFacadeException 83 83 */ 84 public Calendars(Calintf cal, AccessUtil access, 84 public Calendars(Calintf cal, AccessUtil access, 85 85 int currentMode, boolean debug) 86 86 throws CalFacadeException { … … 178 178 usercal.addChild(cal); 179 179 180 /* Add the deleted calendar */ 181 cal = new BwCalendar(); 182 // XXX new syspar cal.setName(getSyspars().getUserOutbox()); 183 cal.setName("Deleted"); 184 cal.setCreator(user); 185 cal.setOwner(user); 186 cal.setPublick(false); 187 // XXX new syspar cal.setPath(path + "/" + getSyspars().getUserOutbox()); 188 cal.setPath(path + "/" + "Deleted"); 189 cal.setCalendar(usercal); 190 cal.setCalendarCollection(true); 191 usercal.addChild(cal); 192 180 193 sess.save(usercal); 181 194 … … 313 326 } 314 327 328 public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException { 329 StringBuffer sb = new StringBuffer(); 330 331 sb.append("/"); 332 sb.append(getSyspars().getUserCalendarRoot()); 333 sb.append("/"); 334 sb.append(user.getAccount()); 335 sb.append("/"); 336 sb.append("Deleted"); 337 // XXX new syspar sb.append(getSyspars().getDefaultTrashCalendar()); 338 339 return getCalendar(sb.toString()); 340 } 341 342 public void createDeletedCalendar(BwUser user) throws CalFacadeException { 343 StringBuffer sb = new StringBuffer(); 344 345 sb.append("/"); 346 sb.append(getSyspars().getUserCalendarRoot()); 347 sb.append("/"); 348 sb.append(user.getAccount()); 349 350 String pathTo = sb.toString(); 351 352 BwCalendar parent = getCalendar(pathTo); 353 354 if (parent == null) { 355 throw new CalFacadeException("org.bedework.calcore.calendars.unabletocreate"); 356 } 357 358 BwCalendar cal = new BwCalendar(); 359 cal.setName("Deleted"); 360 cal.setOwner(user); 361 cal.setCreator(user); 362 cal.setPublick(parent.getPublick()); 363 cal.setCalendarCollection(true); 364 addCalendar(cal, parent); 365 } 366 315 367 public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException { 316 368 HibSession sess = getSess(); 317 369 318 /* We need write access to the parent */319 access.checkAccess(parent, privWrite , false);370 /* We need write content access to the parent */ 371 access.checkAccess(parent, privWriteContent, false); 320 372 321 373 /** Is the parent a calendar collection? 322 374 */ 323 /* sess.namedQuery("countCalendarEventRefs");324 sess.setEntity("cal", parent);325 326 Integer res = (Integer)sess.getUnique();327 328 if (res.intValue() > 0) {*/329 330 375 if (parent.getCalendarCollection()) { 331 376 throw new CalFacadeException(CalFacadeException.illegalCalendarCreation); … … 352 397 353 398 val.setPath(path); 354 val.setOwner(getUser()); 399 if (val.getOwner() == null) { 400 val.setOwner(getUser()); 401 } 355 402 val.setCalendar(parent); 356 403 parent.addChild(val); … … 427 474 while (it.hasNext()) { 428 475 BwCalendar cal = (BwCalendar)it.next(); 429 CurrentAccess ca = access.checkAccess(cal, desiredAccess, 476 CurrentAccess ca = access.checkAccess(cal, desiredAccess, 430 477 noAccessReturnsNull); 431 478 if (ca != null) { … … 450 497 private BwCalendar cloneAndCheckOne(BwCalendar subroot, int desiredAccess, 451 498 boolean nullForNoAccess) throws CalFacadeException { 452 CurrentAccess ca = access.checkAccess(subroot, desiredAccess, 499 CurrentAccess ca = access.checkAccess(subroot, desiredAccess, 453 500 nullForNoAccess); 454 501 455 502 if (!ca.accessAllowed) { 456 503 return null; … … 460 507 // XXX Temp fix - add id to the clone 461 508 cal.setId(subroot.getId()); 462 509 463 510 cal.setCurrentAccess(ca); 464 511 trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
r356 r360 86 86 87 87 import java.sql.Timestamp; 88 import java.util.ArrayList; 88 89 import java.util.Collection; 89 90 import java.util.TreeSet; … … 860 861 } 861 862 863 public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException { 864 return calendars.getDeletedCalendar(user); 865 } 866 862 867 public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException { 863 868 checkOpen(); … … 1106 1111 1107 1112 public Collection getDeletedProxies() throws CalFacadeException { 1108 return events.getDeletedProxies(this.getTrashCalendar(user)); 1113 BwCalendar cal = this.getDeletedCalendar(user); 1114 1115 if (cal == null) { 1116 // Create the deleted calendar for another time 1117 calendars.createDeletedCalendar(user); 1118 return new ArrayList(); 1119 } 1120 1121 return events.getDeletedProxies(this.getDeletedCalendar(user)); 1109 1122 } 1110 1123 trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java
r356 r360 295 295 * from result sets. 296 296 * 297 * @param cal Trashcalendar object297 * @param cal Deleted calendar object 298 298 * @return Collection of CoreEventInfo objects 299 299 */ trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java
r356 r360 470 470 } 471 471 472 public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException { 473 throw new CalFacadeUnimplementedException(); 474 } 475 472 476 public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException { 473 477 checkOpen(); trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java
r212 r360 106 106 107 107 /** Get the default calendar for the given user. This is determined by the 108 * name for the default calendar assigned to the system, not by any user 108 * name for the default calendar assigned to the system, not by any user 109 109 * preferences. This is normally used at initialisation of a new user. 110 110 * 111 * @param user 111 * @param user 112 112 * @return BwCalendar null for unknown calendar 113 113 * @throws CalFacadeException … … 117 117 /** Get the trash calendar for the given user. 118 118 * 119 * @param user 119 * @param user 120 120 * @return BwCalendar null for unknown calendar 121 121 * @throws CalFacadeException 122 122 */ 123 123 public BwCalendar getTrashCalendar(BwUser user) throws CalFacadeException; 124 125 /** Get the deleted calendar for the given user. This holds annotations 126 * marking other events as deleted 127 * 128 * @param user 129 * @return BwCalendar null for unknown calendar 130 * @throws CalFacadeException 131 */ 132 public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException; 124 133 125 134 /** Add a calendar object trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
r357 r360 1683 1683 // Have write access - just set the flag and move it into the owners trash 1684 1684 event.setDeleted(true); 1685 event.setCalendar(getCal().get TrashCalendar(event.getOwner()));1685 event.setCalendar(getCal().getDeletedCalendar(event.getOwner())); 1686 1686 updateEvent(event); 1687 1687 return; … … 1695 1695 // Put it in the trash - but don't delete on empty trash 1696 1696 1697 BwCalendar cal = getCal().get TrashCalendar(getUser());1697 BwCalendar cal = getCal().getDeletedCalendar(getUser()); 1698 1698 proxy.setOwner(getUser()); 1699 1699 proxy.setDeleted(true);
