2006-05-23 13:38:33 +00:00
|
|
|
/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
|
2004-11-15 03:25:39 +00:00
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
package sample.contact;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
2008-12-21 16:36:16 +00:00
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
|
|
import org.springframework.security.acls.Acl;
|
|
|
|
|
import org.springframework.security.acls.AclService;
|
|
|
|
|
import org.springframework.security.acls.objectidentity.ObjectIdentityImpl;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.web.bind.ServletRequestUtils;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
import org.springframework.web.servlet.mvc.Controller;
|
|
|
|
|
|
2004-11-15 03:25:39 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Controller for "administer" index page.
|
|
|
|
|
*
|
|
|
|
|
* @author Ben Alex
|
|
|
|
|
* @version $Id$
|
|
|
|
|
*/
|
|
|
|
|
public class AdminPermissionController implements Controller, InitializingBean {
|
2006-05-23 13:38:33 +00:00
|
|
|
//~ Instance fields ================================================================================================
|
2004-11-15 03:25:39 +00:00
|
|
|
|
2006-11-17 02:01:21 +00:00
|
|
|
private AclService aclService;
|
2004-11-15 03:25:39 +00:00
|
|
|
private ContactManager contactManager;
|
|
|
|
|
|
2006-05-23 13:38:33 +00:00
|
|
|
//~ Methods ========================================================================================================
|
2004-11-15 03:25:39 +00:00
|
|
|
|
2006-05-23 13:38:33 +00:00
|
|
|
public void afterPropertiesSet() throws Exception {
|
|
|
|
|
Assert.notNull(contactManager, "A ContactManager implementation is required");
|
2006-11-17 02:01:21 +00:00
|
|
|
Assert.notNull(aclService, "An aclService implementation is required");
|
2004-11-15 03:25:39 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-23 13:38:33 +00:00
|
|
|
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
|
|
|
|
|
throws ServletException, IOException {
|
2008-11-10 04:27:25 +00:00
|
|
|
int id = ServletRequestUtils.getRequiredIntParameter(request, "contactId");
|
2004-11-15 03:25:39 +00:00
|
|
|
|
2005-11-04 04:15:57 +00:00
|
|
|
Contact contact = contactManager.getById(new Long(id));
|
2006-11-17 02:01:21 +00:00
|
|
|
Acl acl = aclService.readAclById(new ObjectIdentityImpl(contact));
|
2004-11-15 03:25:39 +00:00
|
|
|
|
2008-12-21 16:36:16 +00:00
|
|
|
Map<String, Object> model = new HashMap<String, Object>(2);
|
2004-11-15 03:25:39 +00:00
|
|
|
model.put("contact", contact);
|
2006-11-17 02:01:21 +00:00
|
|
|
model.put("acl", acl);
|
2004-11-15 03:25:39 +00:00
|
|
|
|
|
|
|
|
return new ModelAndView("adminPermission", "model", model);
|
|
|
|
|
}
|
2006-05-23 13:38:33 +00:00
|
|
|
|
2006-11-17 02:01:21 +00:00
|
|
|
public void setAclService(AclService aclService) {
|
|
|
|
|
this.aclService = aclService;
|
2006-05-23 13:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setContactManager(ContactManager contact) {
|
|
|
|
|
this.contactManager = contact;
|
|
|
|
|
}
|
2004-11-15 03:25:39 +00:00
|
|
|
}
|