KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > cocoon > acting > TaskAction


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: TaskAction.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.cms.cocoon.acting;
21
22 import java.util.HashMap JavaDoc;
23 import java.util.Map JavaDoc;
24
25 import org.apache.avalon.framework.parameters.Parameters;
26 import org.apache.cocoon.acting.AbstractAction;
27 import org.apache.cocoon.environment.ObjectModelHelper;
28 import org.apache.cocoon.environment.Redirector;
29 import org.apache.cocoon.environment.Request;
30 import org.apache.cocoon.environment.Session;
31 import org.apache.cocoon.environment.SourceResolver;
32 import org.apache.lenya.cms.cocoon.task.CocoonTaskWrapper;
33 import org.apache.lenya.cms.task.TaskWrapper;
34
35 /**
36  * An action that executes a task.
37  */

38 public class TaskAction extends AbstractAction {
39     
40     /**
41      * DOCUMENT ME!
42      *
43      * @param redirector DOCUMENT ME!
44      * @param sourceResolver DOCUMENT ME!
45      * @param objectModel DOCUMENT ME!
46      * @param str DOCUMENT ME!
47      * @param parameters DOCUMENT ME!
48      *
49      * @return DOCUMENT ME!
50      *
51      * @throws java.lang.Exception DOCUMENT ME!
52      */

53     public java.util.Map JavaDoc act(
54         Redirector redirector,
55         SourceResolver sourceResolver,
56         Map JavaDoc objectModel,
57         String JavaDoc str,
58         Parameters parameters)
59         throws java.lang.Exception JavaDoc {
60
61         TaskWrapper wrapper = new CocoonTaskWrapper(objectModel, parameters);
62         wrapper.execute();
63
64         Request request = ObjectModelHelper.getRequest(objectModel);
65
66         //------------------------------------------------------------
67
// get session
68
//------------------------------------------------------------
69
Session session = request.getSession(true);
70
71         if (session == null) {
72             getLogger().error("No session object");
73
74             return null;
75         }
76
77         //------------------------------------------------------------
78
// Return referer
79
//------------------------------------------------------------
80
String JavaDoc parent_uri =
81             (String JavaDoc) session.getAttribute(
82                 "org.apache.lenya.cms.cocoon.acting.TaskAction.parent_uri");
83         HashMap JavaDoc actionMap = new HashMap JavaDoc();
84         actionMap.put("parent_uri", parent_uri);
85         session.removeAttribute("org.apache.lenya.cms.cocoon.acting.TaskAction.parent_uri");
86
87         return actionMap;
88     }
89 }
90
Popular Tags