001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/presentation/tool/src/java/org/theospi/portfolio/presentation/control/AbstractPresentationController.java $
003: * $Id:AbstractPresentationController.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.theospi.portfolio.presentation.control;
021:
022: import java.util.Collection;
023: import java.util.Map;
024:
025: import org.apache.commons.logging.Log;
026: import org.apache.commons.logging.LogFactory;
027: import org.sakaiproject.metaobj.security.AuthenticationManager;
028: import org.sakaiproject.metaobj.shared.mgt.AgentManager;
029: import org.sakaiproject.metaobj.shared.mgt.HomeFactory;
030: import org.sakaiproject.metaobj.shared.mgt.IdManager;
031: import org.sakaiproject.metaobj.shared.model.Id;
032: import org.sakaiproject.metaobj.utils.mvc.intf.Controller;
033: import org.sakaiproject.metaobj.worksite.mgt.WorksiteManager;
034: import org.sakaiproject.tool.cover.ToolManager;
035: import org.theospi.portfolio.presentation.PresentationManager;
036: import org.theospi.portfolio.presentation.model.PresentationTemplate;
037: import org.theospi.portfolio.security.AuthorizationFacade;
038: import org.theospi.portfolio.shared.model.Node;
039: import org.theospi.utils.mvc.impl.servlet.AbstractFormController;
040:
041: abstract public class AbstractPresentationController extends
042: AbstractFormController implements Controller {
043: private AgentManager agentManager;
044: private PresentationManager presentationManager;
045: private AuthenticationManager authManager;
046: private HomeFactory homeFactory;
047: protected final Log logger = LogFactory.getLog(getClass());
048: //private FileArtifactFinder fileArtifactFinder;
049: private IdManager idManager;
050: private Collection mimeTypes;
051: private AuthorizationFacade authzManager;
052: private WorksiteManager worksiteManager;
053: private AddTemplateController addTemplateController;
054:
055: protected PresentationTemplate getActiveTemplate(Map session) {
056: //AddTemplateController addTemplateController = (AddTemplateController)ComponentManager.getInstance().get("addTemplateController");
057: return (PresentationTemplate) session
058: .get(getAddTemplateController().getFormAttributeName());
059: }
060:
061: /**
062: *
063: * @return true is current agent is a maintainer in the current site
064: */
065: protected Boolean isMaintainer() {
066: return new Boolean(getAuthzManager()
067: .isAuthorized(
068: WorksiteManager.WORKSITE_MAINTAIN,
069: getIdManager().getId(
070: ToolManager.getCurrentPlacement()
071: .getContext())));
072: }
073:
074: protected Node loadNode(Id nodeId) {
075: return getPresentationManager().getNode(nodeId);
076: }
077:
078: public WorksiteManager getWorksiteManager() {
079: return worksiteManager;
080: }
081:
082: public void setWorksiteManager(WorksiteManager worksiteManager) {
083: this .worksiteManager = worksiteManager;
084: }
085:
086: public PresentationManager getPresentationManager() {
087: return presentationManager;
088: }
089:
090: protected Collection getHomes() {
091: return getHomeFactory().getHomes().entrySet();
092: }
093:
094: public void setPresentationManager(
095: PresentationManager presentationManager) {
096: this .presentationManager = presentationManager;
097: }
098:
099: public AuthenticationManager getAuthManager() {
100: return authManager;
101: }
102:
103: public void setAuthManager(AuthenticationManager authManager) {
104: this .authManager = authManager;
105: }
106:
107: public AgentManager getAgentManager() {
108: return agentManager;
109: }
110:
111: public void setAgentManager(AgentManager agentManager) {
112: this .agentManager = agentManager;
113: }
114:
115: public HomeFactory getHomeFactory() {
116: return homeFactory;
117: }
118:
119: public void setHomeFactory(HomeFactory homeFactory) {
120: this .homeFactory = homeFactory;
121: }
122:
123: //public FileArtifactFinder getFileArtifactFinder() {
124: // return fileArtifactFinder;
125: //}
126:
127: //public void setFileArtifactFinder(FileArtifactFinder fileFinder) {
128: // this.fileArtifactFinder = fileFinder;
129: //}
130:
131: public IdManager getIdManager() {
132: return idManager;
133: }
134:
135: public void setIdManager(IdManager idManager) {
136: this .idManager = idManager;
137: }
138:
139: public Collection getMimeTypes() {
140: return mimeTypes;
141: }
142:
143: public void setMimeTypes(Collection mimeTypes) {
144: this .mimeTypes = mimeTypes;
145: }
146:
147: public AuthorizationFacade getAuthzManager() {
148: return authzManager;
149: }
150:
151: public void setAuthzManager(AuthorizationFacade authzManager) {
152: this .authzManager = authzManager;
153: }
154:
155: public AddTemplateController getAddTemplateController() {
156: return addTemplateController;
157: }
158:
159: public void setAddTemplateController(
160: AddTemplateController addTemplateController) {
161: this.addTemplateController = addTemplateController;
162: }
163: }
|