01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: /* $Id: TaskAction.java 473861 2006-11-12 03:51:14Z gregor $ */
20:
21: package org.apache.lenya.cms.cocoon.acting;
22:
23: import java.util.HashMap;
24: import java.util.Map;
25:
26: import org.apache.avalon.framework.parameters.Parameters;
27: import org.apache.cocoon.acting.ServiceableAction;
28: import org.apache.cocoon.environment.ObjectModelHelper;
29: import org.apache.cocoon.environment.Redirector;
30: import org.apache.cocoon.environment.Request;
31: import org.apache.cocoon.environment.Session;
32: import org.apache.cocoon.environment.SourceResolver;
33: import org.apache.lenya.cms.cocoon.task.CocoonTaskWrapper;
34: import org.apache.lenya.cms.task.TaskWrapper;
35:
36: /**
37: * An action that executes a task.
38: */
39: public class TaskAction extends ServiceableAction {
40:
41: /**
42: * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
43: */
44: public java.util.Map act(Redirector redirector,
45: SourceResolver sourceResolver, Map objectModel, String str,
46: Parameters parameters) throws java.lang.Exception {
47:
48: TaskWrapper wrapper = new CocoonTaskWrapper(objectModel,
49: parameters, this .manager);
50: wrapper.execute();
51:
52: Request request = ObjectModelHelper.getRequest(objectModel);
53:
54: //------------------------------------------------------------
55: // get session
56: //------------------------------------------------------------
57: Session session = request.getSession(true);
58:
59: if (session == null) {
60: getLogger().error("No session object");
61:
62: return null;
63: }
64:
65: //------------------------------------------------------------
66: // Return referer
67: //------------------------------------------------------------
68: String parent_uri = (String) session
69: .getAttribute("org.apache.lenya.cms.cocoon.acting.TaskAction.parent_uri");
70: HashMap actionMap = new HashMap();
71: actionMap.put("parent_uri", parent_uri);
72: session
73: .removeAttribute("org.apache.lenya.cms.cocoon.acting.TaskAction.parent_uri");
74:
75: return actionMap;
76: }
77: }
|