Changeset 487
- Timestamp:
- 05/16/06 16:01:01
- Files:
-
- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (modified) (1 diff)
- trunk/calendar3/deployment/webuser/webapp/resources/demoskins/default/default/default.xsl (modified) (4 diffs)
- trunk/calendar3/webclient/war/WEB-INF/struts-config.xml (modified) (3 diffs)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java (modified) (3 diffs)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/EndSubscribeAction.java (moved) (moved from trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/SubscribeAction.java) (4 diffs)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/InitSubscribeAction.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
r484 r487 2043 2043 // Assume deleted 2044 2044 val.setCalendarDeleted(true); 2045 updateSubscription(val); 2045 if (val.getId() != CalFacadeDefs.unsavedItemKey) { 2046 // Save the state 2047 updateSubscription(val); 2048 } 2046 2049 } else { 2047 2050 val.setCalendar(calendar); trunk/calendar3/deployment/webuser/webapp/resources/demoskins/default/default/default.xsl
r485 r487 2927 2927 <h3>Add Subscription to User Calendar</h3> 2928 2928 <p class="note">*the subsciption name must be unique</p> 2929 <form name="subscribeForm" action="{$subscriptions- subscribe}" onsubmit="return setSubscriptionUri(this)" method="post">2929 <form name="subscribeForm" action="{$subscriptions-initAdd}" onsubmit="return setSubscriptionUri(this)" method="post"> 2930 2930 <table class="common" cellspacing="0"> 2931 2931 <tr> 2932 2932 <td class="fieldname">Name:</td> 2933 2933 <td> 2934 <input type="text" value="" name=" subscription.name" size="60"/>2934 <input type="text" value="" name="name" size="60"/> 2935 2935 </td> 2936 2936 </tr> … … 2960 2960 <td class="fieldname">Display:</td> 2961 2961 <td> 2962 <input type="radio" value="true" name=" subscription.display" checked="checked"/> yes2963 <input type="radio" value="false" name=" subscription.display"/> no2962 <input type="radio" value="true" name="display" checked="checked"/> yes 2963 <input type="radio" value="false" name="display"/> no 2964 2964 </td> 2965 2965 </tr> … … 2967 2967 <td class="fieldname">Affects Free/Busy:</td> 2968 2968 <td> 2969 <input type="radio" value="true" name=" subscription.affectsFreeBusy"/> yes2970 <input type="radio" value="false" name=" subscription.affectsFreeBusy" checked="checked"/> no2969 <input type="radio" value="true" name="affectsFreeBusy"/> yes 2970 <input type="radio" value="false" name="affectsFreeBusy" checked="checked"/> no 2971 2971 </td> 2972 2972 </tr> … … 2974 2974 <td class="fieldname">Style:</td> 2975 2975 <td> 2976 <input type="text" value="" name="s ubscription.style" size="60"/>2976 <input type="text" value="" name="style" size="60"/> 2977 2977 </td> 2978 2978 </tr> trunk/calendar3/webclient/war/WEB-INF/struts-config.xml
r481 r487 629 629 <forward name="noAccess" path="/subs/showSubs.rdo" redirect="true"/> 630 630 <forward name="cancelled" path="/subs/showSubs.rdo" redirect="true"/> 631 <forward name="added" path="/subs/showModForm.rdo" redirect="true" /> 631 632 <forward name="success" path="/subs/showModForm.rdo" redirect="true" /> 632 633 </action> … … 642 643 643 644 <action path="/subs/subscribe" 644 type="org.bedework.webcommon.subs. SubscribeAction"645 type="org.bedework.webcommon.subs.EndSubscribeAction" 645 646 name="calForm" 646 647 scope="session" … … 650 651 <forward name="reffed" path="/subs/showSubs.rdo" redirect="true"/> 651 652 <forward name="noAccess" path="/subs/showSubs.rdo" redirect="true"/> 653 <forward name="added" path="/subs/showSubs.rdo" redirect="true" /> 654 <forward name="updated" path="/subs/showSubs.rdo" redirect="true" /> 652 655 <forward name="success" path="/subs/showSubs.rdo" redirect="true" /> 653 656 </action> trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java
r459 r487 80 80 import org.bedework.calsvci.CalSvcIPars; 81 81 82 import edu.rpi.sss.util.Util; 82 83 import edu.rpi.sss.util.jsp.UtilAbstractAction; 83 84 import edu.rpi.sss.util.jsp.UtilActionForm; … … 354 355 } 355 356 357 protected boolean validateSub(BwSubscription sub, 358 BwActionFormBase form) { 359 sub.setName(Util.checkNull(sub.getName())); 360 361 if (sub.getName() == null) { 362 form.getErr().emit("org.bedework.validation.error.missingfield", "name"); 363 return false; 364 } 365 366 sub.setUri(Util.checkNull(sub.getUri())); 367 368 if (!sub.getInternalSubscription() && (sub.getUri() == null)) { 369 form.getErr().emit("org.bedework.validation.error.missingfield", "uri"); 370 return false; 371 } 372 373 return true; 374 } 375 376 /** Called to finish off adding or updating a subscription 377 * 378 * @param request 379 * @param sub 380 * @param form 381 * @return String "added" for added, "updated" for updated. 382 * @throws Throwable 383 */ 384 protected String finishSubscribe(HttpServletRequest request, 385 BwSubscription sub, 386 BwActionFormBase form) throws Throwable { 387 CalSvcI svc = form.fetchSvci(); 388 String forward; 389 390 String viewName = getReqPar(request, "view"); 391 boolean addToDefaultView = false; 392 393 if (viewName == null) { 394 addToDefaultView = true; 395 String str = getReqPar(request, "addtodefaultview"); 396 if (str != null) { 397 addToDefaultView = str.equals("y"); 398 } 399 } 400 401 Boolean bool = getBooleanReqPar(request, "unremoveable"); 402 if (bool != null) { 403 if (!form.getUserAuth().isSuperUser()) { 404 return "noAccess"; // Only super user for that flag 405 } 406 407 sub.setUnremoveable(bool.booleanValue()); 408 } 409 410 if (!validateSub(sub, form)) { 411 return "retry"; 412 } 413 414 if (getReqPar(request, "addSubscription") != null) { 415 try { 416 svc.addSubscription(sub); 417 forward = "added"; 418 } catch (CalFacadeException cfe) { 419 if (CalFacadeException.duplicateSubscription.equals(cfe.getMessage())) { 420 form.getErr().emit(cfe.getMessage()); 421 return "success"; // User will see message and we'll stay on page 422 } 423 424 throw cfe; 425 } 426 } else if (getReqPar(request, "updateSubscription") != null) { 427 svc.updateSubscription(sub); 428 forward = "updated"; 429 } else { 430 forward = "noaction"; 431 } 432 433 if ((viewName == null) && !addToDefaultView) { 434 // We're done - not adding to a view 435 return forward; 436 } 437 438 if (sub != null) { 439 svc.addViewSubscription(viewName, sub); 440 } 441 442 form.setSubscriptions(svc.getSubscriptions()); 443 444 return forward; 445 } 446 356 447 /** Find a user object given a "user" request parameter. 357 448 * … … 359 450 * @param form 360 451 * @return BwUser null if not found. Messages emitted 452 * @throws Throwable 453 */ 454 /** 455 * @param request 456 * @param form 457 * @return 361 458 * @throws Throwable 362 459 */ trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/EndSubscribeAction.java
r486 r487 63 63 import org.bedework.webcommon.BwSession; 64 64 65 import edu.rpi.sss.util.Util;66 67 65 import java.util.Iterator; 68 66 … … 70 68 import javax.servlet.http.HttpServletResponse; 71 69 72 /** Subscribe a userto a calendar.70 /** Complete or update a subscription to a calendar. 73 71 * 74 72 * <p>Parameters are:<ul> … … 90 88 * @author Mike Douglass douglm@rpi.edu 91 89 */ 92 public class SubscribeAction extends BwAbstractAction {90 public class EndSubscribeAction extends BwAbstractAction { 93 91 /* (non-Javadoc) 94 92 * @see org.bedework.webcommon.BwAbstractAction#doAction(javax.servlet.http.HttpServletRequest, org.bedework.webcommon.BwSession, org.bedework.webcommon.BwActionFormBase) … … 106 104 } 107 105 108 BwSubscription sub = form.getSubscription(); 109 110 CalSvcI svc = form.fetchSvci(); 111 112 String viewName = getReqPar(request, "view"); 113 boolean addToDefaultView = false; 114 115 if (viewName == null) { 116 addToDefaultView = true; 117 String str = getReqPar(request, "addtodefaultview"); 118 if (str != null) { 119 addToDefaultView = str.equals("y"); 120 } 121 } 122 123 Boolean bool = getBooleanReqPar(request, "unremoveable"); 124 if (bool != null) { 125 if (!form.getUserAuth().isSuperUser()) { 126 return "noAccess"; // Only super user for that flag 127 } 128 129 sub.setUnremoveable(bool.booleanValue()); 130 } 131 132 if (!validateSub(sub, form)) { 133 return "retry"; 134 } 135 136 if (getReqPar(request, "addSubscription") != null) { 137 try { 138 svc.addSubscription(sub); 139 } catch (CalFacadeException cfe) { 140 if (CalFacadeException.duplicateSubscription.equals(cfe.getMessage())) { 141 form.getErr().emit(cfe.getMessage()); 142 return "success"; // User will see message and we'll stay on page 143 } 144 145 throw cfe; 146 } 147 } else if (getReqPar(request, "updateSubscription") != null) { 148 svc.updateSubscription(sub); 149 } else { 150 } 151 152 if ((viewName == null) && !addToDefaultView) { 153 // We're done - not adding to a view 154 return "success"; 155 } 156 157 if (sub != null) { 158 svc.addViewSubscription(viewName, sub); 159 } 160 161 form.setSubscriptions(svc.getSubscriptions()); 162 163 return "success"; 164 } 165 166 private boolean validateSub(BwSubscription sub, 167 BwActionFormBase form) { 168 sub.setName(Util.checkNull(sub.getName())); 169 170 if (sub.getName() == null) { 171 form.getErr().emit("org.bedework.validation.error.missingfield", "name"); 172 return false; 173 } 174 175 sub.setUri(Util.checkNull(sub.getUri())); 176 177 if (!sub.getInternalSubscription() && (sub.getUri() == null)) { 178 form.getErr().emit("org.bedework.validation.error.missingfield", "uri"); 179 return false; 180 } 181 182 return true; 106 return finishSubscribe(request, form.getSubscription(), form); 183 107 } 184 108 trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/InitSubscribeAction.java
r446 r487 64 64 import javax.servlet.http.HttpServletResponse; 65 65 66 /** Subscribe a user to a calendar. 66 /** This should be called when we have a displayed list of calendars to which 67 * we can subscribe. We pass the path or uri and a subscription object is 68 * created and placed in the form. 69 * 70 * <p>This should then forward to a page which allows the user to set the rest 71 * of the subscrioption parameters. 67 72 * 68 73 * <p>Parameters are:<ul> 74 * <li>"name" Optional name of subscription</li> 75 * <li>"display" Optional setting for display flag</li> 76 * <li>"affctsFreeBusy" Optional setting for freebusy</li> 69 77 * <li>"calPath" Path to local calendar</li> 70 78 * <li>"calUri" URI of remote calendar</li> … … 100 108 BwSubscription sub; 101 109 102 // XXX Bogus??? Just use path for both. 110 boolean display = true; 111 Boolean flag = getBooleanReqPar(request, "display"); 112 if (flag != null) { 113 display = flag.booleanValue(); 114 } 115 116 boolean affectsFreeBusy = false; 117 flag = getBooleanReqPar(request, "affectsFreeBusy"); 118 if (flag != null) { 119 affectsFreeBusy = flag.booleanValue(); 120 } 121 122 String name = getReqPar(request, "name"); 123 103 124 if (calPath == null) { 104 calUri = request.getParameter("calUri");125 calUri = getReqPar(request, "calUri"); 105 126 if (calUri == null) { 106 127 return "error"; 107 128 } 108 129 109 sub = BwSubscription.makeSubscription(calUri, null, false, false, false); 130 sub = BwSubscription.makeSubscription(calUri, name, display, 131 affectsFreeBusy, false); 110 132 111 133 /* Try to access the calendar */ … … 124 146 } 125 147 126 sub = BwSubscription.makeSubscription(cal, cal.getName(), false, false, false); 148 if (name == null) { 149 name = cal.getName(); 150 } 151 152 sub = BwSubscription.makeSubscription(cal, name, display, 153 affectsFreeBusy, false); 154 } 155 156 form.setSubscription(sub); 157 158 if (getReqPar(request, "addSubscription") != null) { 159 return finishSubscribe(request, sub, form); 127 160 } 128 161 129 162 form.assignAddingSubscription(true); 130 form.setSubscription(sub);131 163 132 164 return "success";
