KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > task > TaskParameters


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: TaskParameters.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.cms.task;
21
22 import java.util.Map JavaDoc;
23
24 import org.apache.lenya.cms.publication.Publication;
25 import org.apache.lenya.cms.publication.PublicationException;
26 import org.apache.lenya.cms.publication.PublicationFactory;
27
28 public class TaskParameters extends ParameterWrapper {
29     public static final String JavaDoc[] REQUIRED_KEYS =
30         {
31             Task.PARAMETER_SERVLET_CONTEXT,
32             Task.PARAMETER_SERVER_URI,
33             Task.PARAMETER_SERVER_PORT,
34             Task.PARAMETER_CONTEXT_PREFIX,
35             Task.PARAMETER_PUBLICATION_ID };
36
37     /**
38      * Ctor.
39      * @param prefixedParameters The prefixed parameters .
40      */

41     public TaskParameters(Map JavaDoc prefixedParameters) {
42         super(prefixedParameters);
43     }
44
45     public static final String JavaDoc PREFIX = "task";
46
47     /**
48      * @see org.apache.lenya.cms.task.ParameterWrapper#getPrefix()
49      */

50     public String JavaDoc getPrefix() {
51         return PREFIX;
52     }
53
54     /**
55      * @see org.apache.lenya.cms.task.ParameterWrapper#getRequiredKeys()
56      */

57     protected String JavaDoc[] getRequiredKeys() {
58         return REQUIRED_KEYS;
59     }
60
61     /**
62      * Returns the publication.
63      * @return A publication.
64      * @throws ExecutionException when something went wrong.
65      */

66     public Publication getPublication() throws ExecutionException {
67         Publication publication;
68         try {
69             publication =
70                 PublicationFactory.getPublication(
71                     get(Task.PARAMETER_PUBLICATION_ID),
72                     get(Task.PARAMETER_SERVLET_CONTEXT));
73         } catch (PublicationException e) {
74             throw new ExecutionException(e);
75         }
76         return publication;
77     }
78
79     /**
80      * Sets the publication.
81      * @param publication A publication.
82      */

83     public void setPublication(Publication publication) {
84         put(Task.PARAMETER_PUBLICATION_ID, publication.getId());
85         put(Task.PARAMETER_SERVLET_CONTEXT, publication.getServletContext().getAbsolutePath());
86     }
87
88     /**
89      * Sets the servlet context path.
90      * @param servletContextPath A string.
91      */

92     public void setServletContextPath(String JavaDoc servletContextPath) {
93         put(Task.PARAMETER_SERVLET_CONTEXT, servletContextPath);
94     }
95
96 }
97
Popular Tags