1 17 18 19 20 package org.apache.lenya.cms.cocoon.scheduler; 21 22 import java.util.HashMap ; 23 import java.util.Map ; 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 44 public SchedulerHelper(Map 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 objectModel; 53 54 59 public Map createParameters() throws ProcessingException { 60 61 Map map = new HashMap (); 62 63 try { 64 TaskWrapper wrapper = new CocoonTaskWrapper(objectModel, parameters); 65 66 logger.debug("Adding task wrapper parameters"); 67 Map 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 e) { 83 throw new ProcessingException(e); 84 } 85 86 return map; 87 } 88 89 } 90 | Popular Tags |