001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
014: * License for the specific language governing permissions and limitations under
015: * the License.
016: *
017: */
018:
019: /* $Id: TaskParameters.java 473861 2006-11-12 03:51:14Z gregor $ */
020:
021: package org.apache.lenya.cms.task;
022:
023: import java.util.Map;
024:
025: import org.apache.avalon.framework.service.ServiceManager;
026: import org.apache.lenya.cms.publication.Publication;
027: import org.apache.lenya.cms.publication.PublicationException;
028: import org.apache.lenya.cms.publication.PublicationUtil;
029:
030: /**
031: * Task Parameters
032: * @deprecated Use the usecase framework instead.
033: */
034: public class TaskParameters extends ParameterWrapper {
035: /**
036: * <code>REQUIRED_KEYS</code> Required task parameters
037: */
038: public static final String[] REQUIRED_KEYS = {
039: Task.PARAMETER_SERVLET_CONTEXT, Task.PARAMETER_SERVER_URI,
040: Task.PARAMETER_SERVER_PORT, Task.PARAMETER_CONTEXT_PREFIX,
041: Task.PARAMETER_PUBLICATION_ID };
042: /**
043: * <code>PREFIX</code> The task prefix
044: */
045: public static final String PREFIX = "task";
046:
047: private ServiceManager manager;
048:
049: /**
050: * Ctor.
051: * @param prefixedParameters The prefixed parameters .
052: * @param manager The service manager.
053: */
054: public TaskParameters(Map prefixedParameters, ServiceManager manager) {
055: super (prefixedParameters);
056: }
057:
058: /**
059: * @see org.apache.lenya.cms.task.ParameterWrapper#getPrefix()
060: */
061: public String getPrefix() {
062: return PREFIX;
063: }
064:
065: /**
066: * @see org.apache.lenya.cms.task.ParameterWrapper#getRequiredKeys()
067: */
068: protected String[] getRequiredKeys() {
069: return REQUIRED_KEYS;
070: }
071:
072: /**
073: * Returns the publication.
074: * @return A publication.
075: * @throws ExecutionException when something went wrong.
076: */
077: public Publication getPublication() throws ExecutionException {
078: Publication publication;
079: try {
080: publication = PublicationUtil.getPublication(this .manager,
081: get(Task.PARAMETER_PUBLICATION_ID));
082: } catch (PublicationException e) {
083: throw new ExecutionException(e);
084: }
085: return publication;
086: }
087:
088: /**
089: * Sets the publication.
090: * @param publication A publication.
091: */
092: public void setPublication(Publication publication) {
093: put(Task.PARAMETER_PUBLICATION_ID, publication.getId());
094: put(Task.PARAMETER_SERVLET_CONTEXT, publication
095: .getServletContext().getAbsolutePath());
096: }
097:
098: /**
099: * Sets the servlet context path.
100: * @param servletContextPath A string.
101: */
102: public void setServletContextPath(String servletContextPath) {
103: put(Task.PARAMETER_SERVLET_CONTEXT, servletContextPath);
104: }
105:
106: }
|