01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/presentation/tool/src/java/org/theospi/portfolio/presentation/control/PublishLayoutController.java $
03: * $Id: PublishLayoutController.java 10835 2006-06-17 03:25:03Z lance@indiana.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.presentation.control;
21:
22: import java.util.Map;
23:
24: import org.apache.commons.logging.Log;
25: import org.apache.commons.logging.LogFactory;
26: import org.sakaiproject.metaobj.shared.model.Id;
27: import org.sakaiproject.tool.cover.ToolManager;
28: import org.springframework.validation.Errors;
29: import org.springframework.web.servlet.ModelAndView;
30: import org.theospi.portfolio.presentation.PresentationFunctionConstants;
31: import org.theospi.portfolio.presentation.model.PresentationLayout;
32:
33: public class PublishLayoutController extends
34: AbstractPresentationController {
35: protected final Log logger = LogFactory.getLog(getClass());
36:
37: public ModelAndView handleRequest(Object requestModel, Map request,
38: Map session, Map application, Errors errors) {
39: if (request.get("layout_id") != null
40: && !request.get("layout_id").equals("")) {
41: Id id = getIdManager().getId(
42: (String) request.get("layout_id"));
43: PresentationLayout layout = getPresentationManager()
44: .getPresentationLayout(id);
45:
46: String suggest = (String) request.get("suggest");
47: if (suggest == null) {
48: Id siteId = getIdManager().getId(
49: ToolManager.getCurrentPlacement().getContext());
50: getAuthzManager().checkPermission(
51: PresentationFunctionConstants.PUBLISH_LAYOUT,
52: siteId);
53: layout.setSiteId(siteId.getValue());
54: layout
55: .setGlobalState(PresentationLayout.STATE_PUBLISHED);
56: } else {
57: getAuthzManager()
58: .checkPermission(
59: PresentationFunctionConstants.SUGGEST_PUBLISH_LAYOUT,
60: layout.getId());
61: layout
62: .setGlobalState(PresentationLayout.STATE_WAITING_APPROVAL);
63: }
64:
65: // Don't need to check authz for saving as we should already have perms via the publish
66: getPresentationManager().storeLayout(layout, false);
67: request.put("newPresentationLayoutId", layout.getId()
68: .getValue());
69: }
70: return new ModelAndView("success");
71:
72: }
73:
74: }
|