1 16 package org.outerj.daisy.books.publisher.impl.publicationprocess; 17 18 import org.apache.cocoon.components.flow.util.PipelineUtil; 19 import org.apache.cocoon.components.LifecycleHelper; 20 21 import java.util.Map ; 22 import java.io.OutputStream ; 23 24 public class PublicationProcessTaskUtil { 25 public static String getFileName(String path) { 26 int position = path.lastIndexOf('/'); 27 if (position == -1) { 28 return path; 29 } else { 30 return path.substring(position + 1); 31 } 32 } 33 34 public static void executePipeline(String pipe, Map viewData, OutputStream os, PublicationContext context) throws Exception { 35 PipelineUtil pipelineUtil = new PipelineUtil(); 36 try { 37 LifecycleHelper.setupComponent(pipelineUtil, null, context.getAvalonContext(), context.getServiceManager(), null, false); 38 pipelineUtil.processToStream(pipe, viewData, os); 39 } finally { 40 LifecycleHelper.dispose(pipelineUtil); 41 } 42 } 43 44 public static String getRequiredAttribute(Map attributes, String attrName, String processTaskName) throws Exception { 45 String value = (String )attributes.get(attrName); 46 if (value == null || value.trim().length() == 0) { 47 throw new Exception ("Missing attribute for process task " + processTaskName + ": " + attrName); 48 } 49 return value; 50 } 51 } 52 | Popular Tags |