I have an odd case and Google is not helpful because its an odd case (file producer is always matched). I need to convert PDFs to SWF on linux in a route. The most common tool is called pdf2swf but it has a problem characteristic, it can only read from a file and not a pipe because it reads the file twice. The operations in in the middle of a bunch of routes kicked off from a JMS message. It works fine in the route shown below. The issue is that I am left with at least one file. The camel file consumer does a great job of cleaning up after itself if one wants. Who would expect the file consumer to delete the file it had just written? I have not found a component that just does OS level file manipulation without reading or writing (that doesn't mean there isn't one just that I have not found it). I could write a component (but the point of Camel is to not reinvent the wheel unnecessarily) or just call Java file operations. I can do command line operations though they would be platform specific. I really don't like going around Camel if there is a way to do something with Camel. And in the route I already know the name of the file(s) and I am done with them by the end of the route.
Does anyone have a suggestion for doing this from XML DSL or Java DSL without going around Camel? <route id="DerivativesProcessPDF2SWF"> <from uri="direct:processDerivativesPDF2SWF"/> <log message="${id} Derivatives: Started PDF2SWF processing ..." loggingLevel="DEBUG" logName="edu.si.derivatives"/> <!-- Create a Flash derivative using pdf2swf for the Flexpaper viewer. --> <!-- Unfortunately pdf2swf cannot accept a pipe as an input stream source, hence we use a temporary file. --> <to uri="file://staging/"/> <!-- This will create a temporary file that must be cleaned out. --> <recipientList> <simple> exec:pdf2swf?args=${header.CamelFileNameProduced} -o ${header.CamelFileNameProduced}.swf </simple> </recipientList> <choice> <when> <simple> ${headers.CamelExecExitValue} == 0 </simple> <to uri="fedora:addDatastream?name=OBJ.swf&type=application/x-shockwave-flash&group=M&dsLabel=Flexpaper&versionable=false"/> </when> <otherwise> <log message="${id} Derivatives: Unable to convert PDF to SWF. PID: ${headers.CamelFedoraPid} ${headers.CamelExecExitValue}" loggingLevel="ERROR"/> </otherwise> </choice> <log message="${id} Derivatives: Finished PDF2SWF processing." loggingLevel="DEBUG" logName="edu.si.derivatives"/> </route> -- Daniel Davis Technical Manager - Office of Research Information Systems Smithsonian Institution