use of org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrategy in project camel by apache.
the class SftpProcessStrategyFactory method createGenericFileProcessStrategy.
public static GenericFileProcessStrategy<ChannelSftp.LsEntry> createGenericFileProcessStrategy(CamelContext context, Map<String, Object> params) {
// We assume a value is present only if its value not null for String and 'true' for boolean
Expression moveExpression = (Expression) params.get("move");
Expression moveFailedExpression = (Expression) params.get("moveFailed");
Expression preMoveExpression = (Expression) params.get("preMove");
boolean isNoop = params.get("noop") != null;
boolean isDelete = params.get("delete") != null;
boolean isMove = moveExpression != null || preMoveExpression != null || moveFailedExpression != null;
if (isDelete) {
GenericFileDeleteProcessStrategy<ChannelSftp.LsEntry> strategy = new GenericFileDeleteProcessStrategy<ChannelSftp.LsEntry>();
strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
if (preMoveExpression != null) {
GenericFileExpressionRenamer<ChannelSftp.LsEntry> renamer = new GenericFileExpressionRenamer<ChannelSftp.LsEntry>();
renamer.setExpression(preMoveExpression);
strategy.setBeginRenamer(renamer);
}
if (moveFailedExpression != null) {
GenericFileExpressionRenamer<ChannelSftp.LsEntry> renamer = new GenericFileExpressionRenamer<ChannelSftp.LsEntry>();
renamer.setExpression(moveFailedExpression);
strategy.setFailureRenamer(renamer);
}
return strategy;
} else if (isMove || isNoop) {
GenericFileRenameProcessStrategy<ChannelSftp.LsEntry> strategy = new GenericFileRenameProcessStrategy<ChannelSftp.LsEntry>();
strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
if (!isNoop && moveExpression != null) {
// move on commit is only possible if not noop
GenericFileExpressionRenamer<ChannelSftp.LsEntry> renamer = new GenericFileExpressionRenamer<ChannelSftp.LsEntry>();
renamer.setExpression(moveExpression);
strategy.setCommitRenamer(renamer);
}
// both move and noop supports pre move
if (moveFailedExpression != null) {
GenericFileExpressionRenamer<ChannelSftp.LsEntry> renamer = new GenericFileExpressionRenamer<ChannelSftp.LsEntry>();
renamer.setExpression(moveFailedExpression);
strategy.setFailureRenamer(renamer);
}
// both move and noop supports pre move
if (preMoveExpression != null) {
GenericFileExpressionRenamer<ChannelSftp.LsEntry> renamer = new GenericFileExpressionRenamer<ChannelSftp.LsEntry>();
renamer.setExpression(preMoveExpression);
strategy.setBeginRenamer(renamer);
}
return strategy;
} else {
// default strategy will do nothing
GenericFileNoOpProcessStrategy<ChannelSftp.LsEntry> strategy = new GenericFileNoOpProcessStrategy<ChannelSftp.LsEntry>();
strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
return strategy;
}
}
use of org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrategy in project camel by apache.
the class FtpProcessStrategyFactory method createGenericFileProcessStrategy.
public static GenericFileProcessStrategy<FTPFile> createGenericFileProcessStrategy(CamelContext context, Map<String, Object> params) {
// We assume a value is present only if its value not null for String and 'true' for boolean
Expression moveExpression = (Expression) params.get("move");
Expression moveFailedExpression = (Expression) params.get("moveFailed");
Expression preMoveExpression = (Expression) params.get("preMove");
boolean isNoop = params.get("noop") != null;
boolean isDelete = params.get("delete") != null;
boolean isMove = moveExpression != null || preMoveExpression != null || moveFailedExpression != null;
if (isDelete) {
GenericFileDeleteProcessStrategy<FTPFile> strategy = new GenericFileDeleteProcessStrategy<FTPFile>();
strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
if (preMoveExpression != null) {
GenericFileExpressionRenamer<FTPFile> renamer = new GenericFileExpressionRenamer<FTPFile>();
renamer.setExpression(preMoveExpression);
strategy.setBeginRenamer(renamer);
}
if (moveFailedExpression != null) {
GenericFileExpressionRenamer<FTPFile> renamer = new GenericFileExpressionRenamer<FTPFile>();
renamer.setExpression(moveFailedExpression);
strategy.setFailureRenamer(renamer);
}
return strategy;
} else if (isMove || isNoop) {
GenericFileRenameProcessStrategy<FTPFile> strategy = new GenericFileRenameProcessStrategy<FTPFile>();
strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
if (!isNoop && moveExpression != null) {
// move on commit is only possible if not noop
GenericFileExpressionRenamer<FTPFile> renamer = new GenericFileExpressionRenamer<FTPFile>();
renamer.setExpression(moveExpression);
strategy.setCommitRenamer(renamer);
}
// both move and noop supports pre move
if (moveFailedExpression != null) {
GenericFileExpressionRenamer<FTPFile> renamer = new GenericFileExpressionRenamer<FTPFile>();
renamer.setExpression(moveFailedExpression);
strategy.setFailureRenamer(renamer);
}
// both move and noop supports pre move
if (preMoveExpression != null) {
GenericFileExpressionRenamer<FTPFile> renamer = new GenericFileExpressionRenamer<FTPFile>();
renamer.setExpression(preMoveExpression);
strategy.setBeginRenamer(renamer);
}
return strategy;
} else {
// default strategy will do nothing
GenericFileNoOpProcessStrategy<FTPFile> strategy = new GenericFileNoOpProcessStrategy<FTPFile>();
strategy.setExclusiveReadLockStrategy(getExclusiveReadLockStrategy(params));
return strategy;
}
}
Aggregations