1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package sample.contact;
17
18 import org.acegisecurity.acl.AclManager;
19
20 import org.springframework.beans.factory.InitializingBean;
21
22 import org.springframework.util.Assert;
23
24 import org.springframework.web.bind.RequestUtils;
25 import org.springframework.web.servlet.ModelAndView;
26 import org.springframework.web.servlet.mvc.Controller;
27
28 import java.io.IOException;
29
30 import java.util.HashMap;
31 import java.util.Map;
32
33 import javax.servlet.ServletException;
34 import javax.servlet.http.HttpServletRequest;
35 import javax.servlet.http.HttpServletResponse;
36
37
38 /***
39 * Controller for deleting an ACL permission.
40 *
41 * @author Ben Alex
42 * @version $Id: DeletePermissionController.java,v 1.4 2005/11/17 00:56:08 benalex Exp $
43 */
44 public class DeletePermissionController implements Controller, InitializingBean {
45
46
47 private AclManager aclManager;
48 private ContactManager contactManager;
49
50
51
52 public void setAclManager(AclManager aclManager) {
53 this.aclManager = aclManager;
54 }
55
56 public AclManager getAclManager() {
57 return aclManager;
58 }
59
60 public void setContactManager(ContactManager contact) {
61 this.contactManager = contact;
62 }
63
64 public ContactManager getContactManager() {
65 return contactManager;
66 }
67
68 public void afterPropertiesSet() throws Exception {
69 Assert.notNull(contactManager,
70 "A ContactManager implementation is required");
71 Assert.notNull(aclManager, "An aclManager implementation is required");
72 }
73
74 public ModelAndView handleRequest(HttpServletRequest request,
75 HttpServletResponse response) throws ServletException, IOException {
76 int contactId = RequestUtils.getRequiredIntParameter(request,
77 "contactId");
78 String recipient = RequestUtils.getRequiredStringParameter(request,
79 "recipient");
80
81 Contact contact = contactManager.getById(new Long(contactId));
82
83 contactManager.deletePermission(contact, recipient);
84
85 Map model = new HashMap();
86 model.put("contact", contact);
87 model.put("recipient", recipient);
88
89 return new ModelAndView("deletePermission", "model", model);
90 }
91 }