01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15: package sample.contact;
16:
17: import org.acegisecurity.acls.Acl;
18: import org.acegisecurity.acls.AclService;
19: import org.acegisecurity.acls.objectidentity.ObjectIdentityImpl;
20:
21: import org.springframework.beans.factory.InitializingBean;
22:
23: import org.springframework.util.Assert;
24:
25: import org.springframework.web.bind.RequestUtils;
26: import org.springframework.web.servlet.ModelAndView;
27: import org.springframework.web.servlet.mvc.Controller;
28:
29: import java.io.IOException;
30:
31: import java.util.HashMap;
32: import java.util.Map;
33:
34: import javax.servlet.ServletException;
35: import javax.servlet.http.HttpServletRequest;
36: import javax.servlet.http.HttpServletResponse;
37:
38: /**
39: * Controller for "administer" index page.
40: *
41: * @author Ben Alex
42: * @version $Id: AdminPermissionController.java 1754 2006-11-17 02:01:21Z benalex $
43: */
44: public class AdminPermissionController implements Controller,
45: InitializingBean {
46: //~ Instance fields ================================================================================================
47:
48: private AclService aclService;
49: private ContactManager contactManager;
50:
51: //~ Methods ========================================================================================================
52:
53: public void afterPropertiesSet() throws Exception {
54: Assert.notNull(contactManager,
55: "A ContactManager implementation is required");
56: Assert.notNull(aclService,
57: "An aclService implementation is required");
58: }
59:
60: public ModelAndView handleRequest(HttpServletRequest request,
61: HttpServletResponse response) throws ServletException,
62: IOException {
63: int id = RequestUtils.getRequiredIntParameter(request,
64: "contactId");
65:
66: Contact contact = contactManager.getById(new Long(id));
67: Acl acl = aclService
68: .readAclById(new ObjectIdentityImpl(contact));
69:
70: Map model = new HashMap();
71: model.put("contact", contact);
72: model.put("acl", acl);
73:
74: return new ModelAndView("adminPermission", "model", model);
75: }
76:
77: public void setAclService(AclService aclService) {
78: this .aclService = aclService;
79: }
80:
81: public void setContactManager(ContactManager contact) {
82: this.contactManager = contact;
83: }
84: }
|