01: /**********************************************************************************
02: * $URL:https://source.sakaiproject.org/svn/osp/trunk/common/tool/src/java/org/theospi/portfolio/security/control/PermissionsController.java $
03: * $Id:PermissionsController.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.theospi.portfolio.security.control;
21:
22: import java.util.Hashtable;
23: import java.util.Map;
24:
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27: import org.sakaiproject.metaobj.utils.mvc.impl.servlet.AbstractFormController;
28: import org.sakaiproject.metaobj.utils.mvc.intf.FormController;
29: import org.sakaiproject.metaobj.utils.mvc.intf.LoadObjectController;
30: import org.sakaiproject.tool.cover.ToolManager;
31: import org.springframework.validation.Errors;
32: import org.springframework.web.servlet.ModelAndView;
33: import org.theospi.portfolio.security.mgt.PermissionManager;
34: import org.theospi.portfolio.security.model.PermissionsEdit;
35:
36: public class PermissionsController extends AbstractFormController
37: implements FormController, LoadObjectController {
38: protected final transient Log logger = LogFactory
39: .getLog(getClass());
40:
41: private PermissionManager permissionManager;
42:
43: /**
44: * Create a map of all data the form requries.
45: * Useful for building up drop down lists, etc.
46: *
47: * @param request
48: * @param command
49: * @param errors
50: * @return Map
51: */
52: public Map referenceData(Map request, Object command, Errors errors) {
53: Map model = new Hashtable();
54:
55: PermissionsEdit edit = (PermissionsEdit) command;
56: model.put("toolFunctions", getPermissionManager()
57: .getAppFunctions(edit));
58: model.put("roles", getPermissionManager()
59: .getWorksiteRoles(edit));
60:
61: if (request.get("message") != null) {
62: model.put("message", request.get("message"));
63: }
64:
65: return model;
66: }
67:
68: public ModelAndView processCancel(Map request, Map session,
69: Map application, Object command, Errors errors)
70: throws Exception {
71: return new ModelAndView("helperDone");
72: }
73:
74: public Object fillBackingObject(Object incomingModel, Map request,
75: Map session, Map application) throws Exception {
76: PermissionsEdit edit = (PermissionsEdit) incomingModel;
77: edit.setSiteId(ToolManager.getCurrentPlacement().getContext());
78: return getPermissionManager().fillPermissions(edit);
79: }
80:
81: public ModelAndView handleRequest(Object requestModel, Map request,
82: Map session, Map application, Errors errors) {
83: PermissionsEdit edit = (PermissionsEdit) requestModel;
84: getPermissionManager().updatePermissions(edit);
85: return new ModelAndView("helperDone");
86: }
87:
88: public PermissionManager getPermissionManager() {
89: return permissionManager;
90: }
91:
92: public void setPermissionManager(PermissionManager permissionManager) {
93: this.permissionManager = permissionManager;
94: }
95: }
|