KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > cocoon > scheduler > SchedulerHelper


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: SchedulerHelper.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.cms.cocoon.scheduler;
21
22 import java.util.HashMap JavaDoc;
23 import java.util.Map JavaDoc;
24
25 import org.apache.avalon.framework.logger.Logger;
26 import org.apache.avalon.framework.parameters.Parameters;
27 import org.apache.cocoon.ProcessingException;
28 import org.apache.lenya.cms.cocoon.task.CocoonTaskWrapper;
29 import org.apache.lenya.cms.publication.PageEnvelope;
30 import org.apache.lenya.cms.publication.PageEnvelopeFactory;
31 import org.apache.lenya.cms.scheduler.LoadQuartzServlet;
32 import org.apache.lenya.cms.scheduler.ServletJob;
33 import org.apache.lenya.cms.task.TaskWrapper;
34 import org.apache.lenya.util.NamespaceMap;
35
36 public class SchedulerHelper {
37
38     /**
39      * Ctor.
40      * @param objectModel The Cocoon component object model.
41      * @param parameters The Cocoon component parameters.
42      * @param logger The logger to use.
43      */

44     public SchedulerHelper(Map JavaDoc objectModel, Parameters parameters, Logger logger) {
45         this.objectModel = objectModel;
46         this.parameters = parameters;
47         this.logger = logger;
48     }
49
50     private Logger logger;
51     private Parameters parameters;
52     private Map JavaDoc objectModel;
53
54     /**
55      * Creates the scheduler parameters.
56      * @return A map.
57      * @throws ProcessingException when something went wrong.
58      */

59     public Map JavaDoc createParameters() throws ProcessingException {
60
61         Map JavaDoc map = new HashMap JavaDoc();
62
63         try {
64             TaskWrapper wrapper = new CocoonTaskWrapper(objectModel, parameters);
65
66             logger.debug("Adding task wrapper parameters");
67             Map JavaDoc wrapperParameters = wrapper.getParameters();
68             map.putAll(wrapperParameters);
69
70             NamespaceMap schedulerParameters = new NamespaceMap(LoadQuartzServlet.PREFIX);
71
72             PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
73
74             schedulerParameters.put(
75                 ServletJob.PARAMETER_DOCUMENT_URL,
76                 envelope.getDocument().getCompleteURL());
77             schedulerParameters.put(
78                 LoadQuartzServlet.PARAMETER_PUBLICATION_ID,
79                 envelope.getPublication().getId());
80             map.putAll(schedulerParameters.getPrefixedMap());
81
82         } catch (Exception JavaDoc e) {
83             throw new ProcessingException(e);
84         }
85
86         return map;
87     }
88
89 }
90
Popular Tags