You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2003/08/25 17:40:55 UTC

cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/task WorkflowInvoker.java ParameterWrapper.java TaskParameters.java TaskWrapperParameters.java Task.java Notifier.java DefaultTaskWrapper.java

andreas     2003/08/25 08:40:55

  Modified:    src/java/org/apache/lenya/cms/cocoon/task
                        CocoonTaskWrapper.java
               src/java/org/apache/lenya/cms/task
                        TaskWrapperParameters.java Task.java Notifier.java
                        DefaultTaskWrapper.java
  Added:       src/java/org/apache/lenya/cms/task WorkflowInvoker.java
                        ParameterWrapper.java TaskParameters.java
  Log:
  splitting TaskWrapperParameters into separate modules
  
  Revision  Changes    Path
  1.2       +22 -21    cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/task/CocoonTaskWrapper.java
  
  Index: CocoonTaskWrapper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/task/CocoonTaskWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CocoonTaskWrapper.java	25 Aug 2003 09:52:40 -0000	1.1
  +++ CocoonTaskWrapper.java	25 Aug 2003 15:40:55 -0000	1.2
  @@ -55,8 +55,6 @@
   */
   package org.apache.lenya.cms.cocoon.task;
   
  -import java.util.Enumeration;
  -import java.util.HashMap;
   import java.util.Map;
   
   import org.apache.avalon.framework.parameters.Parameters;
  @@ -73,6 +71,7 @@
   import org.apache.lenya.cms.task.ExecutionException;
   import org.apache.lenya.cms.task.Notifier;
   import org.apache.lenya.cms.task.TaskWrapperParameters;
  +import org.apache.lenya.cms.task.WorkflowInvoker;
   import org.apache.lenya.util.NamespaceMap;
   import org.apache.lenya.util.ServletHelper;
   import org.apache.log4j.Category;
  @@ -84,7 +83,7 @@
    * Window - Preferences - Java - Code Generation - Code and Comments
    */
   public class CocoonTaskWrapper extends DefaultTaskWrapper {
  -    
  +
       private static Category log = Category.getInstance(CocoonTaskWrapper.class);
   
       /**
  @@ -106,6 +105,7 @@
           setNotifying(request);
   
           Parameters taskParameters = extractTaskParameters(parameters, publication, request);
  +        getTaskParameters().parameterize(taskParameters);
   
           String taskId = request.getParameter(TaskWrapperParameters.TASK_ID);
           taskId = parameters.getParameter(TaskWrapperParameters.TASK_ID, taskId);
  @@ -113,16 +113,18 @@
           String webappUrl = ServletHelper.getWebappURI(request);
           initialize(taskId, publication, webappUrl, taskParameters);
   
  -        String eventName = request.getParameter(TaskWrapperParameters.EVENT);
  -
  -        Identity identity = Identity.getIdentity(request.getSession(false));
  -        Role[] roles;
  -        try {
  -            roles = PolicyAuthorizer.getRoles(request);
  -        } catch (AccessControlException e) {
  -            throw new ExecutionException(e);
  +        String eventName = (String) request.getParameter(WorkflowInvoker.EVENT_REQUEST_PARAMETER);
  +        if (eventName != null) {
  +            Identity identity = Identity.getIdentity(request.getSession(false));
  +            Role[] roles;
  +            try {
  +                roles = PolicyAuthorizer.getRoles(request);
  +            } catch (AccessControlException e) {
  +                throw new ExecutionException(e);
  +            }
  +            setWorkflowAware(eventName, identity, roles);
           }
  -        setWorkflowAware(eventName, identity, roles);
  +
       }
   
       /**
  @@ -130,16 +132,10 @@
        * @param request The request.
        */
       protected void setNotifying(Request request) {
  -        
  +
           log.debug("Initializing Notification");
  -        
  -        Map requestParameters = new HashMap();
  -        for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
  -            String key = (String) e.nextElement();
  -            requestParameters.put(key, request.getParameter(key));
  -            log.debug("Request parameter: [" + key + "] = [" + request.getParameter(key) + "]");
  -        }
   
  +        Map requestParameters = ServletHelper.getParameterMap(request);
           NamespaceMap notificationMap =
               new NamespaceMap(requestParameters, Notifier.NOTIFICATION_PREFIX);
   
  @@ -149,6 +145,11 @@
                   NamespaceMap.getFullName(Notifier.NOTIFICATION_PREFIX, Notifier.PARAMETER_TO);
               String toString = "";
               String[] toValues = request.getParameterValues(toKey);
  +
  +            if (toValues == null) {
  +                throw new IllegalStateException("You must specify at least one [notification.tolist] request parameter!");
  +            }
  +
               for (int i = 0; i < toValues.length; i++) {
                   if (i > 0) {
                       toString += ",";
  
  
  
  1.2       +11 -251   cocoon-lenya/src/java/org/apache/lenya/cms/task/TaskWrapperParameters.java
  
  Index: TaskWrapperParameters.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/task/TaskWrapperParameters.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TaskWrapperParameters.java	25 Aug 2003 09:52:40 -0000	1.1
  +++ TaskWrapperParameters.java	25 Aug 2003 15:40:55 -0000	1.2
  @@ -55,23 +55,7 @@
   */
   package org.apache.lenya.cms.task;
   
  -import java.util.ArrayList;
  -import java.util.Arrays;
  -import java.util.HashMap;
  -import java.util.Iterator;
  -import java.util.List;
   import java.util.Map;
  -import java.util.Properties;
  -
  -import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.lenya.cms.ac.Machine;
  -import org.apache.lenya.cms.ac.Role;
  -import org.apache.lenya.cms.ac.User;
  -import org.apache.lenya.cms.ac2.Identity;
  -import org.apache.lenya.cms.publication.Publication;
  -import org.apache.lenya.cms.publication.PublicationException;
  -import org.apache.lenya.cms.publication.PublicationFactory;
  -import org.apache.lenya.util.NamespaceMap;
   import org.apache.log4j.Category;
   
   /**
  @@ -80,101 +64,23 @@
    * To change the template for this generated type comment go to
    * Window - Preferences - Java - Code Generation - Code and Comments
    */
  -public class TaskWrapperParameters {
  +public class TaskWrapperParameters extends ParameterWrapper {
   
       private static Category log = Category.getInstance(TaskWrapperParameters.class);
   
       public static final String TASK_ID = "task-id";
  -    public static final String ROLES = "roles";
  -    public static final String USER_ID = "user-id";
  -    public static final String MACHINE = "machine";
  -    public static final String EVENT = "event";
       public static final String WEBAPP_URL = "webapp-url";
   
  -    protected static final String[] KEYS = { TASK_ID, ROLES, USER_ID, MACHINE, EVENT, WEBAPP_URL };
  -
  -    public static final String TASK_PREFIX = "task";
  +    protected static final String[] REQUIRED_KEYS = { TASK_ID, WEBAPP_URL };
   
  -    private Map parameters = new HashMap();
  -    private NamespaceMap taskParameters = new NamespaceMap(parameters, TASK_PREFIX);
  -    private List keys = new ArrayList();
  +    public static final String PREFIX = "wrapper";
   
       /**
        * Ctor.
  +     * @param parameters The parameter map to use.
        */
  -    public TaskWrapperParameters() {
  -        keys.addAll(Arrays.asList(KEYS));
  -
  -        for (int i = 0; i < Task.PARAMETERS.length; i++) {
  -            keys.add(
  -                NamespaceMap.getFullName(TaskWrapperParameters.TASK_PREFIX, Task.PARAMETERS[i]));
  -        }
  -        for (int i = 0; i < keys.size(); i++) {
  -            log.debug("Adding required key: [" + keys.get(i) + "]");
  -        }
  -    }
  -
  -    /**
  -     * Sets a wrapper parameter value if this key is a required key.
  -     * @param key The key.
  -     * @param value The value.
  -     */
  -    protected void put(String key, String value) {
  -        if (keys.contains(key)) {
  -            putForced(key, value);
  -        }
  -    }
  -
  -    /**
  -     * Sets a wrapper parameter value.
  -     * @param key The key.
  -     * @param value The value.
  -     */
  -    protected void putForced(String key, String value) {
  -        if (value == null) {
  -            value = "";
  -        }
  -        log.debug("Setting parameter: [" + key + "] = [" + value + "]");
  -        parameters.put(key, value);
  -    }
  -
  -    /**
  -     * Returns a parameter value.
  -     * @param key The key.
  -     * @return The value.
  -     */
  -    protected String get(String key) {
  -        return (String) parameters.get(key);
  -    }
  -
  -    /**
  -     * Checks if this parameters object contains all necessary parameters.
  -     * @return A boolean value.
  -     */
  -    public boolean isComplete() {
  -        boolean complete = true;
  -        int i = 0;
  -        while (complete && i < keys.size()) {
  -            log.debug("Checking parameter: [" + keys.get(i) + "]");
  -            complete = complete && parameters.containsKey(keys.get(i));
  -            log.debug("OK: [" + complete + "]");
  -            i++;
  -        }
  -        return complete;
  -    }
  -
  -    /**
  -     * Returns the missing parameters parameters.
  -     * @return A string array.
  -     */
  -    public String[] getMissingKeys() {
  -        List keyList = new ArrayList();
  -        for (int i = 0; i < keys.size(); i++) {
  -            if (!parameters.containsKey(keys.get(i))) {
  -                keyList.add(keys.get(i));
  -            }
  -        }
  -        return (String[]) keyList.toArray(new String[keyList.size()]);
  +    public TaskWrapperParameters(Map parameters) {
  +        super(parameters);
       }
   
       /**
  @@ -182,79 +88,7 @@
        * @return A string array.
        */
       public String[] getRequiredKeys() {
  -        return (String[]) keys.toArray(new String[keys.size()]);
  -    }
  -
  -    /**
  -     * Returns the role names.
  -     * @return A string array.
  -     */
  -    protected String[] getRoleIDs() {
  -        String[] roleIDs = get(ROLES).split(",");
  -        return roleIDs;
  -    }
  -
  -    /**
  -     * Sets the roles.
  -     * @param roles A role array.
  -     */
  -    public void setRoles(Role[] roles) {
  -
  -        String roleString = "";
  -        for (int i = 0; i < roles.length; i++) {
  -            if (i > 0) {
  -                roleString += ",";
  -            }
  -            roleString += roles[i].getId();
  -        }
  -        put(ROLES, roleString);
  -    }
  -
  -    /**
  -     * Sets the identity.
  -     * @param identity An identity.
  -     */
  -    public void setIdentity(Identity identity) {
  -
  -        String userId = "";
  -        User user = identity.getUser();
  -        if (user != null) {
  -            userId = user.getId();
  -        }
  -        put(USER_ID, userId);
  -
  -        String machineIp = "";
  -        Machine machine = identity.getMachine();
  -        if (machine != null) {
  -            machineIp = machine.getIp();
  -        }
  -        put(MACHINE, machineIp);
  -    }
  -
  -    /**
  -     * Returns the workflow event name.
  -     * @return A string.
  -     */
  -    public String getEventName() {
  -        return (String) get(EVENT);
  -    }
  -
  -    /**
  -     * Returns the publication.
  -     * @return A publication.
  -     * @throws ExecutionException when something went wrong.
  -     */
  -    public Publication getPublication() throws ExecutionException {
  -        Publication publication;
  -        try {
  -            publication =
  -                PublicationFactory.getPublication(
  -                    (String) taskParameters.get(Task.PARAMETER_PUBLICATION_ID),
  -                    (String) taskParameters.get(Task.PARAMETER_SERVLET_CONTEXT));
  -        } catch (PublicationException e) {
  -            throw new ExecutionException(e);
  -        }
  -        return publication;
  +        return REQUIRED_KEYS;
       }
   
       /**
  @@ -274,28 +108,6 @@
       }
   
       /**
  -     * Returns the task parameters.
  -     * @return A parameters object.
  -     */
  -    public Parameters getTaskParameters() {
  -        Properties properties = new Properties();
  -        properties.putAll(taskParameters.getMap());
  -        Parameters parameters = Parameters.fromProperties(properties);
  -        return parameters;
  -    }
  -
  -    /**
  -     * Sets the publication.
  -     * @param publication A publication.
  -     */
  -    public void setPublication(Publication publication) {
  -        taskParameters.put(Task.PARAMETER_PUBLICATION_ID, publication.getId());
  -        taskParameters.put(
  -            Task.PARAMETER_SERVLET_CONTEXT,
  -            publication.getServletContext().getAbsolutePath());
  -    }
  -
  -    /**
        * Sets the webapp URL.
        * @param url A url.
        */
  @@ -312,62 +124,10 @@
       }
   
       /**
  -     * Sets the task parameters.
  -     * @param parameters A parameters object.
  +     * @see org.apache.lenya.cms.task.ParameterWrapper#getPrefix()
        */
  -    public void setTaskParameters(Parameters parameters) {
  -        String[] names = parameters.getNames();
  -        for (int i = 0; i < names.length; i++) {
  -            String value = parameters.getParameter(names[i], "");
  -            log.debug("Setting task parameter: [" + names[i] + "] = [" + value + "]");
  -            taskParameters.put(names[i], value);
  -        }
  -    }
  -
  -    /**
  -     * Returns the parameter keys.
  -     * @return A string array.
  -     */
  -    public String[] getKeys() {
  -        return (String[]) parameters.keySet().toArray(new String[parameters.keySet().size()]);
  -    }
  -
  -    /**
  -     * Returns the wrapper parameters.
  -     * @return A parameters object.
  -     */
  -    protected Parameters getParameters() {
  -        Properties properties = new Properties();
  -        properties.putAll(parameters);
  -        Parameters parametersObject = Parameters.fromProperties(properties);
  -        return parametersObject;
  -    }
  -    
  -    /**
  -     * Returns the user ID.
  -     * @return A string.
  -     */
  -    public String getUserId() {
  -        return (String) parameters.get(USER_ID);
  +    public String getPrefix() {
  +        return PREFIX;
       }
       
  -    /**
  -     * Returns the machine IP address.
  -     * @return A string.
  -     */
  -    public String getMachineIp() {
  -        return (String) parameters.get(MACHINE);
  -    }
  -    
  -    /**
  -     * Adds all key-value pairs in map to the parameters.
  -     * @param map A map.
  -     */
  -    protected void putAll(Map map) {
  -        for (Iterator i = map.keySet().iterator(); i.hasNext(); ) {
  -            String key = (String) i.next();
  -            putForced(key, (String) map.get(key));
  -        }
  -    }
  -
   }
  
  
  
  1.16      +1 -9      cocoon-lenya/src/java/org/apache/lenya/cms/task/Task.java
  
  Index: Task.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/task/Task.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Task.java	25 Aug 2003 09:54:10 -0000	1.15
  +++ Task.java	25 Aug 2003 15:40:55 -0000	1.16
  @@ -99,14 +99,6 @@
        */
       String PARAMETER_PUBLICATION_ID = "publication-id";
   
  -    String[] PARAMETERS =
  -        {
  -            PARAMETER_SERVLET_CONTEXT,
  -            PARAMETER_SERVER_URI,
  -            PARAMETER_SERVER_PORT,
  -            PARAMETER_CONTEXT_PREFIX,
  -            PARAMETER_PUBLICATION_ID };
  -
       /**
        * Execute the task. All parameters must have been set with parameterize().
        * 
  
  
  
  1.2       +30 -17    cocoon-lenya/src/java/org/apache/lenya/cms/task/Notifier.java
  
  Index: Notifier.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/task/Notifier.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Notifier.java	25 Aug 2003 09:52:40 -0000	1.1
  +++ Notifier.java	25 Aug 2003 15:40:55 -0000	1.2
  @@ -69,7 +69,7 @@
    * To change the template for this generated type comment go to
    * Window - Preferences - Java - Code Generation - Code and Comments
    */
  -public class Notifier {
  +public class Notifier extends ParameterWrapper {
   
       private static Category log = Category.getInstance(Notifier.class);
   
  @@ -79,35 +79,33 @@
   
       public static final String PARAMETER_TO = "tolist";
   
  -    private Parameters taskWrapperParameters;
       private TaskManager taskManager;
   
       /**
        * Ctor.
        * @param taskManager The task manager.
  -     * @param taskWrapperParameters The task wrapper parameters.
  +     * @param parameters The task wrapper parameters.
        */
  -    public Notifier(TaskManager taskManager, Parameters taskWrapperParameters) {
  -        this.taskWrapperParameters = taskWrapperParameters;
  +    public Notifier(TaskManager taskManager, Map parameters) {
  +        super(parameters);
           this.taskManager = taskManager;
       }
   
       /**
        * Sends the notification message.
  +     * @param taskParameters The task parameters.
        * @throws ExecutionException when something went wrong.
        */
  -    public void sendNotification() throws ExecutionException {
  +    public void sendNotification(TaskParameters taskParameters) throws ExecutionException {
   
  -        Map map = Parameters.toProperties(taskWrapperParameters);
  -        NamespaceMap notificationParameters = new NamespaceMap(map, NOTIFICATION_PREFIX);
  -
  -        if (notificationParameters.getMap().isEmpty()) {
  -            log.info("Not sending notification");
  -        } else {
  +        if (getMap().isEmpty()) {
  +            log.info("Not sending notification: no parameters provided.");
  +        } else if ("".equals(get(PARAMETER_TO).trim())) {
  +            log.info("Not sending notification: empty notification.tolist parameter.");
  +        }
  +        else {
               log.info("Sending notification");
  -
  -            NamespaceMap taskParameters = new NamespaceMap(map, TaskWrapperParameters.TASK_PREFIX);
  -
  +            
               Task task = taskManager.getTask(TaskManager.ANT_TASK);
   
               Parameters params = new Parameters();
  @@ -127,7 +125,7 @@
               }
   
               NamespaceMap mailMap = new NamespaceMap(MAIL_PREFIX);
  -            mailMap.putAll(notificationParameters.getMap());
  +            mailMap.putAll(getMap());
               NamespaceMap propertiesMap = new NamespaceMap(AntTask.PROPERTIES_PREFIX);
               propertiesMap.putAll(mailMap.getPrefixedMap());
   
  @@ -154,6 +152,21 @@
        */
       protected TaskManager getTaskManager() {
           return taskManager;
  +    }
  +
  +    /**
  +     * @see org.apache.lenya.cms.task.ParameterWrapper#getPrefix()
  +     */
  +    public String getPrefix() {
  +        return NOTIFICATION_PREFIX;
  +    }
  +
  +    /**
  +     * @see org.apache.lenya.cms.task.ParameterWrapper#getRequiredKeys()
  +     */
  +    protected String[] getRequiredKeys() {
  +        String[] requiredKeys = { };
  +        return requiredKeys;
       }
   
   }
  
  
  
  1.2       +89 -91    cocoon-lenya/src/java/org/apache/lenya/cms/task/DefaultTaskWrapper.java
  
  Index: DefaultTaskWrapper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/task/DefaultTaskWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultTaskWrapper.java	25 Aug 2003 09:52:40 -0000	1.1
  +++ DefaultTaskWrapper.java	25 Aug 2003 15:40:55 -0000	1.2
  @@ -56,21 +56,17 @@
   package org.apache.lenya.cms.task;
   
   import java.util.Enumeration;
  +import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Map;
  +import java.util.Properties;
   
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.environment.Request;
   import org.apache.lenya.cms.ac.Role;
   import org.apache.lenya.cms.ac2.Identity;
  -import org.apache.lenya.cms.publication.DefaultDocumentBuilder;
  -import org.apache.lenya.cms.publication.Document;
   import org.apache.lenya.cms.publication.Publication;
  -import org.apache.lenya.cms.workflow.WorkflowFactory;
   import org.apache.lenya.util.NamespaceMap;
  -import org.apache.lenya.workflow.Event;
  -import org.apache.lenya.workflow.Situation;
  -import org.apache.lenya.workflow.WorkflowInstance;
   import org.apache.lenya.xml.NamespaceHelper;
   import org.apache.log4j.Category;
   import org.w3c.dom.Element;
  @@ -84,24 +80,32 @@
   public class DefaultTaskWrapper implements TaskWrapper {
       
       private static Category log = Category.getInstance(DefaultTaskWrapper.class);
  -    
  +
  +    private Map parameters = new HashMap();
  +    private TaskWrapperParameters wrapperParameters = new TaskWrapperParameters(parameters);
  +    private WorkflowInvoker workflowInvoker = null;
  +    private TaskParameters taskParameters = new TaskParameters(parameters);
  +
       /**
        * Default ctor for subclasses.
        */
       protected DefaultTaskWrapper() {
       }
  -    
  +
       /**
        * Ctor to be called when all task wrapper parameters are known.
  -     * @param parameters The parameters.
  +     * @param parameters The prefixed parameters.
        */
       public DefaultTaskWrapper(Map parameters) {
           log.debug("Creating");
  -        for (Iterator i = parameters.keySet().iterator(); i.hasNext(); ) {
  -            String key = (String) i.next();
  -            String value = (String) parameters.get(key);
  -            log.debug("Setting task parameter: [" + key + "] = [" + value + "]");
  -            getParams().putForced(key, value);
  +        this.parameters.putAll(parameters);
  +        
  +        if (log.isDebugEnabled()) {
  +            for (Iterator i = parameters.keySet().iterator(); i.hasNext();) {
  +                String key = (String) i.next();
  +                String value = (String) parameters.get(key);
  +                log.debug("Setting parameter: [" + key + "] = [" + value + "]");
  +            }
           }
       }
   
  @@ -131,15 +135,15 @@
           Parameters parameters)
           throws ExecutionException {
           log.debug("Initializing");
  -            
  -        getParams().setPublication(publication);
  -        getParams().setWebappUrl(webappUrl);
  +
  +        getTaskParameters().setPublication(publication);
  +        getWrapperParameters().setWebappUrl(webappUrl);
   
           if (taskId == null) {
               throw new ExecutionException("No task id provided!");
           }
  -        getParams().setTaskId(taskId);
  -        getParams().setTaskParameters(parameters);
  +        getWrapperParameters().setTaskId(taskId);
  +        getTaskParameters().parameterize(parameters);
       }
   
       /**
  @@ -149,7 +153,10 @@
        * @param request A request.
        * @return A parameters object.
        */
  -    protected Parameters extractTaskParameters(Parameters parameters, Publication publication, Request request) {
  +    protected Parameters extractTaskParameters(
  +        Parameters parameters,
  +        Publication publication,
  +        Request request) {
           Parameters taskParameters = new Parameters();
           taskParameters.setParameter(
               Task.PARAMETER_SERVLET_CONTEXT,
  @@ -180,8 +187,6 @@
           return taskParameters;
       }
   
  -    private TaskWrapperParameters parameters = new TaskWrapperParameters();
  -
       /**
        * Enables workflow transition invocation.
        * @param eventName The event name.
  @@ -189,9 +194,7 @@
        * @param roles The roles of the identity.
        */
       public void setWorkflowAware(String eventName, Identity identity, Role[] roles) {
  -        parameters.put(TaskWrapperParameters.EVENT, eventName);
  -        parameters.setRoles(roles);
  -        parameters.setIdentity(identity);
  +        this.workflowInvoker = new WorkflowInvoker(getParameterMap(), eventName, identity, roles);
       }
   
       /**
  @@ -200,14 +203,14 @@
        */
       public void execute() throws ExecutionException {
   
  -        String taskId = getParams().getTaskId();
  +        String taskId = getWrapperParameters().getTaskId();
           log.debug("-----------------------------------");
           log.debug(" Executing task [" + taskId + "]");
           log.debug("-----------------------------------");
  -        
  -        if (!parameters.isComplete()) {
  -            
  -            String[] missingKeys = getParams().getMissingKeys();
  +
  +        if (!wrapperParameters.isComplete()) {
  +
  +            String[] missingKeys = getWrapperParameters().getMissingKeys();
               String keyString = "";
               for (int i = 0; i < missingKeys.length; i++) {
                   if (i > 0) {
  @@ -219,61 +222,37 @@
           }
   
           TaskManager manager;
  -        try {
   
  -            Publication publication = getParams().getPublication();
  +        Publication publication = getTaskParameters().getPublication();
   
  -            boolean doTransition = false;
  -            WorkflowFactory factory = null;
  -            Document document = null;
  -
  -            if (!getParams().getEventName().equals("")) {
  -                // check for workflow instance first (task can initialize the workflow history)
  -                factory = WorkflowFactory.newInstance();
  -                document =
  -                    DefaultDocumentBuilder.getInstance().buildDocument(
  -                        publication,
  -                        getParams().getWebappUrl());
  -                doTransition = factory.hasWorkflow(document);
  -            }
  +        if (workflowInvoker != null) {
  +            workflowInvoker.setup(publication, getWrapperParameters().getWebappUrl());
  +        }
   
  +        Task task;
  +        try {
               manager = new TaskManager(publication.getDirectory().getAbsolutePath());
  -            Task task = manager.getTask(taskId);
  -            task.parameterize(getParams().getTaskParameters());
  -
  -            //FIXME The new workflow is set before the end of the transition because the document id
  -            // and so the document are sometimes changing during the transition (ex archiving , ...) 
  -            if (doTransition) {
  -
  -                WorkflowInstance instance = factory.buildInstance(document);
  -                Situation situation =
  -                    factory.buildSituation(
  -                        getParams().getRoleIDs(),
  -                        getParams().getUserId(),
  -                        getParams().getMachineIp());
  -
  -                Event event = null;
  -                Event[] events = instance.getExecutableEvents(situation);
  -
  -                for (int i = 0; i < events.length; i++) {
  -                    if (events[i].getName().equals(getParams().getEventName())) {
  -                        event = events[i];
  -                    }
  -                }
  -
  -                assert event != null;
  -                instance.invoke(situation, event);
  -            }
  -
  -            task.execute(publication.getServletContext().getAbsolutePath());
  -
  -            Notifier notifier = new Notifier(manager, getParameters());
  -            notifier.sendNotification();
  +            task = manager.getTask(taskId);
               
  +            Properties properties = new Properties();
  +            properties.putAll(getTaskParameters().getMap());
  +            Parameters parameters = Parameters.fromProperties(properties);
  +            
  +            task.parameterize(parameters);
           } catch (Exception e) {
               throw new ExecutionException(e);
           }
  -        
  +
  +        //FIXME The new workflow is set before the end of the transition because the document id
  +        // and so the document are sometimes changing during the transition (ex archiving , ...) 
  +        if (workflowInvoker != null) {
  +            workflowInvoker.invokeTransition();
  +        }
  +
  +        task.execute(publication.getServletContext().getAbsolutePath());
  +
  +        Notifier notifier = new Notifier(manager, getParameterMap());
  +        notifier.sendNotification(getTaskParameters());
   
       }
   
  @@ -281,8 +260,16 @@
        * Returns the task wrapper parameters.
        * @return A task wrapper parameters object.
        */
  -    protected TaskWrapperParameters getParams() {
  -        return parameters;
  +    protected TaskWrapperParameters getWrapperParameters() {
  +        return wrapperParameters;
  +    }
  +    
  +    /**
  +     * Returns the task parameters.
  +     * @return A task parameters object.
  +     */
  +    protected TaskParameters getTaskParameters() {
  +        return taskParameters;
       }
   
       protected static final String ELEMENT_TASK = "task";
  @@ -301,11 +288,11 @@
               new NamespaceHelper(Task.NAMESPACE, Task.DEFAULT_PREFIX, document);
           Element element = taskHelper.createElement(ELEMENT_TASK);
   
  -        String[] keys = getParams().getKeys();
  -        for (int i = 0; i < keys.length; i++) {
  +        for (Iterator i = getParameterMap().keySet().iterator(); i.hasNext(); ) {
  +            String key = (String) i.next();
               Element parameterElement = taskHelper.createElement(ELEMENT_PARAMETER);
  -            parameterElement.setAttribute(ATTRIBUTE_NAME, keys[i]);
  -            parameterElement.setAttribute(ATTRIBUTE_VALUE, getParams().get(keys[i]));
  +            parameterElement.setAttribute(ATTRIBUTE_NAME, key);
  +            parameterElement.setAttribute(ATTRIBUTE_VALUE, (String) getParameterMap().get(key));
           }
   
           return element;
  @@ -325,25 +312,36 @@
           for (int i = 0; i < parameterElements.length; i++) {
               String key = parameterElements[i].getAttribute(ATTRIBUTE_NAME);
               String value = parameterElements[i].getAttribute(ATTRIBUTE_VALUE);
  -            getParams().put(key, value);
  +            getWrapperParameters().put(key, value);
           }
       }
  -    
  +
       /**
  -     * Returns the task wrapper parameters.
  +     * Returns all prefixed parameters.
        * @return A parameter object.
        */
       public Parameters getParameters() {
  -        return getParams().getParameters();
  +        Properties properties = new Properties();
  +        properties.putAll(getParameterMap());
  +        Parameters params = Parameters.fromProperties(properties);
  +        return params;
       }
  -    
  +
  +    /**
  +     * Returns all prefixed parameters.
  +     * @return A map.
  +     */
  +    public Map getParameterMap() {
  +        return parameters;
  +    }
  +
       /**
        * Sets the notification parameters.
        * @param notificationParameters The notification parameters.
        */
       protected void setNotifying(NamespaceMap notificationParameters) {
           log.info("Enabling notification");
  -        getParams().putAll(notificationParameters.getPrefixedMap());
  +        getParameterMap().putAll(notificationParameters.getPrefixedMap());
       }
  -    
  +
   }
  
  
  
  1.1                  cocoon-lenya/src/java/org/apache/lenya/cms/task/WorkflowInvoker.java
  
  Index: WorkflowInvoker.java
  ===================================================================
  /*
  $Id: WorkflowInvoker.java,v 1.1 2003/08/25 15:40:55 andreas Exp $
  <License>
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Lenya" and  "Apache Software Foundation"  must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
   ware Foundation, please see <http://www.apache.org/>.
  
   Lenya includes software developed by the Apache Software Foundation, W3C,
   DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
  </License>
  */
  package org.apache.lenya.cms.task;
  
  import java.util.Map;
  
  import org.apache.lenya.cms.ac.Machine;
  import org.apache.lenya.cms.ac.Role;
  import org.apache.lenya.cms.ac.User;
  import org.apache.lenya.cms.ac2.Identity;
  import org.apache.lenya.cms.publication.DefaultDocumentBuilder;
  import org.apache.lenya.cms.publication.Document;
  import org.apache.lenya.cms.publication.DocumentBuildException;
  import org.apache.lenya.cms.publication.Publication;
  import org.apache.lenya.cms.workflow.WorkflowFactory;
  import org.apache.lenya.workflow.Event;
  import org.apache.lenya.workflow.Situation;
  import org.apache.lenya.workflow.WorkflowInstance;
  import org.apache.log4j.Category;
  
  /**
   * @author andreas
   *
   * To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Generation - Code and Comments
   */
  public class WorkflowInvoker extends ParameterWrapper {
  
      private static Category log = Category.getInstance(WorkflowInvoker.class);
  
      public static final String ROLES = "roles";
      public static final String USER_ID = "user-id";
      public static final String MACHINE = "machine";
      public static final String EVENT = "event";
      public static final String EVENT_REQUEST_PARAMETER = "lenya.event";
  
      public static final String PREFIX = "workflow";
  
      /**
       * Ctor.
       * @param parameters A map containing the prefixed parameters.
       * @param eventName The event name.
       * @param identity The identity.
       * @param roles The roles.
       */
      public WorkflowInvoker(Map parameters, String eventName, Identity identity, Role[] roles) {
          this(parameters);
          log.debug("Creating workflow invoker.");
          log.debug("    Event: [" + eventName + "]");
          put(EVENT, eventName);
          setRoles(roles);
          setIdentity(identity);
      }
  
      /**
       * Ctor.
       * @param parameters A map containing the prefixed parameters.
       */
      public WorkflowInvoker(Map parameters) {
          super(parameters);
      }
  
      /**
       * Returns the role names.
       * @return A string array.
       */
      protected String[] getRoleIDs() {
          String rolesString = get(ROLES);
          String[] roleIDs = rolesString.split(",");
          return roleIDs;
      }
  
      /**
       * Sets the roles.
       * @param roles A role array.
       */
      public void setRoles(Role[] roles) {
  
          String roleString = "";
          for (int i = 0; i < roles.length; i++) {
              if (i > 0) {
                  roleString += ",";
              }
              roleString += roles[i].getId();
          }
          put(ROLES, roleString);
      }
  
      /**
       * Sets the identity.
       * @param identity An identity.
       */
      public void setIdentity(Identity identity) {
  
          String userId = "";
          User user = identity.getUser();
          if (user != null) {
              userId = user.getId();
          }
          put(USER_ID, userId);
  
          String machineIp = "";
          Machine machine = identity.getMachine();
          if (machine != null) {
              machineIp = machine.getIp();
          }
          put(MACHINE, machineIp);
      }
  
      /**
       * Returns the workflow event name.
       * @return A string.
       */
      public String getEventName() {
          return get(EVENT);
      }
  
      /**
       * Returns the user ID.
       * @return A string.
       */
      public String getUserId() {
          return get(USER_ID);
      }
  
      /**
       * Returns the machine IP address.
       * @return A string.
       */
      public String getMachineIp() {
          return get(MACHINE);
      }
  
      private Document document;
      private boolean doTransition = false;
  
      /**
       * Initializes the workflow invoker.
       * @param publication The publication.
       * @param webappUrl The webapp URL.
       * @throws ExecutionException when something went wrong.
       */
      public void setup(Publication publication, String webappUrl) throws ExecutionException {
          String eventName = getEventName();
          if (eventName == null) {
              log.debug("No workflow event.");
          } else {
              log.debug("Workflow event: [" + eventName + "]");
              // check for workflow instance first (task can initialize the workflow history)
              WorkflowFactory factory = WorkflowFactory.newInstance();
              try {
                  document =
                      DefaultDocumentBuilder.getInstance().buildDocument(publication, webappUrl);
              } catch (DocumentBuildException e) {
                  throw new ExecutionException(e);
              }
              doTransition = factory.hasWorkflow(document);
          }
      }
  
      /**
       * Invokes the transition.
       * @throws ExecutionException when something went wrong.
       */
      public void invokeTransition() throws ExecutionException {
          if (doTransition) {
              
              log.debug("Invoking transition.");
  
              try {
                  WorkflowFactory factory = WorkflowFactory.newInstance();
                  WorkflowInstance instance = factory.buildInstance(document);
                  Situation situation =
                      factory.buildSituation(getRoleIDs(), getUserId(), getMachineIp());
  
                  Event event = null;
                  Event[] events = instance.getExecutableEvents(situation);
  
                  for (int i = 0; i < events.length; i++) {
                      if (events[i].getName().equals(getEventName())) {
                          event = events[i];
                      }
                  }
  
                  assert event != null;
                  instance.invoke(situation, event);
  
              } catch (Exception e) {
                  throw new ExecutionException(e);
              }
          }
  
      }
  
      /**
       * @see org.apache.lenya.cms.task.ParameterWrapper#getPrefix()
       */
      public String getPrefix() {
          return PREFIX;
      }
  
      /**
       * @see org.apache.lenya.cms.task.ParameterWrapper#getRequiredKeys()
       */
      protected String[] getRequiredKeys() {
          String[] keys = { };
          return keys;
      }
  
  }
  
  
  
  1.1                  cocoon-lenya/src/java/org/apache/lenya/cms/task/ParameterWrapper.java
  
  Index: ParameterWrapper.java
  ===================================================================
  /*
  $Id: ParameterWrapper.java,v 1.1 2003/08/25 15:40:55 andreas Exp $
  <License>
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Lenya" and  "Apache Software Foundation"  must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
   ware Foundation, please see <http://www.apache.org/>.
  
   Lenya includes software developed by the Apache Software Foundation, W3C,
   DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
  </License>
  */
  package org.apache.lenya.cms.task;
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Map;
  
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.lenya.util.NamespaceMap;
  import org.apache.log4j.Category;
  
  /**
   * @author andreas
   *
   * To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Generation - Code and Comments
   */
  public abstract class ParameterWrapper {
      
      private static Category log = Category.getInstance(ParameterWrapper.class);
      private NamespaceMap parameters;
      
      /**
       * Returns the un-prefixed parameters.
       * @return A map.
       */
      public Map getMap() {
          return parameters.getMap();
      }
  
      /**
       * Ctor.
       * @param prefixedParameters The prefixed parameters to wrap.
       */
      public ParameterWrapper(Map prefixedParameters) {
          parameters = new NamespaceMap(prefixedParameters, getPrefix());
      }
      
      /**
       * Returns the namespace prefix.
       * @return A string.
       */
      public abstract String getPrefix();
      
      /**
       * Adds a key-value pair. If the value is null, no pair is added.
       * @param key The key.
       * @param value The value.
       */
      public void put(String key, String value) {
          if (value != null) {
              log.debug("Setting parameter: [" + key + "] = [" + value + "]");
              parameters.put(key, value);
          }
          else {
              log.debug("Not setting parameter: [" + key + "] = [" + value + "]");
          }
      }
      
      /**
       * Returns the value for a key.
       * @param key The key.
       * @return The value.
       */
      public String get(String key) {
          return (String) parameters.get(key);
      }
      
      /**
       * Returns the required keys.
       * @return A string array.
       */
      protected abstract String[] getRequiredKeys();
      
      /**
       * Checks if this parameters object contains all necessary parameters.
       * @return A boolean value.
       */
      public boolean isComplete() {
          boolean complete = true;
          Map parameterMap = getMap();
          String[] requiredKeys = getRequiredKeys();
          int i = 0;
          while (complete && i < requiredKeys.length) {
              log.debug("Checking parameter: [" + requiredKeys[i] + "]");
              complete = complete && parameterMap.containsKey(requiredKeys[i]);
              log.debug("OK: [" + complete + "]");
              i++;
          }
          return complete;
      }
  
      /**
       * Returns the missing parameters parameters.
       * @return A string array.
       */
      public String[] getMissingKeys() {
          String[] requiredKeys = getRequiredKeys();
          Map parameterMap = getMap();
          List keyList = new ArrayList();
          for (int i = 0; i < requiredKeys.length; i++) {
              if (!parameterMap.containsKey(requiredKeys[i])) {
                  keyList.add(requiredKeys[i]);
              }
          }
          return (String[]) keyList.toArray(new String[keyList.size()]);
      }
      
      /**
       * Parameterizes this wrapper with un-prefixed parameters.
       * @param parameters A parameters object.
       */
      public void parameterize(Parameters parameters) {
          String[] keys = parameters.getNames();
          for (int i = 0; i < keys.length; i++) {
              put(keys[i], parameters.getParameter(keys[i], null));
          }
      }
      
  }
  
  
  
  1.1                  cocoon-lenya/src/java/org/apache/lenya/cms/task/TaskParameters.java
  
  Index: TaskParameters.java
  ===================================================================
  /*
  $Id: TaskParameters.java,v 1.1 2003/08/25 15:40:55 andreas Exp $
  <License>
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Lenya" and  "Apache Software Foundation"  must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
   ware Foundation, please see <http://www.apache.org/>.
  
   Lenya includes software developed by the Apache Software Foundation, W3C,
   DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
  </License>
  */
  package org.apache.lenya.cms.task;
  
  import java.util.Map;
  
  import org.apache.lenya.cms.publication.Publication;
  import org.apache.lenya.cms.publication.PublicationException;
  import org.apache.lenya.cms.publication.PublicationFactory;
  import org.apache.log4j.Category;
  
  /**
   * @author andreas
   *
   * To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Generation - Code and Comments
   */
  public class TaskParameters extends ParameterWrapper {
      private static Category log = Category.getInstance(TaskParameters.class);
  
      public static final String[] REQUIRED_KEYS =
          {
              Task.PARAMETER_SERVLET_CONTEXT,
              Task.PARAMETER_SERVER_URI,
              Task.PARAMETER_SERVER_PORT,
              Task.PARAMETER_CONTEXT_PREFIX,
              Task.PARAMETER_PUBLICATION_ID };
  
      /**
       * Ctor.
       * @param prefixedParameters The prefixed parameters .
       */
      public TaskParameters(Map prefixedParameters) {
          super(prefixedParameters);
      }
  
      public static final String PREFIX = "task";
  
      /**
       * @see org.apache.lenya.cms.task.ParameterWrapper#getPrefix()
       */
      public String getPrefix() {
          return PREFIX;
      }
  
      /**
       * @see org.apache.lenya.cms.task.ParameterWrapper#getRequiredKeys()
       */
      protected String[] getRequiredKeys() {
          return REQUIRED_KEYS;
      }
  
      /**
       * Returns the publication.
       * @return A publication.
       * @throws ExecutionException when something went wrong.
       */
      public Publication getPublication() throws ExecutionException {
          Publication publication;
          try {
              publication =
                  PublicationFactory.getPublication(
                      (String) get(Task.PARAMETER_PUBLICATION_ID),
                      (String) get(Task.PARAMETER_SERVLET_CONTEXT));
          } catch (PublicationException e) {
              throw new ExecutionException(e);
          }
          return publication;
      }
  
      /**
       * Sets the publication.
       * @param publication A publication.
       */
      public void setPublication(Publication publication) {
          put(Task.PARAMETER_PUBLICATION_ID, publication.getId());
          put(
              Task.PARAMETER_SERVLET_CONTEXT,
              publication.getServletContext().getAbsolutePath());
      }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org