use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class KeyTransformer method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String cacheKey = keyTransformer.transformKey((String) input, session);
Cache cache = ibisCacheManager.getCache(cacheName);
if (cache.remove("r" + cacheKey) && cache.remove("s" + cacheKey)) {
log.debug("removed cache key [" + cacheKey + "] from cache [" + cacheName + "]");
} else {
log.warn("could not find cache key [" + cacheKey + "] to remove from cache [" + cacheName + "]");
}
return new PipeRunResult(getForward(), input);
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class BatchFileTransformerPipe method doPipe.
/**
* Open a reader for the file named according the input messsage and
* transform it.
* Move the input file to a done directory when transformation is finished
* and return the names of the generated files.
*
* @see nl.nn.adapterframework.core.IPipe#doPipe(java.lang.Object, nl.nn.adapterframework.core.IPipeLineSession)
*/
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
if (input == null) {
throw new PipeRunException(this, "got null input instead of String containing filename");
}
if (!(input instanceof String)) {
throw new PipeRunException(this, "expected String containing filename as input, got [" + ClassUtils.nameOf(input) + "], value [" + input + "]");
}
String filename = input.toString();
File file = new File(filename);
try {
PipeRunResult result = super.doPipe(file, session);
try {
FileUtils.moveFileAfterProcessing(file, getMove2dirAfterTransform(), isDelete(), isOverwrite(), getNumberOfBackups());
} catch (Exception e) {
log.error(getLogPrefix(session), e);
}
return result;
} catch (PipeRunException e) {
try {
FileUtils.moveFileAfterProcessing(file, getMove2dirAfterError(), isDelete(), isOverwrite(), getNumberOfBackups());
} catch (Exception e2) {
log.error(getLogPrefix(session) + "Could not move file after exception [" + e2 + "]");
}
throw e;
}
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class TransactionAttributePipeProcessor method processPipe.
public PipeRunResult processPipe(PipeLine pipeLine, IPipe pipe, String messageId, Object message, IPipeLineSession pipeLineSession) throws PipeRunException {
PipeRunResult pipeRunResult;
int txOption;
int txTimeout = 0;
if (pipe instanceof HasTransactionAttribute) {
HasTransactionAttribute taPipe = (HasTransactionAttribute) pipe;
txOption = taPipe.getTransactionAttributeNum();
txTimeout = taPipe.getTransactionTimeout();
} else {
txOption = TransactionDefinition.PROPAGATION_SUPPORTS;
}
// TransactionStatus txStatus = txManager.getTransaction(SpringTxManagerProxy.getTransactionDefinition(txOption,txTimeout));
IbisTransaction itx = new IbisTransaction(txManager, SpringTxManagerProxy.getTransactionDefinition(txOption, txTimeout), "pipe [" + pipe.getName() + "]");
TransactionStatus txStatus = itx.getStatus();
try {
TimeoutGuard tg = new TimeoutGuard("pipeline of adapter [" + pipeLine.getOwner().getName() + "] running pipe [" + pipe.getName() + "]");
Throwable tCaught = null;
try {
tg.activateGuard(txTimeout);
pipeRunResult = pipeProcessor.processPipe(pipeLine, pipe, messageId, message, pipeLineSession);
} catch (Throwable t) {
tCaught = t;
throw tCaught;
} finally {
if (tg.cancel()) {
if (tCaught == null) {
throw new PipeRunException(pipe, tg.getDescription() + " was interrupted");
} else {
log.warn("Thread interrupted, but propagating other caught exception of type [" + ClassUtils.nameOf(tCaught) + "]");
}
}
}
} catch (Throwable t) {
log.debug("setting RollBackOnly for pipe [" + pipe.getName() + "] after catching exception");
txStatus.setRollbackOnly();
if (t instanceof Error) {
throw (Error) t;
} else if (t instanceof RuntimeException) {
throw (RuntimeException) t;
} else if (t instanceof PipeRunException) {
throw (PipeRunException) t;
} else {
throw new PipeRunException(pipe, "Caught unknown checked exception", t);
}
} finally {
// txManager.commit(txStatus);
itx.commit();
}
return pipeRunResult;
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class PasswordHashPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
Object result;
PipeForward pipeForward;
if (StringUtils.isEmpty(getHashSessionKey())) {
try {
if (getRoundsSessionKey() == null) {
result = PasswordHash.createHash(input.toString().toCharArray(), getRounds());
} else {
result = PasswordHash.createHash(input.toString().toCharArray(), Integer.valueOf(session.get(getRoundsSessionKey()).toString()));
}
pipeForward = getForward();
} catch (Exception e) {
throw new PipeRunException(this, "Could not hash password", e);
}
} else {
try {
result = input;
if (PasswordHash.validatePassword(input.toString(), (String) session.get(getHashSessionKey()))) {
pipeForward = getForward();
} else {
pipeForward = findForward(FAILURE_FORWARD_NAME);
}
} catch (Exception e) {
throw new PipeRunException(this, "Could not validate password", e);
}
}
return new PipeRunResult(pipeForward, result);
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class PutParametersInSession method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
ParameterValueList pvl = null;
ParameterList parameterList = getParameterList();
if (parameterList != null) {
ParameterResolutionContext prc = new ParameterResolutionContext((String) input, session);
try {
pvl = prc.getValues(getParameterList());
if (pvl != null) {
for (int i = 0; i < parameterList.size(); i++) {
Parameter parameter = parameterList.getParameter(i);
String pn = parameter.getName();
Object pv = parameter.getValue(pvl, prc);
session.put(pn, pv);
log.debug(getLogPrefix(session) + "stored [" + pv + "] in pipeLineSession under key [" + pn + "]");
}
}
} catch (ParameterException e) {
throw new PipeRunException(this, getLogPrefix(session) + "exception extracting parameters", e);
}
}
return new PipeRunResult(getForward(), input);
}
Aggregations