01: /**********************************************************************************
02: * $URL:https://source.sakaiproject.org/svn/osp/trunk/common/tool-lib/src/java/org/theospi/utils/mvc/impl/ToolFinishedView.java $
03: * $Id:ToolFinishedView.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.sakaiproject.metaobj.shared.control;
21:
22: import java.util.Map;
23:
24: import javax.servlet.http.HttpServletRequest;
25: import javax.servlet.http.HttpServletResponse;
26:
27: import org.sakaiproject.tool.api.Tool;
28: import org.sakaiproject.tool.api.ToolSession;
29: import org.sakaiproject.tool.cover.SessionManager;
30: import org.sakaiproject.tool.cover.ToolManager;
31: import org.sakaiproject.metaobj.shared.control.HelperView;
32: import org.sakaiproject.spring.util.SpringTool;
33:
34: /**
35: * Created by IntelliJ IDEA.
36: * User: John Ellis
37: * Date: Jul 15, 2005
38: * Time: 2:06:07 PM
39: * To change this template use File | Settings | File Templates.
40: */
41: public class ToolFinishedView extends HelperView {
42:
43: /** the alternate next view */
44: public static final String ALTERNATE_DONE_URL = "altDoneURL";
45:
46: /** the set of alternate views */
47: public static final String ALTERNATE_DONE_URL_MAP = "altDoneURLSet";
48:
49: public void render(Map model, HttpServletRequest request,
50: HttpServletResponse response) throws Exception {
51: ToolSession toolSession = SessionManager
52: .getCurrentToolSession();
53: Tool tool = ToolManager.getCurrentTool();
54:
55: String url = (String) toolSession.getAttribute(tool.getId()
56: + Tool.HELPER_DONE_URL);
57:
58: toolSession
59: .removeAttribute(tool.getId() + Tool.HELPER_DONE_URL);
60: toolSession.removeAttribute(SpringTool.LAST_VIEW_VISITED);
61:
62: String pathObj = (String) toolSession.getAttribute(tool.getId()
63: + "thetoolPath");
64: toolSession.removeAttribute(tool.getId() + "thetoolPath");
65:
66: if (toolSession.getAttribute(tool.getId() + ALTERNATE_DONE_URL) != null) {
67: String path = "";
68: Object altObj = toolSession.getAttribute(tool.getId()
69: + ALTERNATE_DONE_URL);
70: Map urlMap = (Map) toolSession.getAttribute(tool.getId()
71: + ALTERNATE_DONE_URL_MAP);
72:
73: if (urlMap != null) {
74: url = (String) urlMap.get((String) altObj);
75:
76: if (pathObj != null) {
77: path = (String) pathObj;
78: }
79:
80: if (!url.startsWith("/"))
81: url = path + "/" + url;
82: }
83:
84: toolSession.removeAttribute(tool.getId()
85: + ALTERNATE_DONE_URL);
86: }
87:
88: setUrl(url);
89:
90: if (getModelPrefix() == null) {
91: setModelPrefix("");
92: }
93:
94: super.render(model, request, response);
95: }
96:
97: }
|