Changeset 493
- Timestamp:
- 05/18/06 15:27:43
- Files:
-
- trunk/calendar3/http/src/org/bedework/http/client/caldav/MkcalendarMethod.java (added)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java (modified) (11 diffs)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/misc/SetSelectionAction.java (modified) (1 diff)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/EndSubscribeAction.java (modified) (6 diffs)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/InitSubscribeAction.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java
r490 r493 74 74 import org.bedework.calfacade.svc.BwAuthUserPrefs; 75 75 import org.bedework.calfacade.svc.BwSubscription; 76 import org.bedework.calfacade.svc.BwView; 76 77 import org.bedework.calfacade.svc.EventInfo; 77 78 import org.bedework.calfacade.svc.UserAuth; … … 84 85 import edu.rpi.sss.util.jsp.UtilActionForm; 85 86 87 import java.util.ArrayList; 86 88 import java.util.Collection; 87 89 import java.util.Iterator; … … 107 109 private static final String appNameInitParameter = "rpiappname"; 108 110 111 /* These are all the possible forwards we take. Internal routines should 112 * return one of the following indices. 113 */ 114 // ENUM 115 protected int forwardSuccess = 0; 116 protected int forwardContinue = 1; 117 protected int forwardRetry = 2; 118 119 protected int forwardError = 3; 120 protected int forwardNoAccess = 4; 121 122 protected int forwardNotFound = 5; 123 124 protected int forwardNoSuchView = 6; 125 126 /* Set when an optional parameter is not found */ 127 protected int forwardNoParameter = 7; 128 129 /* Set when no action was taken */ 130 protected int forwardNoAction = 8; 131 132 /* Something is referenced and cannot be removed */ 133 protected int forwardReffed = 9; 134 135 /* an object was added/updated */ 136 protected int forwardAdded = 10; 137 protected int forwardUpdated = 11; 138 139 protected final String[] forwards = { 140 "success", 141 "continue", 142 "retry", 143 "error", 144 "noAccess", 145 "notFound", 146 "noSuchView", 147 "noParameter", 148 "noAction", 149 "reffed", 150 "added", 151 "updated", 152 }; 153 154 /* 155 * (non-Javadoc) 156 * @see edu.rpi.sss.util.jsp.UtilAbstractAction#getId() 157 */ 109 158 public String getId() { 110 159 return getClass().getName(); … … 282 331 } 283 332 333 /* Reset the current selection. Called after updates to views, subscriptions 334 * or calendars. 335 */ 336 protected void resetSelection(BwActionFormBase form) throws CalFacadeException { 337 String seltype = form.getSelectionType(); 338 CalSvcI svci = form.fetchSvci(); 339 String name = null; 340 341 if (seltype.equals(BedeworkDefs.selectionTypeView)) { 342 BwView v = svci.getCurrentView(); 343 if (v != null) { 344 name = v.getName(); 345 } 346 setView(name, form); 347 } else if (seltype.equals(BedeworkDefs.selectionTypeSubscription)) { 348 // No refresh needed? 349 } else if (seltype.equals(BedeworkDefs.selectionTypeCalendar)) { 350 // No refresh needed? 351 } else { 352 // Set to default 353 setView(null, form); 354 } 355 } 356 284 357 /* Set the view to the given name or the default if null. 285 358 * … … 307 380 form.refreshIsNeeded(); 308 381 return true; 382 } 383 384 /* Set the subscription to the given name or the default if null. 385 * 386 * @return int result code 387 */ 388 protected int setSubscription(String name, 389 BwActionFormBase form) throws CalFacadeException { 390 CalSvcI svci = form.fetchSvci(); 391 392 if (name == null) { 393 return forwardNoParameter; 394 } 395 396 BwSubscription sub = svci.findSubscription(name); 397 398 if (sub == null) { 399 form.getErr().emit("org.bedework.client.error.unknownsubscription"); 400 return forwardNotFound; 401 } 402 403 Collection c = new ArrayList(); 404 c.add(sub.clone()); 405 svci.setCurrentSubscriptions(c); 406 form.assignCurrentSubscriptions(c); 407 form.setSelectionType(BedeworkDefs.selectionTypeSubscription); 408 409 form.refreshIsNeeded(); 410 return forwardSuccess; 309 411 } 310 412 … … 379 481 * @param sub 380 482 * @param form 381 * @return String "added" for added, "updated" for updated.483 * @return int result code 382 484 * @throws Throwable 383 485 */ 384 protected StringfinishSubscribe(HttpServletRequest request,486 protected int finishSubscribe(HttpServletRequest request, 385 487 BwSubscription sub, 386 488 BwActionFormBase form) throws Throwable { 387 489 CalSvcI svc = form.fetchSvci(); 388 String forward;490 int result; 389 491 390 492 String viewName = getReqPar(request, "view"); … … 402 504 if (bool != null) { 403 505 if (!form.getUserAuth().isSuperUser()) { 404 return "noAccess"; // Only super user for that flag506 return forwardNoAccess; // Only super user for that flag 405 507 } 406 508 … … 409 511 410 512 if (!validateSub(sub, form)) { 411 return "retry";513 return forwardRetry; 412 514 } 413 515 … … 415 517 try { 416 518 svc.addSubscription(sub); 417 forward = "added";519 result = forwardAdded; 418 520 } catch (CalFacadeException cfe) { 419 521 if (CalFacadeException.duplicateSubscription.equals(cfe.getMessage())) { 420 522 form.getErr().emit(cfe.getMessage()); 421 return "success"; // User will see message and we'll stay on page523 return forwardSuccess; // User will see message and we'll stay on page 422 524 } 423 525 … … 426 528 } else if (getReqPar(request, "updateSubscription") != null) { 427 529 svc.updateSubscription(sub); 428 forward = "updated";530 result = forwardUpdated; 429 531 } else { 430 forward = "noaction";532 result = forwardNoAction; 431 533 } 432 534 433 535 if ((viewName == null) && !addToDefaultView) { 434 536 // We're done - not adding to a view 435 return forward;537 return result; 436 538 } 437 539 … … 442 544 form.setSubscriptions(svc.getSubscriptions()); 443 545 444 return forward;546 return result; 445 547 } 446 548 trunk/calendar3/webcommon/src/org/bedework/webcommon/misc/SetSelectionAction.java
r300 r493 107 107 private String trySub(HttpServletRequest request, 108 108 BwActionFormBase form) throws Throwable { 109 CalSvcI svci = form.fetchSvci(); 110 String name = getReqPar(request, "subname"); 109 int result = setSubscription(getReqPar(request, "subname"), form); 111 110 112 if ( name == null) {111 if (result == forwardNoParameter) { 113 112 return null; 114 113 } 115 114 116 BwSubscription sub = svci.findSubscription(name); 117 118 if (sub == null) { 119 form.getErr().emit("org.bedework.client.error.unknownsubscription"); 120 return "notFound"; 121 } 122 123 Collection c = new ArrayList(); 124 c.add(sub.clone()); 125 svci.setCurrentSubscriptions(c); 126 form.assignCurrentSubscriptions(c); 127 form.setSelectionType(BedeworkDefs.selectionTypeSubscription); 128 129 form.refreshIsNeeded(); 130 return "success"; 115 return forwards[result]; 131 116 } 132 117 trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/EndSubscribeAction.java
r490 r493 99 99 } 100 100 101 int result; 102 101 103 if (getReqPar(request, "delete") != null) { 102 return unsubscribe(request, form); 104 result = unsubscribe(request, form); 105 } else { 106 result = finishSubscribe(request, form.getSubscription(), form); 103 107 } 104 108 105 return finishSubscribe(request, form.getSubscription(), form); 109 resetSelection(form); 110 111 return forwards[result]; 106 112 } 107 113 108 private Stringunsubscribe(HttpServletRequest request,109 BwActionFormBase form) throws Throwable {114 private int unsubscribe(HttpServletRequest request, 115 BwActionFormBase form) throws Throwable { 110 116 CalSvcI svc = form.fetchSvci(); 111 117 … … 115 121 // Assume no access 116 122 form.getErr().emit("org.bedework.client.error.missingfield", "name"); 117 return "error";123 return forwardError; 118 124 } 119 125 … … 122 128 if (sub == null) { 123 129 form.getErr().emit("org.bedework.client.error.nosuchsubscription", name); 124 return "notFound";130 return forwardNotFound; 125 131 } 126 132 127 133 if (sub.getUnremoveable() && !form.getUserAuth().isSuperUser()) { 128 return "noAccess"; // Only super user can remove the unremovable134 return forwardNoAccess; // Only super user can remove the unremovable 129 135 } 130 136 … … 145 151 form.getErr().emit("org.bedework.client.error.viewnotfound", 146 152 v.getName()); 147 return "error";153 return forwardError; 148 154 } 149 155 } else { … … 156 162 157 163 if (reffed) { 158 return "reffed";164 return forwardReffed; 159 165 } 160 166 … … 165 171 form.setSubscriptions(svc.getSubscriptions()); 166 172 167 return "success";173 return forwardSuccess; 168 174 } 169 175 } trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/InitSubscribeAction.java
r487 r493 157 157 158 158 if (getReqPar(request, "addSubscription") != null) { 159 return f inishSubscribe(request, sub, form);159 return forwards[finishSubscribe(request, sub, form)]; 160 160 } 161 161
