Changeset 163

Show
Ignore:
Timestamp:
02/15/06 23:25:56
Author:
douglm
Message:

Check to see if the subscription we are about to delete is referenced by a view.
If so emit error org.bedework.client.error.subscription.reffed with the view name as a parameter (for each view) and return "reffed".

Delete still does not work as the Modify Subscription page needs a hidden field "name" with the name of the subscription as a parameter.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java

    r162 r163  
    920920 
    921921    prefs.getSubscriptions().remove(val); 
    922     dbi.updatePreferences(prefs); 
     922    //dbi.updatePreferences(prefs); 
    923923  } 
    924924 
  • trunk/calendar3/webadmin/war/WEB-INF/struts-config.xml

    r157 r163  
    331331      <forward name="cancelled" path="/subs/showSubs.rdo" redirect="true"/> 
    332332      <forward name="retry" path="/subs/showSubs.rdo" redirect="true"/> 
     333      <forward name="reffed" path="/subs/showSubs.rdo" redirect="true"/> 
    333334      <forward name="success" path="/subs/showSubs.rdo" redirect="true" /> 
    334335    </action> 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java

    r147 r163  
    7272import org.bedework.calfacade.svc.BwAuthUserPrefs; 
    7373import org.bedework.calfacade.svc.BwSubscription; 
     74import org.bedework.calfacade.svc.BwView; 
    7475import org.bedework.calfacade.svc.EventInfo; 
    7576import org.bedework.calfacade.svc.UserAuth; 
     
    291292    form.refreshIsNeeded(); 
    292293    return true; 
     294  } 
     295   
     296  protected String unsubscribe(HttpServletRequest request, 
     297                                 BwActionFormBase form) throws Throwable { 
     298    if (form.getGuest()) { 
     299      return "noAccess"; // First line of defence 
     300    } 
     301 
     302    CalSvcI svc = form.fetchSvci(); 
     303 
     304    String name = request.getParameter("name"); 
     305 
     306    if (name == null) { 
     307      // Assume no access 
     308      form.getErr().emit("org.bedework.client.error.missingfield", "name"); 
     309      return "error"; 
     310    } 
     311 
     312    BwSubscription sub = svc.findSubscription(name); 
     313 
     314    if (sub == null) { 
     315      form.getErr().emit("org.bedework.client.error.nosuchsubscription", name); 
     316      return "notFound"; 
     317    } 
     318     
     319    if (sub.getUnremoveable() && !form.getUserAuth().isSuperUser()) { 
     320      return "noAccess"; // Only super user can remove the unremovable 
     321    } 
     322     
     323        Iterator it = svc.getViews().iterator(); 
     324        boolean reffed = false; 
     325        while (it.hasNext()) { 
     326                BwView v = (BwView)it.next(); 
     327                if (v.getSubscriptions().contains(sub)) { 
     328                        form.getErr().emit("org.bedework.client.error.subscription.reffed",  
     329                                                       v.getName()); 
     330                        reffed = true; 
     331                } 
     332        } 
     333         
     334        if (reffed) { 
     335                return "reffed"; 
     336        } 
     337 
     338    svc.removeSubscription(sub); 
     339    form.getMsg().emit("org.bedework.client.message.subscription.removed"); 
     340    return "success"; 
    293341  } 
    294342 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/SubscribeAction.java

    r160 r163  
    7979 * <p>Forwards to:<ul> 
    8080 *      <li>"error"        some form of fatal error.</li> 
     81 *      <li>"reffed"       subscription is referenced.</li> 
    8182 *      <li>"noAccess"     user not authorised.</li> 
    8283 *      <li>"cancelled"    for a cancelled request.</li> 
     
    9697    if (form.getGuest()) { 
    9798      return "noAccess"; // First line of defence 
     99    } 
     100     
     101    if (getReqPar(request, "delete") != null) { 
     102        return unsubscribe(request, form); 
    98103    } 
    99104 
     
    139144    } else if (getReqPar(request, "updateSubscription") != null) { 
    140145      svc.updateSubscription(sub); 
    141     } else if (getReqPar(request, "delete") != null) { 
    142       svc.removeSubscription(sub); 
    143146    } else { 
    144147    } 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/UnsubscribeAction.java

    r55 r163  
    5454package org.bedework.webcommon.subs; 
    5555 
    56 import org.bedework.calfacade.svc.BwSubscription; 
    57 import org.bedework.calsvci.CalSvcI; 
    5856import org.bedework.webcommon.BwAbstractAction; 
    5957import org.bedework.webcommon.BwActionFormBase; 
     
    7169 * <p>Forwards to:<ul> 
    7270 *      <li>"error"        some form of fatal error.</li> 
     71 *      <li>"reffed"       subscription is referenced.</li> 
    7372 *      <li>"noAccess"     user not authorised.</li> 
    7473 *      <li>"notFound"     no such subscription.</li> 
     
    8685                         BwSession sess, 
    8786                         BwActionFormBase form) throws Throwable { 
    88     if (form.getGuest()) { 
    89       return "noAccess"; // First line of defence 
    90     } 
    91  
    92     CalSvcI svc = form.fetchSvci(); 
    93  
    94     String name = request.getParameter("name"); 
    95  
    96     if (name == null) { 
    97       // Assume no access 
    98       form.getErr().emit("org.bedework.client.error.missingfield", "name"); 
    99       return "error"; 
    100     } 
    101  
    102     BwSubscription sub = svc.findSubscription(name); 
    103  
    104     if (sub == null) { 
    105       form.getErr().emit("org.bedework.client.error.nosuchsubscription", name); 
    106       return "notFound"; 
    107     } 
    108  
    109     svc.removeSubscription(sub); 
    110     form.getMsg().emit("org.bedework.client.message.subscription.removed"); 
    111     return "success"; 
     87        return unsubscribe(request, form); 
    11288  } 
    11389}