1 17 18 19 20 package org.apache.lenya.cms.task; 21 22 import java.util.Map ; 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 [] 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 41 public TaskParameters(Map prefixedParameters) { 42 super(prefixedParameters); 43 } 44 45 public static final String PREFIX = "task"; 46 47 50 public String getPrefix() { 51 return PREFIX; 52 } 53 54 57 protected String [] getRequiredKeys() { 58 return REQUIRED_KEYS; 59 } 60 61 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 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 92 public void setServletContextPath(String servletContextPath) { 93 put(Task.PARAMETER_SERVLET_CONTEXT, servletContextPath); 94 } 95 96 } 97 | Popular Tags |