Changeset 507
- Timestamp:
- 05/25/06 09:34:51
- Files:
-
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java (modified) (23 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java (modified) (2 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/BwEvent.java (modified) (2 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/BwFreeBusyComponent.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeException.java (modified) (6 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeUtil.java (modified) (5 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java (modified) (47 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java (modified) (5 diffs)
- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CalDavOptionsMethod.java (added)
- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWIntf.java (modified) (3 diffs)
- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWServlet.java (modified) (1 diff)
- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBwNode.java (modified) (2 diffs)
- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavCalNode.java (modified) (1 diff)
- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/MkcalendarMethod.java (modified) (3 diffs)
- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/calquery/FreeBusyQuery.java (modified) (1 diff)
- trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/common/OptionsMethod.java (modified) (3 diffs)
- trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/common/PropPatchMethod.java (modified) (2 diffs)
- trunk/calendar3/caldavClientApi/src/org/bedework/caldav/client/CalintfCaldavImpl.java (modified) (16 diffs)
- trunk/calendar3/caldavClientApi/src/org/bedework/caldav/client/api/CaldavClientIo.java (modified) (6 diffs)
- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (modified) (18 diffs)
- trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java (modified) (3 diffs)
- trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FreeBusyAggregator.java (modified) (3 diffs)
- trunk/calendar3/test/caldavTestData/eg/content/eg02.xml (modified) (1 diff)
- trunk/calendar3/test/caldavTestData/eg/content/eg20.xml (modified) (1 diff)
- trunk/calendar3/test/caldavTestData/eg/eg12.test (modified) (1 diff)
- trunk/calendar3/test/caldavTestData/eg/eg16.test (modified) (1 diff)
- trunk/calendar3/test/caldavTestData/eg/eg17.test (modified) (1 diff)
- trunk/calendar3/test/caldavTestData/eg/eg22.test (added)
- trunk/calendar3/test/src/org/bedework/tests/caldav/Req.java (modified) (4 diffs)
- trunk/calendar3/test/src/org/bedework/tests/caldav/TestCalDav.java (modified) (1 diff)
- trunk/calendar3/webclient/src/org/bedework/webclient/BwFreeBusyAction.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
r477 r507 62 62 import org.bedework.calfacade.BwCategory; 63 63 import org.bedework.calfacade.BwDateTime; 64 import org.bedework.calfacade.BwDuration; 64 65 import org.bedework.calfacade.BwEvent; 66 import org.bedework.calfacade.BwFreeBusy; 67 import org.bedework.calfacade.BwFreeBusyComponent; 65 68 import org.bedework.calfacade.BwLocation; 69 import org.bedework.calfacade.BwPrincipal; 66 70 import org.bedework.calfacade.BwRWStats; 67 71 import org.bedework.calfacade.BwSponsor; … … 76 80 import org.bedework.calfacade.CalFacadeDefs; 77 81 import org.bedework.calfacade.CalFacadeException; 82 import org.bedework.calfacade.CalFacadeUtil; 78 83 import org.bedework.calfacade.CoreEventInfo; 84 import org.bedework.calfacade.CalFacadeUtil.EventPeriod; 85 import org.bedework.calfacade.CalFacadeUtil.GetPeriodsPars; 79 86 import org.bedework.calfacade.base.BwShareableDbentity; 87 import org.bedework.calfacade.base.CalintfBase; 80 88 import org.bedework.calfacade.filter.BwFilter; 81 89 import org.bedework.calfacade.ifs.CalTimezones; 82 import org.bedework.calfacade.ifs.Calintf;83 90 import org.bedework.calfacade.ifs.CalintfInfo; 84 91 import org.bedework.calfacade.ifs.EventsI; 85 92 import org.bedework.calfacade.ifs.Groups; 93 import org.bedework.calfacade.svc.EventInfo; 86 94 import org.bedework.icalendar.IcalTranslator; 87 95 … … 89 97 import java.util.ArrayList; 90 98 import java.util.Collection; 99 import java.util.Iterator; 91 100 import java.util.TreeSet; 92 101 93 102 import net.fortuna.ical4j.model.Calendar; 94 103 import net.fortuna.ical4j.model.Component; 104 import net.fortuna.ical4j.model.DateTime; 105 import net.fortuna.ical4j.model.Period; 95 106 import net.fortuna.ical4j.model.component.VTimeZone; 96 107 … … 131 142 * @author Mike Douglass douglm@rpi.edu 132 143 */ 133 public class CalintfImpl implements Calintf, PrivilegeDefs { 134 private boolean debug; 135 144 public class CalintfImpl extends CalintfBase implements PrivilegeDefs { 136 145 private BwSystem syspars; 137 146 … … 150 159 private AccessUtil access; 151 160 152 /** Ensure we don't open while open153 */154 private boolean isOpen;155 156 /* * This is all the personal calendars modified while the current transaction157 * has been in progress. Just before commit we update the lastmod off all158 * the users on this list.159 * /160 private Vector personalModified;161 */162 163 /** User for whom we maintain this facade164 */165 private BwUser user;166 167 161 private EventsI events; 168 162 … … 174 168 175 169 private EventProperties sponsors; 176 177 private int currentMode = CalintfUtil.guestMode;178 179 /** Non-null if this is for synchronization. Identifies the client end.180 */181 private String synchId;182 170 183 171 /** Prevent updates. … … 213 201 } 214 202 215 private transient Logger log;216 217 /** When we were created for debugging */218 private Timestamp objTimestamp;219 220 203 /* ==================================================================== 221 204 * initialisation … … 225 208 * @see org.bedework.calfacade.Calintf#init(org.bedework.calfacade.BwUser, java.lang.String, boolean, boolean, boolean, java.lang.String, boolean) 226 209 */ 227 public boolean init(String authenticatedUser, 210 public boolean init(String url, 211 String authenticatedUser, 228 212 String user, 229 213 boolean publicAdmin, … … 231 215 String synchId, 232 216 boolean debug) throws CalFacadeException { 233 this.debug = debug; 217 super.init(url, authenticatedUser, user, publicAdmin, 218 groups, synchId, debug); 219 234 220 boolean userCreated = false; 235 221 … … 238 224 try { 239 225 access = new AccessUtil(debug); 240 241 objTimestamp = new Timestamp(System.currentTimeMillis());242 243 this.synchId = synchId;244 log = Logger.getLogger(getClass());245 226 246 227 if ((synchId != null) && publicAdmin) { … … 327 308 } 328 309 310 public void logon(BwUser val) throws CalFacadeException { 311 checkOpen(); 312 Timestamp now = new Timestamp(System.currentTimeMillis()); 313 314 val.setLogon(now); 315 val.setLastAccess(now); 316 sess.update(val); 317 } 318 329 319 public void setSuperUser(boolean val) { 330 320 access.setSuperUser(val); … … 421 411 } 422 412 423 public boolean getDebug() throws CalFacadeException {424 return debug;425 }426 427 public void setUser(String val) throws CalFacadeException {428 refreshEvents();429 430 user = getUser(val);431 if (this.user == null) {432 throw new CalFacadeException("User " + val + " does not exist.");433 }434 435 logon(user);436 437 if (debug) {438 log.debug("User " + val + " set in calintf");439 }440 }441 442 413 /* ==================================================================== 443 414 * Misc methods … … 446 417 public void flushAll() throws CalFacadeException { 447 418 if (debug) { 448 log.debug("flushAll for " + objTimestamp);419 debug("flushAll for " + objTimestamp); 449 420 } 450 421 if (sess == null) { … … 472 443 if (sess == null) { 473 444 if (debug) { 474 log.debug("New hibernate session for " + objTimestamp);475 } 476 sess = new HibSession(sessFactory, log);445 debug("New hibernate session for " + objTimestamp); 446 } 447 sess = new HibSession(sessFactory, getLogger()); 477 448 } else { 478 449 if (debug) { 479 log.debug("Reconnect hibernate session for " + objTimestamp);450 debug("Reconnect hibernate session for " + objTimestamp); 480 451 } 481 452 sess.reconnect(); … … 492 463 if (!isOpen) { 493 464 if (debug) { 494 log.debug("Close for " + objTimestamp + " closed session");465 debug("Close for " + objTimestamp + " closed session"); 495 466 } 496 467 return; … … 498 469 499 470 if (debug) { 500 log.debug("Close for " + objTimestamp);471 debug("Close for " + objTimestamp); 501 472 } 502 473 … … 526 497 // sess.close(); 527 498 if (debug) { 528 log.debug("Begin transaction for " + objTimestamp);499 debug("Begin transaction for " + objTimestamp); 529 500 } 530 501 sess.beginTransaction(); … … 535 506 536 507 if (debug) { 537 log.debug("End transaction for " + objTimestamp);508 debug("End transaction for " + objTimestamp); 538 509 } 539 510 … … 604 575 * Users 605 576 * ==================================================================== */ 606 607 public BwUser getUser() throws CalFacadeException {608 return user;609 }610 577 611 578 public BwUser getUser(int id) throws CalFacadeException { … … 656 623 } 657 624 658 public void updateUser() throws CalFacadeException {659 updateUser(getUser());660 }661 662 625 public void updateUser(BwUser user) throws CalFacadeException { 663 626 checkOpen(); … … 682 645 throw new CalFacadeException("Unimplemented"); 683 646 }*/ 684 685 private void logon(BwUser val) throws CalFacadeException {686 checkOpen();687 Timestamp now = new Timestamp(System.currentTimeMillis());688 689 val.setLogon(now);690 val.setLastAccess(now);691 sess.update(val);692 }693 647 694 648 /* ==================================================================== … … 1079 1033 1080 1034 return sponsors.getRefs(val); 1035 } 1036 1037 /* ==================================================================== 1038 * Free busy 1039 * ==================================================================== */ 1040 1041 public BwFreeBusy getFreeBusy(BwCalendar cal, BwPrincipal who, 1042 BwDateTime start, BwDateTime end, 1043 BwDuration granularity, 1044 boolean returnAll, 1045 boolean ignoreTransparency) 1046 throws CalFacadeException { 1047 if (!(who instanceof BwUser)) { 1048 throw new CalFacadeException("Unsupported: non user principal for free-busy"); 1049 } 1050 1051 Collection events = getFreeBusyEntities(cal, start, end, ignoreTransparency); 1052 BwFreeBusy fb = new BwFreeBusy(who, start, end); 1053 1054 try { 1055 if (granularity != null) { 1056 // chunked. 1057 GetPeriodsPars gpp = new GetPeriodsPars(); 1058 1059 gpp.events = events; 1060 gpp.startDt = start; 1061 gpp.dur = granularity; 1062 gpp.tzcache = getTimezones(); 1063 1064 BwFreeBusyComponent fbc = null; 1065 1066 if (!returnAll) { 1067 // One component 1068 fbc = new BwFreeBusyComponent(); 1069 fb.addTime(fbc); 1070 } 1071 1072 int limit = 10000; // XXX do this better 1073 1074 /* endDt is null first time through, then represents end of last 1075 * segment. 1076 */ 1077 while ((gpp.endDt == null) || (gpp.endDt.before(end))) { 1078 //if (debug) { 1079 // trace("gpp.startDt=" + gpp.startDt + " end=" + end); 1080 //} 1081 if (limit < 0) { 1082 throw new CalFacadeException("org.bedework.svci.limit.exceeded"); 1083 } 1084 limit--; 1085 1086 Collection periodEvents = CalFacadeUtil.getPeriodsEvents(gpp); 1087 1088 if (returnAll) { 1089 fbc = new BwFreeBusyComponent(); 1090 fb.addTime(fbc); 1091 1092 DateTime psdt = new DateTime(gpp.startDt.getDtval()); 1093 DateTime pedt = new DateTime(gpp.endDt.getDtval()); 1094 1095 psdt.setUtc(true); 1096 pedt.setUtc(true); 1097 fbc.addPeriod(new Period(psdt, pedt)); 1098 if (periodEvents.size() == 0) { 1099 fbc.setType(BwFreeBusyComponent.typeFree); 1100 } 1101 } else if (periodEvents.size() != 0) { 1102 /* Some events fall in the period. Add an entry. 1103 * We eliminated cancelled events earler. Now we should set the 1104 * free/busy type based on the events status. 1105 */ 1106 1107 DateTime psdt = new DateTime(gpp.startDt.getDtval()); 1108 DateTime pedt = new DateTime(gpp.endDt.getDtval()); 1109 1110 psdt.setUtc(true); 1111 pedt.setUtc(true); 1112 1113 if (fbc == null) { 1114 fbc = new BwFreeBusyComponent(); 1115 fb.addTime(fbc); 1116 } 1117 1118 fbc.addPeriod(new Period(psdt, pedt)); 1119 } 1120 } 1121 1122 return fb; 1123 } 1124 1125 Iterator it = events.iterator(); 1126 1127 TreeSet eventPeriods = new TreeSet(); 1128 1129 while (it.hasNext()) { 1130 EventInfo ei = (EventInfo)it.next(); 1131 BwEvent ev = ei.getEvent(); 1132 1133 if (BwEvent.statusCancelled.equals(ev.getStatus())) { 1134 // Ignore this one. 1135 continue; 1136 } 1137 1138 // Ignore if times were specified and this event is outside the times 1139 1140 BwDateTime estart = ev.getDtstart(); 1141 BwDateTime eend = ev.getDtend(); 1142 1143 /* Don't report out of the requested period */ 1144 1145 String dstart; 1146 String dend; 1147 1148 if (estart.before(start)) { 1149 dstart = start.getDtval(); 1150 } else { 1151 dstart = estart.getDtval(); 1152 } 1153 1154 if (eend.after(end)) { 1155 dend = end.getDtval(); 1156 } else { 1157 dend = eend.getDtval(); 1158 } 1159 1160 DateTime psdt = new DateTime(dstart); 1161 DateTime pedt = new DateTime(dend); 1162 1163 psdt.setUtc(true); 1164 pedt.setUtc(true); 1165 1166 int type = BwFreeBusyComponent.typeBusy; 1167 1168 if (BwEvent.statusTentative.equals(ev.getStatus())) { 1169 type = BwFreeBusyComponent.typeBusyTentative; 1170 } 1171 1172 eventPeriods.add(new EventPeriod(psdt, pedt, type)); 1173 } 1174 1175 /* iterate through the sorted periods combining them where they are 1176 adjacent or overlap */ 1177 1178 Period p = null; 1179 1180 /* For the moment just build a single BwFreeBusyComponent 1181 */ 1182 BwFreeBusyComponent fbc = null; 1183 int lastType = 0; 1184 1185 it = eventPeriods.iterator(); 1186 while (it.hasNext()) { 1187 EventPeriod ep = (EventPeriod)it.next(); 1188 1189 if (debug) { 1190 trace(ep.toString()); 1191 } 1192 1193 if (p == null) { 1194 p = new Period(ep.getStart(), ep.getEnd()); 1195 lastType = ep.getType(); 1196 } else if ((lastType != ep.getType()) || ep.getStart().after(p.getEnd())) { 1197 // Non adjacent periods 1198 if (fbc == null) { 1199 fbc = new BwFreeBusyComponent(); 1200 fbc.setType(lastType); 1201 fb.addTime(fbc); 1202 } 1203 fbc.addPeriod(p); 1204 1205 if (lastType != ep.getType()) { 1206 fbc = null; 1207 } 1208 1209 p = new Period(ep.getStart(), ep.getEnd()); 1210 lastType = ep.getType(); 1211 } else if (ep.getEnd().after(p.getEnd())) { 1212 // Extend the current period 1213 p = new Period(p.getStart(), ep.getEnd()); 1214 } // else it falls within the existing period 1215 } 1216 1217 if (p != null) { 1218 if ((fbc == null) || (lastType != fbc.getType())) { 1219 fbc = new BwFreeBusyComponent(); 1220 fbc.setType(lastType); 1221 fb.addTime(fbc); 1222 } 1223 fbc.addPeriod(p); 1224 } 1225 } catch (Throwable t) { 1226 if (debug) { 1227 error(t); 1228 } 1229 throw new CalFacadeException(t); 1230 } 1231 1232 return fb; 1081 1233 } 1082 1234 … … 1342 1494 * ==================================================================== */ 1343 1495 1344 private void checkOpen() throws CalFacadeException { 1345 if (!isOpen) { 1346 throw new CalFacadeException("Calintf call when closed"); 1347 } 1348 } 1349 1350 /* Get a logger for messages 1351 */ 1352 private Logger getLogger() { 1353 if (log == null) { 1354 log = Logger.getLogger(this.getClass()); 1355 } 1356 1357 return log; 1358 } 1359 1360 private void trace(String msg) { 1361 getLogger().debug(msg); 1496 private Collection getFreeBusyEntities(BwCalendar cal, 1497 BwDateTime start, BwDateTime end, 1498 boolean ignoreTransparency) 1499 throws CalFacadeException { 1500 Collection evs = getEvents(cal, null, start, end, 1501 CalFacadeDefs.retrieveRecurExpanded, true, 1502 true); 1503 1504 // Filter out transparent and cancelled events 1505 Iterator evit = evs.iterator(); 1506 1507 Collection events = new TreeSet(); 1508 1509 while (evit.hasNext()) { 1510 EventInfo ei = (EventInfo)evit.next(); 1511 BwEvent ev = ei.getEvent(); 1512 1513 if (!ignoreTransparency && 1514 BwEvent.transparencyTransparent.equals(ev.getTransparency())) { 1515 // Ignore this one. 1516 continue; 1517 } 1518 1519 if (BwEvent.statusCancelled.equals(ev.getStatus())) { 1520 // Ignore this one. 1521 continue; 1522 } 1523 1524 events.add(ei); 1525 } 1526 1527 return events; 1362 1528 } 1363 1529 } trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java
r452 r507 1092 1092 // Single leaf calendar - always include 1093 1093 sess.setEntity("calendar", calendar); 1094 if (debug) { 1095 trace("------------Using calendar " + calendar.getPath()); 1096 } 1094 1097 } else { 1095 1098 // Non leaf - add entities … … 1106 1109 // leaf calendar 1107 1110 getSess().setEntity("calendar" + calTerm.i, calendar); 1111 if (debug) { 1112 trace("------------Using calendar " + calendar.getPath()); 1113 } 1108 1114 calTerm.i++; 1109 1115 } trunk/calendar3/calFacade/src/org/bedework/calfacade/BwEvent.java
r464 r507 185 185 186 186 private String link; 187 188 /** Rfc value for a confirmed meeting */ 189 public static final String statusConfirmed = "CONFIRMED"; 190 191 /** Rfc value for a cancelled meeting */ 192 public static final String statusCancelled = "CANCELLED"; 193 194 /** Rfc value for a tentative meeting */ 195 public static final String statusTentative = "TENTATIVE"; 196 187 197 private String status; 188 198 private String cost; … … 985 995 res.setGuid(getGuid()); 986 996 res.setTransparency(getTransparency()); 997 res.setStatus(getStatus()); 987 998 988 999 return res; trunk/calendar3/calFacade/src/org/bedework/calfacade/BwFreeBusyComponent.java
r365 r507 79 79 public static final int typeBusyTentative = 3; 80 80 81 private int type ;81 private int type = typeBusy; 82 82 83 83 /** Collection of Period trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeException.java
r298 r507 62 62 * retrieve a localized message and can also be used to identify the 63 63 * cause of the exception. 64 * 64 * 65 65 * Every CalFacadeException should have one of these as the getMessage() 66 66 * value. 67 67 */ 68 68 69 69 /* ****************** Admin groups ****************************** */ 70 70 71 71 /** The admin group already exists */ 72 72 public static final String duplicateAdminGroup = 73 73 "org.bedework.exception.duplicateadmingroup"; 74 74 75 75 /** The admin group is already on the path to the root (makes a loop) */ 76 76 public static final String alreadyOnAdminGroupPath = … … 78 78 79 79 /* ****************** Calendars ****************************** */ 80 80 81 81 /** Couldn't find calendar */ 82 82 public static final String calendarNotFound = … … 100 100 101 101 /* ****************** Subscriptions ****************************** */ 102 102 103 103 /** Somebody tried to create a duplicate subscription */ 104 104 public static final String duplicateSubscription = … … 109 109 "org.bedework.exception.ical.endandduration"; 110 110 111 /* ****************** Users ****************************** */ 112 113 /** No such account */ 114 public static final String noSuchAccount = 115 "org.bedework.exception.nosuchaccount"; 116 111 117 /* ****************** Events ****************************** */ 112 118 113 119 /** The guid for this event already exists */ 114 120 public static final String duplicateGuid = … … 116 122 117 123 /* ****************** Timezones ****************************** */ 118 124 119 125 /** Error reading timezones */ 120 126 public static final String timezonesReadError = 121 127 "org.bedework.error.timezones.readerror"; 122 128 123 129 /** Unknown timezones */ 124 130 public static final String unknownTimezone = 125 131 "org.bedework.error.unknown.timezone"; 126 132 127 133 /** Bad date */ 128 134 public static final String badDate = … … 134 140 public static final String illegalObjectClass = 135 141 "org.bedework.exception.illegalobjectclass"; 136 142 137 143 private String extra; 138 144 trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeUtil.java
r459 r507 57 57 import org.bedework.calfacade.svc.EventInfo; 58 58 59 import net.fortuna.ical4j.model.DateTime; 59 60 import net.fortuna.ical4j.model.Parameter; 60 61 import net.fortuna.ical4j.model.ParameterList; … … 671 672 //} 672 673 674 EntityRange er = new EntityRange(); 673 675 Iterator it = pars.events.iterator(); 674 676 while (it.hasNext()) { 675 EventInfo ei = (EventInfo)it.next(); 676 BwEvent ev = ei.getEvent(); 677 678 String evStart = ev.getDtstart().getDate(); 679 String evEnd = ev.getDtend().getDate(); 677 er.setEntity(it.next()); 680 678 681 679 /* Event is within range if: … … 688 686 */ 689 687 690 int evstSt = e vStart.compareTo(start);691 int evendSt = e vEnd.compareTo(start);688 int evstSt = er.start.compareTo(start); 689 int evendSt = er.end.compareTo(start); 692 690 693 691 //debugMsg(" event " + evStart + " to " + evEnd); 694 692 695 693 if (((evstSt <= 0) && (evendSt > 0)) || 696 ((evstSt >= 0) && (e vStart.compareTo(end) < 0)) ||694 ((evstSt >= 0) && (er.start.compareTo(end) < 0)) || 697 695 //((evendSt > 0) && (evEnd.compareTo(end) <= 0))) { 698 ((evendSt > 0) && (e vEnd.compareTo(end) < 0))) {696 ((evendSt > 0) && (er.end.compareTo(end) < 0))) { 699 697 // Passed the tests. 700 698 /* … … 704 702 ": " + ev.getSummary()); 705 703 }*/ 706 al.add(e i);704 al.add(er.entity); 707 705 } 708 706 } … … 731 729 return "0" + String.valueOf(val); 732 730 } 731 732 private static class EntityRange { 733 Object entity; 734 735 String start; 736 String end; 737 738 void setEntity(Object o) throws CalFacadeException { 739 entity = o; 740 741 if (o instanceof EventInfo) { 742 EventInfo ei = (EventInfo)o; 743 BwEvent ev = ei.getEvent(); 744 745 start = ev.getDtstart().getDate(); 746 start = ev.getDtend().getDate(); 747 748 return; 749 } 750 751 if (o instanceof EventPeriod) { 752 EventPeriod ep = (EventPeriod)o; 753 754 start = String.valueOf(ep.getStart()); 755 start = String.valueOf(ep.getEnd()); 756 757 return; 758 } 759 760 start = null; 761 end = null; 762 } 763 } 764 765 /** 766 * 767 */ 768 public static class EventPeriod implements Comparable { 769 private DateTime start; 770 private DateTime end; 771 private int type; // from BwFreeBusyComponent 772 773 /** Constructor 774 * 775 * @param start 776 * @param end 777 * @param type 778 */ 779 public EventPeriod(DateTime start, DateTime end, int type) { 780 this.start = start; 781 this.end = end; 782 this.type = type; 783 } 784 785 /** 786 * @return DateTime 787 */ 788 public DateTime getStart() { 789 return start; 790 } 791 792 /** 793 * @return DateTime 794 */ 795 public DateTime getEnd() { 796 return end; 797 } 798 799 /** 800 * @return int 801 */ 802 public int getType() { 803 return type; 804 } 805 806 public int compareTo(Object o) { 807 if (!(o instanceof EventPeriod)) { 808 return -1; 809 } 810 811 EventPeriod that = (EventPeriod)o; 812 813 /* Sort by type first */ 814 if (type < that.type) { 815 return -1; 816 } 817 818 if (type > that.type) { 819 return 1; 820 } 821 822 int res = start.compareTo(that.start); 823 if (res != 0) { 824 return res; 825 } 826 827 return end.compareTo(that.end); 828 } 829 830 public boolean equals(Object o) { 831 return compareTo(o) == 0; 832 } 833 834 public int hashCode() { 835 return 7 * (type + 1) * (start.hashCode() + 1) * (end.hashCode() + 1); 836 } 837 838 public String toString() { 839 StringBuffer sb = new StringBuffer("EventPeriod{start="); 840 841 sb.append(start); 842 sb.append(", end="); 843 sb.append(end); 844 sb.append(", type="); 845 sb.append(type); 846 sb.append("}"); 847 848 return sb.toString(); 849 } 850 } 733 851 } 734 trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java
r477 r507 55 55 56 56 57 import org.bedework.calfacade.BwAlarm; 58 import org.bedework.calfacade.BwCalendar; 59 import org.bedework.calfacade.BwCategory; 60 import org.bedework.calfacade.BwDateTime; 61 import org.bedework.calfacade.BwEvent; 62 import org.bedework.calfacade.BwLocation; 63 import org.bedework.calfacade.BwSponsor; 64 import org.bedework.calfacade.BwStats; 65 import org.bedework.calfacade.BwSynchInfo; 66 import org.bedework.calfacade.BwSynchState; 67 import org.bedework.calfacade.BwSystem; 57 //import org.bedework.calfacade.BwAlarm; 58 //import org.bedework.calfacade.BwCalendar; 59 //import org.bedework.calfacade.BwCategory; 60 //import org.bedework.calfacade.BwDateTime; 61 //import org.bedework.calfacade.BwDuration; 62 //import org.bedework.calfacade.BwEvent; 63 //import org.bedework.calfacade.BwFreeBusy; 64 //import org.bedework.calfacade.BwFreeBusyComponent; 65 //import org.bedework.calfacade.BwLocation; 66 //import org.bedework.calfacade.BwPrincipal; 67 //import org.bedework.calfacade.BwSponsor; 68 //import org.bedework.calfacade.BwStats; 69 //import org.bedework.calfacade.BwSynchInfo; 70 //import org.bedework.calfacade.BwSynchState; 71 //import org.bedework.calfacade.BwSystem; 68 72 import org.bedework.calfacade.BwUser; 69 73 import org.bedework.calfacade.CalFacadeAccessException; 70 import org.bedework.calfacade.CalFacadeUnimplementedException; 74 //import org.bedework.calfacade.CalFacadeDefs; 75 //import org.bedework.calfacade.CalFacadeUnimplementedException; 71 76 import org.bedework.calfacade.CalFacadeException; 77 //import org.bedework.calfacade.CalFacadeUtil; 72 78 import org.bedework.calfacade.CalintfDefs; 73 import org.bedework.calfacade.CoreEventInfo; 74 import org.bedework.calfacade.filter.BwFilter; 75 import org.bedework.calfacade.ifs.CalTimezones; 79 //import org.bedework.calfacade.CoreEventInfo; 80 //import org.bedework.calfacade.CalFacadeUtil.EventPeriod; 81 //import org.bedework.calfacade.CalFacadeUtil.GetPeriodsPars; 82 //import org.bedework.calfacade.filter.BwFilter; 83 //import org.bedework.calfacade.ifs.CalTimezones; 76 84 import org.bedework.calfacade.ifs.Calintf; 77 import org.bedework.calfacade.ifs.CalintfInfo;85 //import org.bedework.calfacade.ifs.CalintfInfo; 78 86 import org.bedework.calfacade.ifs.Groups; 79 80 import edu.rpi.cct.uwcal.access.Acl.CurrentAccess; 87 //import org.bedework.calfacade.svc.EventInfo; 88 89 //import edu.rpi.cct.uwcal.access.Acl.CurrentAccess; 81 90 82 91 import java.sql.Timestamp; 83 import java.util.Collection; 84 import java.util.TreeSet; 85 86 import net.fortuna.ical4j.model.component.VTimeZone; 92 //import java.util.Collection; 93 //import java.util.Iterator; 94 //import java.util.TreeSet; 95 96 //import net.fortuna.ical4j.model.DateTime; 97 //import net.fortuna.ical4j.model.Period; 98 //import net.fortuna.ical4j.model.component.VTimeZone; 87 99 88 100 import org.apache.log4j.Logger; … … 92 104 * @author Mike Douglass douglm@rpi.edu 93 105 */ 94 public class CalintfBase implements Calintf { 106 public abstract class CalintfBase implements Calintf { 107 protected String url; 108 95 109 protected boolean debug; 96 110 … … 110 124 /** Ensure we don't open while open 111 125 */ 112 pr ivateboolean isOpen;126 protected boolean isOpen; 113 127 114 128 /** Ignore owner for superuser … … 125 139 * @see org.bedework.calfacade.Calintf#init(org.bedework.calfacade.BwUser, java.lang.String, boolean, boolean, boolean, java.lang.String, boolean) 126 140 */ 127 public boolean init(String authenticatedUser, 141 public boolean init(String url, 142 String authenticatedUser, 128 143 String user, 129 144 boolean publicAdmin, … … 131 146 String synchId, 132 147 boolean debug) throws CalFacadeException { 148 this.url = url; 133 149 this.debug = debug; 134 150 boolean userCreated = false; … … 153 169 } 154 170 171 public boolean getDebug() throws CalFacadeException { 172 return debug; 173 } 174 175 /* 155 176 public void setSuperUser(boolean val) { 156 177 } … … 160 181 } 161 182 162 /** Get the current stats163 *164 * @return BwStats object165 * @throws CalFacadeException if not admin166 */167 183 public BwStats getStats() throws CalFacadeException { 168 184 return null; … … 190 206 } 191 207 192 /** Get the timezones cache object193 *194 * @return CalTimezones object195 * @throws CalFacadeException if not admin196 */197 208 public CalTimezones getTimezones() throws CalFacadeException { 198 209 return null; … … 206 217 ); 207 218 } 208 209 public boolean getDebug() throws CalFacadeException { 210 return debug; 211 } 219 */ 212 220 213 221 public void setUser(String val) throws CalFacadeException { … … 216 224 user = getUser(val); 217 225 if (this.user == null) { 218 throw new CalFacadeException( "User " + val + " does not exist.");226 throw new CalFacadeException(CalFacadeException.noSuchAccount, val); 219 227 } 220 228 … … 230 238 * ==================================================================== */ 231 239 240 /* 232 241 public void flushAll() throws CalFacadeException { 233 242 if (debug) { … … 235 244 } 236 245 } 246 */ 237 247 238 248 /** Default implementation fails if already open and sets the open flag … … 269 279 } 270 280 281 /* 271 282 public void beginTransaction() throws CalFacadeException { 272 283 checkOpen(); … … 284 295 return null; 285 296 } 297 */ 286 298 287 299 /* ==================================================================== … … 293 305 checkOpen(); 294 306 sess.flush(); 295 } */307 } 296 308 297 309 public void refreshEvents() throws CalFacadeException { … … 299 311 } 300 312 301 /*302 313 public void lockRead(Object val) throws CalFacadeException { 303 314 checkOpen(); … … 315 326 * ==================================================================== */ 316 327 328 /* 317 329 public long getPublicLastmod() throws CalFacadeException { 318 330 checkOpen(); … … 323 335 return ""; 324 336 } 337 */ 325 338 326 339 /* ==================================================================== … … 336 349 } 337 350 351 /* 338 352 public void updateUser(BwUser user) throws CalFacadeException { 339 353 checkOpen(); … … 352 366 } 353 367 354 355 368 public BwUser getUser(String account) throws CalFacadeException { 356 369 checkOpen(); … … 367 380 throw new CalFacadeUnimplementedException(); 368 381 } 382 */ 369 383 370 384 /* ==================================================================== … … 372 386 * ==================================================================== */ 373 387 388 /* 374 389 public void changeAccess(BwShareableDbentity ent, 375 390 Collection aces) throws CalFacadeException { … … 382 397 throw new CalFacadeUnimplementedException(); 383 398 } 399 */ 384 400 385 401 /* ==================================================================== … … 387 403 * ==================================================================== */ 388 404 405 /* 389 406 public void saveTimeZone(String tzid, VTimeZone vtz) throws CalFacadeException { 390 407 throw new CalFacadeUnimplementedException(); … … 407 424 throw new CalFacadeUnimplementedException(); 408 425 } 426 */ 409 427 410 428 /* ==================================================================== … … 412 430 * ==================================================================== */ 413 431 432 /* 414 433 public BwCalendar getPublicCalendars() throws CalFacadeException { 415 434 throw new CalFacadeUnimplementedException(); … … 505 524 throw new CalFacadeUnimplementedException(); 506 525 } 526 */ 507 527 508 528 /* ==================================================================== … … 510 530 * ==================================================================== */ 511 531 532 /* 512 533 public void setSearch(String val) throws CalFacadeException { 513 534 checkOpen(); … … 520 541 } 521 542 522 / *543 / * 523 544 public BwFilter getFilter(String name) throws CalFacadeException { 524 545 checkOpen(); … … 547 568 548 569 return (BwFilter)sess.getUnique(); 549 } */570 } 550 571 551 572 public void addFilter(BwFilter val) throws CalFacadeException { … … 558 579 throw new CalFacadeUnimplementedException(); 559 580 } 581 */ 560 582 561 583 /* ==================================================================== … … 563 585 * ==================================================================== */ 564 586 587 /* 565 588 public Collection getCategories(BwUser owner, BwUser creator) 566 589 throws CalFacadeException { … … 605 628 throw new CalFacadeUnimplementedException(); 606 629 } 630 */ 607 631 608 632 /* ==================================================================== … … 610 634 * ==================================================================== */ 611 635 636 /* 612 637 public Collection getLocations(BwUser owner, BwUser creator) 613 638 throws CalFacadeException { … … 652 677 throw new CalFacadeUnimplementedException(); 653 678 } 679 */ 654 680 655 681 /* ==================================================================== … … 657 683 * ==================================================================== */ 658 684 685 /* 659 686 public Collection getSponsors(BwUser owner, BwUser creator) 660 687 throws CalFacadeException { … … 699 726 throw new CalFacadeUnimplementedException(); 700 727 } 728 */ 701 729 702 730 /* ==================================================================== … … 704 732 * ==================================================================== */ 705 733 734 /* 706 735 public CoreEventInfo getEvent(int id) throws CalFacadeException { 707 736 checkOpen(); … … 746 775 throw new CalFacadeUnimplementedException(); 747 776 } 777 */ 748 778 749 779 /* ==================================================================== … … 753 783 * ==================================================================== */ 754 784 785 /* 755 786 public Collection getEventsByName(BwCalendar cal, String val) 756 787 throws CalFacadeException { … … 758 789 throw new CalFacadeUnimplementedException(); 759 790 } 791 */ 760 792 761 793 /* ==================================================================== … … 763 795 * ==================================================================== */ 764 796 797 /* 765 798 public BwSynchInfo getSynchInfo() throws CalFacadeException { 766 799 checkOpen(); … … 840 873 throw new CalFacadeUnimplementedException(); 841 874 } 875 */ 842 876 843 877 /* ==================================================================== … … 845 879 * ==================================================================== */ 846 880 881 /* 847 882 public Collection getAlarms(BwEvent event, BwUser user) throws CalFacadeException { 848 883 checkOpen(); … … 874 909 throw new CalFacadeUnimplementedException(); 875 910 } 911 */ 876 912 877 913 /* ==================================================================== … … 894 930 protected Logger getLogger() { 895 931 if (log == null) { 896 log = Logger.getLogger( this.getClass());932 log = Logger.getLogger(getClass()); 897 933 } 898 934 … … 904 940 } 905 941 942 protected void error(Throwable t) { 943 getLogger().error(this, t); 944 } 945 906 946 protected void trace(String msg) { 947 getLogger().debug(msg); 948 } 949 950 protected void debug(String msg) { 907 951 getLogger().debug(msg); 908 952 } trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java
r415 r507 55 55 56 56 import org.bedework.calfacade.BwAlarm; 57 import org.bedework.calfacade.BwCalendar; 57 58 import org.bedework.calfacade.BwCategory; 59 import org.bedework.calfacade.BwDateTime; 60 import org.bedework.calfacade.BwDuration; 58 61 import org.bedework.calfacade.BwEvent; 62 import org.bedework.calfacade.BwFreeBusy; 59 63 import org.bedework.calfacade.BwLocation; 64 import org.bedework.calfacade.BwPrincipal; 60 65 import org.bedework.calfacade.BwSponsor; 61 66 import org.bedework.calfacade.BwStats; … … 95 100 /** Must be called to initialise the new object. 96 101 * 102 * @param url String url to which we are connecting 97 103 * @param authenticatedUser String authenticated user of the application 98 104 * or null for guest … … 106 112 * @throws CalFacadeException 107 113 */ 108 public boolean init(String authenticatedUser, 114 public boolean init(String url, 115 String authenticatedUser, 109 116 String user, 110 117 boolean publicAdmin, … … 112 119 String synchId, 113 120 boolean debug) throws CalFacadeException; 121 122 /** Can be called after init to flag the arrival of a user. 123 * 124 * @param val true for a super user 125 * @throws CalFacadeException 126 */ 127 public void logon(BwUser val) throws CalFacadeException; 114 128 115 129 /** Called after init to flag this user as a super user. … … 692 706 */ 693 707 public Collection getSponsorRefs(BwSponsor val) throws CalFacadeException; 708 709 /* ==================================================================== 710 * Free busy 711 * ==================================================================== */ 712 713 /** 714 * @param cal 715 * @param who 716 * @param start 717 * @param end 718 * @param granularity 719 * @param returnAll 720 * @param ignoreTransparency 721 * @return BwFreeBusy object representing the calendar (or principals) 722 * free/busy 723 * @throws CalFacadeException 724 */ 725 public BwFreeBusy getFreeBusy(BwCalendar cal, BwPrincipal who, 726 BwDateTime start, BwDateTime end, 727 BwDuration granularity, 728 boolean returnAll, 729 boolean ignoreTransparency) 730 throws CalFacadeException; 694 731 695 732 /* ==================================================================== trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWIntf.java
r490 r507 1038 1038 try { 1039 1039 /* Deal with webdav properties */ 1040 if (!ns.equals(CaldavDefs.caldavNamespace)) { 1040 if ((!ns.equals(CaldavDefs.caldavNamespace) && 1041 !ns.equals(CaldavDefs.icalNamespace))) { 1041 1042 // Not ours 1042 1043 super.generatePropValue(node, pr); … … 1044 1045 } 1045 1046 1046 if (tag.equals(CaldavTags.calendarDescription)) { 1047 // XXX Change this to have node class generate??? 1048 if (tag.equals(ICalTags.summary)) { 1049 openPropstat(); 1050 xml.property(tag, pr.getPval()); 1051 closePropstat(); 1052 } else if (tag.equals(ICalTags.dtstart)) { 1053 openPropstat(); 1054 xml.property(tag, pr.getPval()); 1055 closePropstat(); 1056 } else if (tag.equals(ICalTags.dtend)) { 1057 openPropstat(); 1058 xml.property(tag, pr.getPval()); 1059 closePropstat(); 1060 } else if (tag.equals(ICalTags.duration)) { 1061 openPropstat(); 1062 xml.property(tag, pr.getPval()); 1063 closePropstat(); 1064 } else if (tag.equals(ICalTags.transp)) { 1065 openPropstat(); 1066 xml.property(tag, pr.getPval()); 1067 closePropstat(); 1068 } else if (tag.equals(ICalTags.due)) { 1069 openPropstat(); 1070 xml.property(tag, pr.getPval()); 1071 closePropstat(); 1072 } else if (tag.equals(ICalTags.status)) { 1073 openPropstat(); 1074 xml.property(tag, pr.getPval()); 1075 closePropstat(); 1076 } else if (tag.equals(ICalTags.uid)) { 1077 openPropstat(); 1078 xml.property(tag, pr.getPval()); 1079 closePropstat(); 1080 } else if (tag.equals(ICalTags.sequence)) { 1081 openPropstat(); 1082 xml.property(tag, pr.getPval()); 1083 closePropstat(); 1084 } else if (tag.equals(ICalTags.hasRecurrence)) { 1085 openPropstat(); 1086 xml.property(tag, pr.getPval()); 1087 closePropstat(); 1088 } else if (tag.equals(ICalTags.hasAlarm)) { 1089 openPropstat(); 1090 xml.property(tag, pr.getPval()); 1091 closePropstat(); 1092 } else if (tag.equals(ICalTags.hasAttachment)) { 1093 openPropstat(); 1094 xml.property(tag, pr.getPval()); 1095 closePropstat(); 1096 } else if (tag.equals(CaldavTags.calendarDescription)) { 1047 1097 if ((cal != null) && (cal.getDescription() != null)) { 1048 1098 // XXX lang … … 1395 1445 } 1396 1446 1447 if (uri.endsWith("/")) { 1448 uri = uri.substring(0, uri.length() - 1); 1449 } 1450 1397 1451 String[] ss = uri.split("/"); 1398 1452 int pathLength = ss.length - 1; // First element is empty string trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWServlet.java
r490 r507 107 107 // Replace methods 108 108 methods.put("MKCALENDAR", new MkcalendarMethod()); 109 methods.put("OPTIONS", new CalDavOptionsMethod()); 109 110 methods.put("REPORT", new ReportMethod()); 110 111 } trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBwNode.java
r2 r507 63 63 import java.io.StringReader; 64 64 import java.io.Reader; 65 import java.util.ArrayList; 65 66 import java.util.Collection; 66 import java.util.Vector;67 67 68 68 /** Class to represent a caldav node. … … 133 133 */ 134 134 public Collection getProperties(String ns) throws WebdavIntfException { 135 return new Vector();135 return new ArrayList(); 136 136 } 137 137 trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavCalNode.java
r472 r507 156 156 VFreeBusy vfreeBusy = VFreeUtil.toVFreeBusy(fb); 157 157 if (vfreeBusy != null) { 158 ical = new Calendar();158 ical = IcalTranslator.newIcal(); 159 159 ical.getComponents().add(vfreeBusy); 160 160 vfreeBusyString = ical.toString(); trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/MkcalendarMethod.java
r491 r507 58 58 59 59 import edu.rpi.cct.webdav.servlet.common.PropPatchMethod; 60 import edu.rpi.cct.webdav.servlet.common.Property;61 60 import edu.rpi.cct.webdav.servlet.shared.WebdavBadRequest; 62 61 import edu.rpi.cct.webdav.servlet.shared.WebdavException; 63 import edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf;64 62 import edu.rpi.cct.webdav.servlet.shared.WebdavNsNode; 65 63 … … 114 112 Document doc) throws WebdavException { 115 113 try { 116 WebdavNsIntf intf = getNsIntf();117 118 114 Element root = doc.getDocumentElement(); 119 115 … … 134 130 Iterator pit = sr.iterator(); 135 131 while (pit.hasNext()) { 136 Property prop = (Property)pit.next(); 132 Element prop = (Element)pit.next(); 133 134 if (nodeMatches(prop, CaldavTags.calendarDescription)) { 135 // Some way to set description 136 } 137 137 } 138 138 } trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/calquery/FreeBusyQuery.java
r490 r507 137 137 throw WebdavIntfException.unauthorized(); 138 138 } 139 BwFreeBusy fb = svci.getFreeBusy(cal, user, 139 140 if (svci.isUserRoot(cal)) { 141 cal = null; 142 } 143 144 BwFreeBusy fb = svci.getFreeBusy(null, cal, user, 140 145 timeRange.getStart(), timeRange.getEnd(), 141 146 null, false); trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/common/OptionsMethod.java
r2 r507 52 52 to the maximum extent the law permits. 53 53 */ 54 55 54 package edu.rpi.cct.webdav.servlet.common; 56 55 … … 91 90 } 92 91 93 if (getNsIntf().getAccessControl()) { 94 resp.addHeader("DAV", "1, 2, access-control"); 95 } else { 96 resp.addHeader("DAV", "1, 2"); 97 } 92 addDavHeader(resp); 98 93 99 94 // Lisa say's we need this … … 119 114 } 120 115 } 116 117 protected void addDavHeader(HttpServletResponse resp) throws WebdavException { 118 if (getNsIntf().getAccessControl()) { 119 resp.addHeader("DAV", "1, 2, 3, access-control"); 120 } else { 121 resp.addHeader("DAV", "1, 2, 3"); 122 } 123 } 121 124 } 122 125 trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/common/PropPatchMethod.java
r490 r507 156 156 Element prop = props[i]; 157 157 158 String ns = prop.getNamespaceURI();159 String nm = prop.getLocalName();160 158 String value = getElementContent(prop); 161 159 … … 164 162 } 165 163 166 plist.add( new Property(ns, nm, value));164 plist.add(prop); 167 165 168 166 if (debug) { 169 trace("reqtype: " + nm + " ns: " + ns + " value: " + value); 167 trace("reqtype: " + prop.getLocalName() + 168 " ns: " + prop.getNamespaceURI() + 169 " value: " + value); 170 170 } 171 171 } trunk/calendar3/caldavClientApi/src/org/bedework/caldav/client/CalintfCaldavImpl.java
r466 r507 59 59 import org.bedework.calfacade.BwCategory; 60 60 import org.bedework.calfacade.BwDateTime; 61 import org.bedework.calfacade.BwDuration; 61 62 import org.bedework.calfacade.BwEvent; 63 import org.bedework.calfacade.BwFreeBusy; 62 64 import org.bedework.calfacade.BwLocation; 65 import org.bedework.calfacade.BwPrincipal; 63 66 import org.bedework.calfacade.BwSponsor; 64 67 import org.bedework.calfacade.BwStats; 68 import org.bedework.calfacade.BwSystem; 65 69 import org.bedework.calfacade.CoreEventInfo; 66 70 //import org.bedework.calfacade.BwSynchData; … … 110 114 * @see org.bedework.calfacade.Calintf#init(org.bedework.calfacade.BwUser, java.lang.String, boolean, boolean, boolean, java.lang.String, boolean) 111 115 */ 112 public boolean init(String authenticatedUser, 116 public boolean init(String url, 117 String authenticatedUser, 113 118 String user, 114 119 boolean publicAdmin, … … 116 121 String synchId, 117 122 boolean debug) throws CalFacadeException { 118 boolean userAdded = super.init( authenticatedUser, user, publicAdmin,123 boolean userAdded = super.init(url, authenticatedUser, user, publicAdmin, 119 124 groups, synchId, debug); 120 125 … … 130 135 } 131 136 132 /** Get the current stats 133 * 134 * @return BwStats object 135 * @throws CalFacadeException if not admin 136 */ 137 public void logon(BwUser val) throws CalFacadeException { 138 checkOpen(); 139 throw new CalFacadeUnimplementedException(); 140 } 141 142 public void setSuperUser(boolean val) { 143 } 144 145 public boolean getSuperUser() { 146 return false; 147 } 148 137 149 public BwStats getStats() throws CalFacadeException { 138 150 return null; 139 151 } 140 152 141 /** Get the timezones cache object 142 * 143 * @return CalTimezones object 144 * @throws CalFacadeException if not admin 145 */ 153 public void setDbStatsEnabled(boolean enable) throws CalFacadeException { 154 } 155 156 public boolean getDbStatsEnabled() throws CalFacadeException { 157 return false; 158 } 159 160 public void dumpDbStats() throws CalFacadeException { 161 } 162 163 public Collection getDbStats() throws CalFacadeException { 164 return null; 165 } 166 167 public BwSystem getSyspars() throws CalFacadeException { 168 return null; 169 } 170 171 public void updateSyspars(BwSystem val) throws CalFacadeException { 172 } 173 146 174 public CalTimezones getTimezones() throws CalFacadeException { 147 175 return null; … … 150 178 public CalintfInfo getInfo() throws CalFacadeException { 151 179 return info; 152 }153 154 public boolean getDebug() throws CalFacadeException {155 return debug;156 180 } 157 181 … … 181 205 } 182 206 183 public synchronized void open() throws CalFacadeException {184 super.open();185 }186 187 public synchronized void close() throws CalFacadeException {188 super.close();189 }190 191 207 public void beginTransaction() throws CalFacadeException { 192 208 checkOpen(); … … 209 225 * ==================================================================== */ 210 226 211 /*212 public void refresh() throws CalFacadeException {213 checkOpen();214 sess.flush();215 }*/216 217 227 public void refreshEvents() throws CalFacadeException { 218 228 checkOpen(); 219 229 } 220 221 /*222 public void lockRead(Object val) throws CalFacadeException {223 checkOpen();224 sess.lockRead(val);225 }226 227 public void lockMod(Object val) throws CalFacadeException {228 checkOpen();229 sess.lockUpdate(val);230 }231 */232 230 233 231 /* ==================================================================== … … 248 246 * ==================================================================== */ 249 247 250 public BwUser getUser() throws CalFacadeException { 251 return user; 248 public void updateUser(BwUser user) throws CalFacadeException { 249 checkOpen(); 250 throw new CalFacadeUnimplementedException(); 251 } 252 253 public void addUser(BwUser user) throws CalFacadeException { 254 checkOpen(); 255 256 throw new CalFacadeUnimplementedException(); 252 257 } 253 258 … … 257 262 } 258 263 259 260 264 public BwUser getUser(String user) throws CalFacadeException { 261 265 checkOpen(); … … 263 267 } 264 268 265 public void addUser(BwUser user) throws CalFacadeException { 266 checkOpen(); 267 268 throw new CalFacadeUnimplementedException(); 269 } 270 271 public void updateUser() throws CalFacadeException { 272 updateUser(getUser()); 273 } 274 275 public void updateUser(BwUser user) throws CalFacadeException { 276 checkOpen(); 277 throw new CalFacadeUnimplementedException(); 278 } 279 280 /* 281 public void deleteUser(BwUser user) throws CalFacadeException { 282 checkOpen(); 283 throw new CalFacadeException("Unimplemented"); 284 }*/ 285 286 private void logon(BwUser val) throws CalFacadeException { 269 public Collection getInstanceOwners() throws CalFacadeException { 287 270 checkOpen(); 288 271 throw new CalFacadeUnimplementedException(); … … 345 328 346 329 public BwCalendar getCalendars() throws CalFacadeException { 330 throw new CalFacadeUnimplementedException(); 331 } 332 333 public BwCalendar getCalendars(BwUser user, 334 int desiredAccess) throws CalFacadeException { 347 335 throw new CalFacadeUnimplementedException(); 348 336 } … … 389 377 } 390 378 379 public BwCalendar getSpecialCalendar(BwUser user, 380 int calType, 381 boolean create) throws CalFacadeException { 382 throw new CalFacadeUnimplementedException(); 383 } 384 391 385 public void addCalendar(BwCalendar val, String parentPath) throws CalFacadeException { 392 386 checkOpen(); … … 396 390 397 391 public void updateCalendar(BwCalendar val) throws CalFacadeException { 392 checkOpen(); 393 throw new CalFacadeUnimplementedException(); 394 } 395 396 public void changeAccess(BwCalendar cal, 397 Collection aces) throws CalFacadeException { 398 398 checkOpen(); 399 399 throw new CalFacadeUnimplementedException(); … … 573 573 checkOpen(); 574 574 575 throw new CalFacadeUnimplementedException(); 576 } 577 578 /* ==================================================================== 579 * Free busy 580 * ==================================================================== */ 581 582 public BwFreeBusy getFreeBusy(BwCalendar cal, BwPrincipal who, 583 BwDateTime start, BwDateTime end, 584 BwDuration granularity, 585 boolean returnAll, 586 boolean ignoreTransparency) 587 throws CalFacadeException { 575 588 throw new CalFacadeUnimplementedException(); 576 589 } … … 615 628 } 616 629 630 public Collection getDeletedProxies() throws CalFacadeException { 631 throw new CalFacadeUnimplementedException(); 632 } 633 634 public Collection getDeletedProxies(BwCalendar cal) throws CalFacadeException { 635 throw new CalFacadeUnimplementedException(); 636 } 637 617 638 /* ==================================================================== 618 639 * Caldav support … … 742 763 throw new CalFacadeUnimplementedException(); 743 764 } 765 766 /* ==================================================================== 767 * Free busy 768 * ==================================================================== */ 744 769 } 745 770 trunk/calendar3/caldavClientApi/src/org/bedework/caldav/client/api/CaldavClientIo.java
r490 r507 57 57 import org.bedework.calfacade.CalFacadeException; 58 58 import org.bedework.http.client.caldav.CaldavClient; 59 import org.bedework.http.client.DepthHttpMethod; 59 60 import org.bedework.http.client.HttpManager; 60 61 … … 135 136 * @param url 136 137 * @param hdrs 138 * @param depth 137 139 * @param contentType 138 140 * @param contentLen … … 142 144 */ 143 145 public int sendRequest(String method, String url, 144 Header[] hdrs, String contentType, int contentLen, 146 Header[] hdrs, int depth, 147 String contentType, int contentLen, 145 148 byte[] content) throws Throwable { 146 return sendRequest(method, url, null, null, hdrs, contentType, contentLen, content); 149 return sendRequest(method, url, null, null, hdrs, depth, 150 contentType, contentLen, content); 147 151 } 148 152 … … 154 158 * @param pw 155 159 * @param hdrs 160 * @param depth 156 161 * @param contentType 157 162 * @param contentLen … … 161 166 */ 162 167 public int sendRequest(String method, String url, String user, String pw, 163 Header[] hdrs, String contentType, int contentLen, 168 Header[] hdrs, int depth, 169 String contentType, int contentLen, 164 170 byte[] content) throws Throwable { 165 171 int sz = 0; … … 175 181 176 182 HttpMethod meth = client.getMethod(); 183 184 if (meth instanceof DepthHttpMethod) { 185 ((DepthHttpMethod)meth).setDepth(depth); 186 } 177 187 178 188 if (user != null) { trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
r501 r507 730 730 } 731 731 732 public boolean isUserRoot(BwCalendar cal) throws CalFacadeException { 733 if (cal == null) { 734 return false; 735 } 736 737 String[] ss = cal.getPath().split("/"); 738 int pathLength = ss.length - 1; // First element is empty string 739 740 return (pathLength == 2) && 741 (ss[1].equals(getSyspars().getUserCalendarRoot())); 742 } 743 732 744 /* ==================================================================== 733 745 * Views … … 1022 1034 * ==================================================================== */ 1023 1035 1024 public BwFreeBusy getFreeBusy(BwCalendar cal, BwPrincipal who, 1036 public BwFreeBusy getFreeBusy(Collection subs, 1037 BwCalendar cal, BwPrincipal who, 1025 1038 BwDateTime start, BwDateTime end, 1026 1039 BwDuration granularity, … … 1032 1045 1033 1046 BwUser u = (BwUser)who; 1034 Collection subs; 1035 1036 /* See if the calendar is a user root. */ 1037 1038 if (cal != null) { 1039 String[] ss = cal.getPath().split("/"); 1040 int pathLength = ss.length - 1; // First element is empty string 1041 1042 if ((pathLength == 2) && 1043 (ss[1].equals(getSyspars().getUserCalendarRoot()))) { 1044 cal = null; 1045 } 1046 } 1047 1048 if (cal != null) { 1047 1048 if (subs != null) { 1049 // Use these 1050 } else if (cal != null) { 1049 1051 getCal().checkAccess(cal, PrivilegeDefs.privReadFreeBusy, false); 1050 1052 … … 1092 1094 if (!sub.getIgnoreTransparency() && 1093 1095 BwEvent.transparencyTransparent.equals(ev.getTransparency())) { 1096 // Ignore this one. 1097 continue; 1098 } 1099 1100 if (BwEvent.statusCancelled.equals(ev.getStatus())) { 1094 1101 // Ignore this one. 1095 1102 continue; … … 1148 1155 } 1149 1156 } else if (periodEvents.size() != 0) { 1150 // Some events fall in the period. Add an entry. 1157 /* Some events fall in the period. Add an entry. 1158 * We eliminated cancelled events earler. Now we should set the 1159 * free/busy type based on the events status. 1160 */ 1151 1161 1152 1162 DateTime psdt = new DateTime(gpp.startDt.getDtval()); … … 1155 1165 psdt.setUtc(true); 1156 1166 pedt.setUtc(true); 1167 1168 if (fbc == null) { 1169 fbc = new BwFreeBusyComponent(); 1170 fb.addTime(fbc); 1171 } 1172 1157 1173 fbc.addPeriod(new Period(psdt, pedt)); 1158 1174 } … … 1169 1185 EventInfo ei = (EventInfo)it.next(); 1170 1186 BwEvent ev = ei.getEvent(); 1187 1188 if (BwEvent.statusCancelled.equals(ev.getStatus())) { 1189 // Ignore this one. 1190 continue; 1191 } 1171 1192 1172 1193 // Ignore if times were specified and this event is outside the times … … 1198 1219 pedt.setUtc(true); 1199 1220 1200 eventPeriods.add(new EventPeriod(psdt, pedt)); 1221 int type = BwFreeBusyComponent.typeBusy; 1222 1223 if (BwEvent.statusTentative.equals(ev.getStatus())) { 1224 type = BwFreeBusyComponent.typeBusyTentative; 1225 } 1226 1227 eventPeriods.add(new EventPeriod(psdt, pedt, type)); 1201 1228 } 1202 1229 … … 1209 1236 */ 1210 1237 BwFreeBusyComponent fbc = null; 1238 int lastType = 0; 1211 1239 1212 1240 it = eventPeriods.iterator(); … … 1214 1242 EventPeriod ep = (EventPeriod)it.next(); 1215 1243 1244 if (debug) { 1245 trace(ep.toString()); 1246 } 1247 1216 1248 if (p == null) { 1217 1249 p = new Period(ep.start, ep.end); 1218 } else if (ep.start.after(p.getEnd())) { 1250 lastType = ep.type; 1251 } else if ((lastType != ep.type) || ep.start.after(p.getEnd())) { 1219 1252 // Non adjacent periods 1220 1253 if (fbc == null) { 1221 1254 fbc = new BwFreeBusyComponent(); 1255 fbc.setType(lastType); 1256 fb.addTime(fbc); 1222 1257 } 1223 1258 fbc.addPeriod(p); 1259 1260 if (lastType != ep.type) { 1261 fbc = null; 1262 } 1263 1224 1264 p = new Period(ep.start, ep.end); 1265 lastType = ep.type; 1225 1266 } else if (ep.end.after(p.getEnd())) { 1226 1267 // Extend the current period … … 1230 1271 1231 1272 if (p != null) { 1232 if ( fbc == null) {1273 if ((fbc == null) || (lastType != fbc.getType())) { 1233 1274 fbc = new BwFreeBusyComponent(); 1275 fbc.setType(lastType); 1276 fb.addTime(fbc); 1234 1277 } 1235 1278 fbc.addPeriod(p); 1236 1279 } 1237 1238 if (fbc != null) {1239 fb.addTime(fbc);1240 }1241 1280 } catch (Throwable t) { 1281 if (debug) { 1282 error(t); 1283 } 1242 1284 throw new CalFacadeException(t); 1243 1285 } … … 1249 1291 DateTime start; 1250 1292 DateTime end; 1251 1252 EventPeriod(DateTime start, DateTime end) { 1293 int type; // from BwFreeBusyComponent 1294 1295 EventPeriod(DateTime start, DateTime end, int type) { 1253 1296 this.start = start; 1254 1297 this.end = end; 1298 this.type = type; 1255 1299 } 1256 1300 … … 1262 1306 EventPeriod that = (EventPeriod)o; 1263 1307 1308 /* Sort by type first */ 1309 if (type < that.type) { 1310 return -1; 1311 } 1312 1313 if (type > that.type) { 1314 return 1; 1315 } 1316 1264 1317 int res = start.compareTo(that.start); 1265 1318 if (res != 0) { … … 1268 1321 1269 1322 return end.compareTo(that.end); 1323 } 1324 1325 public boolean equals(Object o) { 1326 return compareTo(o) == 0; 1327 } 1328 1329 public int hashCode() { 1330 return 7 * (type + 1) * (start.hashCode() + 1) * (end.hashCode() + 1); 1331 } 1332 1333 public String toString() { 1334 StringBuffer sb = new StringBuffer("EventPeriod{start="); 1335 1336 sb.append(start); 1337 sb.append(", end="); 1338 sb.append(end); 1339 sb.append(", type="); 1340 sb.append(type); 1341 sb.append("}"); 1342 1343 return sb.toString(); 1270 1344 } 1271 1345 } … … 1921 1995 // Explicitly selected calendar - via a subscription. 1922 1996 1923 return postProcess(getCal( ).getEvents(sub.getCalendar(), filter, startDate,1924 endDate, recurRetrieval,1925 freeBusy, true),1997 return postProcess(getCal(sub).getEvents(sub.getCalendar(), filter, 1998 startDate, endDate, 1999 recurRetrieval, freeBusy, true), 1926 2000 sub); 1927 2001 } … … 2212 2286 }*/ 2213 2287 2288 /* This will get a calintf based on the subscription uri. 2289 */ 2290 Calintf getCal(BwSubscription sub) throws CalFacadeException { 2291 return getCal(); 2292 } 2293 2294 /* Currently this gets a local calintf only. Later we need to use a par to 2295 * get calintf from a table. 2296 */ 2214 2297 Calintf getCal() throws CalFacadeException { 2215 2298 if (cali != null) { … … 2227 2310 cali.beginTransaction(); 2228 2311 2229 boolean userCreated = cali.init(pars.getAuthUser(), 2312 boolean userCreated = cali.init(null, 2313 pars.getAuthUser(), 2230 2314 pars.getUser(), 2231 2315 pars.getPublicAdmin(), … … 2549 2633 getLogger().debug(msg); 2550 2634 } 2635 2636 private void error(Throwable t) { 2637 getLogger().error(this, t); 2638 } 2551 2639 } 2552 2640 trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java
r501 r507 612 612 public abstract int deleteCalendar(BwCalendar val) throws CalFacadeException; 613 613 614 /** Return true if cal != null and it represents a (local) user root 615 * 616 * @param cal 617 * @return boolean 618 * @throws CalFacadeException 619 */ 620 public abstract boolean isUserRoot(BwCalendar cal) throws CalFacadeException; 621 614 622 /* ==================================================================== 615 623 * Views … … 812 820 * events fall in the segment. 813 821 * 814 * @param cal Calendar to provide free-busy for. Null or the user root 822 * @param subs If non-null use these as the subscriptions. 823 * @param cal Calendar to provide free-busy for. Null for the user root 815 824 * for default collection (as specified by user). 816 * @param who 825 * Used for local access to a given calendar via e.g. caldav 826 * @param who If sub and cal are null get the info for this user, otherwise 827 * this si used as the free/busy result owner 817 828 * @param start 818 829 * @param end … … 825 836 * @throws CalFacadeException 826 837 */ 827 public abstract BwFreeBusy getFreeBusy(BwCalendar cal, BwPrincipal who, 838 public abstract BwFreeBusy getFreeBusy(Collection subs, 839 BwCalendar cal, BwPrincipal who, 828 840 BwDateTime start, BwDateTime end, 829 841 BwDuration granularity, trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FreeBusyAggregator.java
r490 r507 134 134 // req.addContentLine(" end=\"" + 135 135 // CalFacadeUtil.isoDateTimeUTC(end) + "\"/>"); 136 req.addContentLine(" <C:time-range start=\"20060 521T131358Z\"");137 req.addContentLine(" end=\"20060 528T131358Z\"/>");136 req.addContentLine(" <C:time-range start=\"20060601T131358Z\""); 137 req.addContentLine(" end=\"20060631T131358Z\"/>"); 138 138 req.addContentLine("</C:free-busy-query>"); 139 139 … … 158 158 "/ucaldav/user/johnsa")); 159 159 */ 160 160 /* 161 161 addUser(new UserInfo("testuser02", "bedework", "testuser02", 162 162 "www.bedework.org", 80, false, 163 163 "/ucaldav/user/testuser02")); 164 addUser(new UserInfo("testuser03", "bedework", "testuser03", 164 */ 165 addUser(new UserInfo("douglm", "bedework", "douglm", 166 "localhost", 8080, false, 167 "/ucaldav/user/douglm")); 168 /* 169 addUser(new UserInfo("testuser02", "bedework", "testuser02", 165 170 "www.bedework.org", 80, false, 166 "/ucaldav/user/testuser03")); 167 171 "/ucaldav/user/testuser02")); 172 addUser(new UserInfo("testuser08", "bedework", "testuser08", 173 "www.bedework.org", 80, false, 174 "/ucaldav/user/testuser08")); 175 */ 168 176 getSvci(); // 169 177 } … … 185 193 if (r.getAuth()) { 186 194 resp.responseCode = cio.sendRequest(r.getMethod(), r.getUrl(), 187 r.getUser(), r.getPw(), r.getHeaders(), 195 r.getUser(), r.getPw(), 196 r.getHeaders(), 0, 188 197 r.getContentType(), 189 198 r.getContentLength(), r.getContentBytes()); 190 199 } else { 191 resp.responseCode = cio.sendRequest(r.getMethod(), r.getUrl(), r.getHeaders(), 200 resp.responseCode = cio.sendRequest(r.getMethod(), r.getUrl(), 201 r.getHeaders(), 0, 192 202 r.getContentType(), r.getContentLength(), 193 203 r.getContentBytes()); trunk/calendar3/test/caldavTestData/eg/content/eg02.xml
r2 r507 30 30 <C:comp-filter name="VCALENDAR"> 31 31 <C:comp-filter name="VEVENT"> 32 <C:time-range start="200 50402T000000Z"33 end="200 50602T235959Z"/>32 <C:time-range start="20060601T000000Z" 33 end="20060630T235959Z"/> 34 34 </C:comp-filter> 35 35 </C:comp-filter> trunk/calendar3/test/caldavTestData/eg/content/eg20.xml
r423 r507 1 1 <?xml version="1.0" encoding="utf-8" ?> 2 2 <C:free-busy-query xmlns:C="urn:ietf:params:xml:ns:caldav"> 3 <C:time-range start="@NOW@" 4 end="@NEXTWEEK@"/> 3 <C:time-range start="20060601T131358Z" 4 end="20060701T131358Z"/> 5 <!-- <C:time-range start="@NOW@" 6 end="@NEXTWEEK@"/> --> 5 7 </C:free-busy-query> 6 8 trunk/calendar3/test/caldavTestData/eg/eg12.test
r2 r507 14 14 <?xml version="1.0" encoding="utf-8" ?> 15 15 <C:free-busy-query xmlns:C="urn:ietf:params:xml:ns:caldav"> 16 <C:time-range start="200 50701T000000Z"17 end="200 50731T240000Z"/>16 <C:time-range start="20060401T000000Z" 17 end="20060731T240000Z"/> 18 18 </C:free-busy-query> 19 19 trunk/calendar3/test/caldavTestData/eg/eg16.test
r2 r507 5 5 AUTH: true 6 6 7 URL: newcol7 URL: RPI_TEST 8 8 trunk/calendar3/test/caldavTestData/eg/eg17.test
r2 r507 5 5 AUTH: true 6 6 7 URL: newcol/newcalendar7 URL: RPI_TEST/RPI_TEST/ 8 8 trunk/calendar3/test/src/org/bedework/tests/caldav/Req.java
r420 r507 74 74 String description; 75 75 Header[] hdrs; 76 int depth; 76 77 String contentType; 77 78 String[] content; … … 89 90 static final String exprespHdr = "EXPECT-RESPONSE: "; 90 91 static final String methHdr = "METHOD: "; 92 static final String depthHdr = "DEPTH: "; 91 93 static final String authHdr = "AUTH: "; 92 94 static final String urlHdr = "URL: "; … … 141 143 */ 142 144 method = ln.substring(methHdr.length()); 145 } else if (ln.startsWith(depthHdr)) { 146 /* 147 DEPTH 148 */ 149 depth = Integer.valueOf(ln.substring(depthHdr.length())).intValue(); 143 150 } else if (ln.startsWith(authHdr)) { 144 151 /* … … 262 269 263 270 /** 271 * @return int 272 */ 273 public int getDepth() { 274 return depth; 275 } 276 277 /** 264 278 * @return String 265 279 */ trunk/calendar3/test/src/org/bedework/tests/caldav/TestCalDav.java
r464 r507 365 365 if (r.getAuth()) { 366 366 respCode = cio.sendRequest(r.getMethod(), r.getPrefixedUrl(), 367 user, pw, r.getHdrs(), r.getContentType(), 367 user, pw, r.getHdrs(), r.getDepth(), 368 r.getContentType(), 368 369 r.getContentLength(), r.getContentBytes()); 369 370 } else { 370 respCode = cio.sendRequest(r.getMethod(), r.getPrefixedUrl(), r.getHdrs(), 371 respCode = cio.sendRequest(r.getMethod(), r.getPrefixedUrl(), 372 r.getHdrs(), r.getDepth(), 371 373 r.getContentType(), r.getContentLength(), 372 374 r.getContentBytes()); trunk/calendar3/webclient/src/org/bedework/webclient/BwFreeBusyAction.java
r480 r507 78 78 * <p>Request parameters - all optional:<ul> 79 79 * <li> userid: whose free busy we want - default to current user</li>. 80 * <li> calendar: name of the calendar- default to subscriptions80 * <li> subname: name of the subscription - default to subscriptions 81 81 * specified by user</li>. 82 82 * <li> start: start of period - default to beginning of this week</li>. … … 203 203 204 204 try { 205 BwFreeBusy fb = svci.getFreeBusy(null, user,205 BwFreeBusy fb = svci.getFreeBusy(null, null, user, 206 206 CalFacadeUtil.getDateTime(sdt, false, false, tzs), 207 207 CalFacadeUtil.getDateTime(edt, false, false, tzs),
