Поток синтаксического анализа ввода XML-файла Mule

У меня есть следующий поток Mule:

<?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>

Мне нужно разбить и проанализировать будущий входной xml-файл. Если файл по каким-то причинам недействителен, мне нужно поймать исключение и переместить файл в специальную папку. Когда я пытаюсь сделать это с помощью Java-компонента AxaptaValidationFailure, я обнаруживаю, что входной файл исчезает из входной папки при возникновении исключения.

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;
}
}

Линия

текущийФайл = Новый Файл("d:\WORK\Input\"+ originalFilenameProperty);

не могу найти входной файл

Подскажите, заранее спасибо.


person user3042795    schedule 03.12.2013    source источник


Ответы (1)


Ты пробовал:

currentFile = new File("D:\WORK\Input\"+ originalFilenameProperty);

то есть заглавная буква D для буквы диска?

person Gabriel Dimech    schedule 15.12.2013