I have the following Mule flow:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/file
http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-
current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/ee/tracking
http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<mulexml:dom-to-xml-transformer name="domToXml"/>
<flow name="SplitterFlow1" doc:name="SplitterFlow1">
<file:inbound-endpoint path="D:\WORK\Input"
responseTimeout="10000" doc:name="File" encoding="UTF-8" tracking:enable-default-events="true"
moveToDirectory="D:\WORK\Output"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<byte-array-to-string-transformer doc:name="Byte Array to String" />
<splitter evaluator="xpath" expression="/Invoices/invoice"
doc:name="Splitter"/>
<transformer ref="domToXml" doc:name="Transformer Reference"/>
<tracking:custom-event event-name="Invoice ID" doc:name="Custom Business event">
<tracking:meta-data key="Invoice ID" value="#[message.payload]"/>
</tracking:custom-event>
<logger level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="D:\WORK\Output"
outputPattern="#[function:dateStamp:dd-MM-yyyy-HH.mm.ss]-#[header:OUTBOUND:MULE_CORRELATION_SEQUENCE]"
responseTimeout="10000" doc:name="File"></file:outbound-endpoint>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<component doc:name="Java"
class="no.schibsted.exception_strategy.file.Validationfailure.AxaptaValidationFailure"/>
</catch-exception-strategy>
</flow>
</mule>
I need to split and parse in future input xml file. If the file is invalid for some reasons, I need catch exception and move the file in special folder. When I try to do it by using AxaptaValidationFailure Java component, I find out that input file disappears from input folder when exception is thrown.
public class AxaptaValidationFailure implements Callable{
protected transient Log logger = LogFactory.getLog(getClass());
private File currentFile;
private File moveToOnClose;
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
MuleMessage message = eventContext.getMessage();
Object originalFilenameProperty = message.getInboundProperty("originalFilename");
currentFile = new File("d:\\WORK\\Input\\"+ originalFilenameProperty);
moveToOnClose = new File("d:\\WORK\\Output_Validation_Failure\\"+ originalFilenameProperty);
if (!FileUtils.moveFileWithCopyFallback(currentFile, moveToOnClose))
{
logger.warn(String.format("Failed to move file from %s to %s\n", currentFile.getPath(),
moveToOnClose.getPath()));
}
return originalFilenameProperty;
}
}
The line
currentFile = new File("d:\WORK\Input\"+ originalFilenameProperty);
cannot find input file
Please advise, thanks in advance.
Did you try:
i.e. a capital "D" for the drive letter?