org.mule.modules.ftpclient.RenameStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ftp-client-connector Show documentation
Show all versions of ftp-client-connector Show documentation
A Mule connector for ftp/sftp.
package org.mule.modules.ftpclient;
import java.util.function.Consumer;
import org.mule.api.MuleContext;
import org.mule.api.MuleMessage;
import org.mule.api.expression.ExpressionManager;
/**
* A strategy which can rename files (within the same directory).
*/
public class RenameStrategy implements CompletionStrategy {
private MuleContext muleContext;
private String filenameExpression;
private String originalFilenameExpression;
public RenameStrategy(MuleContext muleContext, String filenameExpression, String originalFilenameExpression) {
this.muleContext = muleContext;
this.filenameExpression = filenameExpression;
this.originalFilenameExpression = originalFilenameExpression;
}
@Override
public Consumer createCompletionHandler(MuleMessage message, String filename,
String translatedName) {
ExpressionManager expressionManager = muleContext.getExpressionManager();
String moveToFilename = (String) expressionManager.evaluate(filenameExpression, null, message, true);
String moveToOriginalFilename = (String) expressionManager.evaluate(originalFilenameExpression, null, message,
true);
return new FileArchiver(translatedName, moveToFilename, filename, moveToOriginalFilename);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy