01: /**********************************************************************************
02: * $URL:https://source.sakaiproject.org/svn/osp/trunk/presentation/tool/src/java/org/theospi/portfolio/presentation/control/AddCommentController.java $
03: * $Id:AddCommentController.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.presentation.control;
21:
22: import java.util.Map;
23: import java.util.Hashtable;
24:
25: import org.springframework.validation.BindException;
26: import org.springframework.validation.Errors;
27: import org.springframework.web.servlet.ModelAndView;
28: import org.theospi.portfolio.presentation.model.PresentationComment;
29: import org.theospi.portfolio.presentation.model.Presentation;
30: import org.theospi.portfolio.security.AuthorizationFacade;
31:
32: /**
33: * Created by IntelliJ IDEA.
34: * User: John Ellis
35: * Date: Jun 1, 2004
36: * Time: 10:52:26 AM
37: * To change this template use File | Settings | File Templates.
38: */
39: public class AddCommentController extends
40: AbstractPresentationController {
41:
42: private AuthorizationFacade authzManager = null;
43:
44: public ModelAndView handleRequest(Object requestModel, Map request,
45: Map session, Map application, Errors errors) {
46:
47: PresentationComment comment = (PresentationComment) requestModel;
48:
49: if (comment.getTitle() == null
50: || comment.getTitle().length() == 0) {
51: errors.rejectValue("title", "required", "required");
52: }
53:
54: if (comment.getComment() == null
55: || comment.getComment().length() == 0) {
56: errors.rejectValue("comment", "required", "required");
57: }
58:
59: request.put(BindException.ERROR_KEY_PREFIX + "newComment",
60: errors);
61:
62: if (!errors.hasErrors()) {
63: Presentation pres = getPresentationManager()
64: .getPresentation(comment.getPresentationId());
65: getAuthzManager().pushAuthzGroups(pres.getSiteId());
66: getPresentationManager().createComment(
67: (PresentationComment) requestModel);
68: }
69: Hashtable model = new Hashtable();
70: model.put("sakai.tool.placement.id", request
71: .get("sakai.tool.placement.id"));
72: model.put("id", comment.getPresentation().getId());
73: return new ModelAndView("success", model);
74: }
75:
76: public AuthorizationFacade getAuthzManager() {
77: return authzManager;
78: }
79:
80: public void setAuthzManager(AuthorizationFacade authzManager) {
81: this.authzManager = authzManager;
82: }
83: }
|