use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class XmlIf method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String forward = "";
PipeForward pipeForward = null;
String sInput;
if (StringUtils.isEmpty(getSessionKey())) {
if (input == null) {
sInput = "";
} else {
sInput = input.toString();
}
} else {
log.debug(getLogPrefix(session) + "taking input from sessionKey [" + getSessionKey() + "]");
sInput = (String) session.get(getSessionKey());
}
if (tp != null) {
try {
forward = tp.transform(sInput, null, isNamespaceAware());
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot evaluate expression", e);
}
} else {
if (StringUtils.isEmpty(expressionValue)) {
if (StringUtils.isEmpty(sInput)) {
forward = elseForwardName;
} else {
forward = thenForwardName;
}
} else {
if (sInput.equals(expressionValue)) {
forward = thenForwardName;
} else {
forward = elseForwardName;
}
}
}
log.debug(getLogPrefix(session) + "determined forward [" + forward + "]");
pipeForward = findForward(forward);
if (pipeForward == null) {
throw new PipeRunException(this, getLogPrefix(null) + "cannot find forward or pipe named [" + forward + "]");
}
log.debug(getLogPrefix(session) + "resolved forward [" + forward + "] to path [" + pipeForward.getPath() + "]");
return new PipeRunResult(pipeForward, input);
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class XmlSwitch method doPipe.
/**
* This is where the action takes place, the switching is done. Pipes may only throw a PipeRunException,
* to be handled by the caller of this object.<br/>
* As WebLogic has the problem that when an non-well formed XML stream is given to
* weblogic.xerces the transformer gets corrupt, on an exception the configuration is done again, so that the
* transformer is re-initialized.
*/
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String forward = "";
String sInput = (String) input;
PipeForward pipeForward = null;
if (StringUtils.isNotEmpty(getSessionKey())) {
sInput = (String) session.get(sessionKey);
}
if (transformerPool != null) {
ParameterList parameterList = null;
ParameterResolutionContext prc = new ParameterResolutionContext(sInput, session, isNamespaceAware());
;
try {
Map parametervalues = null;
if (getParameterList() != null) {
parameterList = getParameterList();
parametervalues = prc.getValueMap(parameterList);
}
forward = transformerPool.transform(prc.getInputSource(), parametervalues);
} catch (Throwable e) {
throw new PipeRunException(this, getLogPrefix(session) + "got exception on transformation", e);
}
} else {
forward = sInput;
}
log.debug(getLogPrefix(session) + "determined forward [" + forward + "]");
if (StringUtils.isEmpty(forward) && getEmptyForwardName() != null) {
throwEvent(XML_SWITCH_FORWARD_FOUND_MONITOR_EVENT);
pipeForward = findForward(getEmptyForwardName());
} else {
if (findForward(forward) != null) {
throwEvent(XML_SWITCH_FORWARD_FOUND_MONITOR_EVENT);
pipeForward = findForward(forward);
} else {
log.info(getLogPrefix(session) + "determined forward [" + forward + "], which is not defined. Will use [" + getNotFoundForwardName() + "] instead");
throwEvent(XML_SWITCH_FORWARD_NOT_FOUND_MONITOR_EVENT);
pipeForward = findForward(getNotFoundForwardName());
}
}
if (pipeForward == null) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot find forward or pipe named [" + forward + "]");
}
return new PipeRunResult(pipeForward, input);
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class XsltPipe method doPipe.
/**
* Here the actual transforming is done. Under weblogic the transformer object becomes
* corrupt when a not-well formed xml was handled. The transformer is then re-initialized
* via the configure() and start() methods.
*/
@Override
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
if (input == null) {
throw new PipeRunException(this, getLogPrefix(session) + "got null input");
}
if (!(input instanceof String)) {
throw new PipeRunException(this, getLogPrefix(session) + "got an invalid type as input, expected String, got " + input.getClass().getName());
}
String stringResult = (String) input;
// ParameterResolutionContext prc = new ParameterResolutionContext((String)input, session, isNamespaceAware());
try {
ParameterResolutionContext prc = getInput(stringResult, session);
Map parametervalues = null;
ParameterList parameterList = getParameterList();
if (parameterList != null) {
parametervalues = prc.getValueMap(parameterList);
}
// stringResult = transformerPool.transform(prc.getInputSource(), parametervalues);
stringResult = transform(transformerPool, prc.getInputSource(), parametervalues);
if (isSkipEmptyTags()) {
log.debug(getLogPrefix(session) + " skipping empty tags from result [" + stringResult + "]");
// URL xsltSource = ClassUtils.getResourceURL( this, skipEmptyTags_xslt);
// Transformer transformer = XmlUtils.createTransformer(xsltSource);
// stringResult = XmlUtils.transformXml(transformer, stringResult);
ParameterResolutionContext prc_SkipEmptyTags = new ParameterResolutionContext(stringResult, session, true, true);
stringResult = transformerPoolSkipEmptyTags.transform(prc_SkipEmptyTags.getInputSource(), null);
}
if (StringUtils.isEmpty(getSessionKey())) {
return new PipeRunResult(getForward(), stringResult);
}
session.put(getSessionKey(), stringResult);
return new PipeRunResult(getForward(), input);
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on transforming input", e);
}
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class CheckMessageSizePipeProcessor method processPipe.
public PipeRunResult processPipe(PipeLine pipeLine, IPipe pipe, String messageId, Object message, IPipeLineSession pipeLineSession) throws PipeRunException {
checkMessageSize(message, pipeLine, pipe, true);
PipeRunResult pipeRunResult = pipeProcessor.processPipe(pipeLine, pipe, messageId, message, pipeLineSession);
Object result = pipeRunResult.getResult();
checkMessageSize(result, pipeLine, pipe, false);
return pipeRunResult;
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class CheckSemaphorePipeProcessor method processPipe.
public PipeRunResult processPipe(PipeLine pipeLine, IPipe pipe, String messageId, Object message, IPipeLineSession pipeLineSession) throws PipeRunException {
PipeRunResult pipeRunResult;
Semaphore s = getSemaphore(pipe);
if (s != null) {
long waitingDuration = 0;
try {
// keep waiting statistics for thread-limited pipes
long startWaiting = System.currentTimeMillis();
s.acquire();
waitingDuration = System.currentTimeMillis() - startWaiting;
StatisticsKeeper sk = pipeLine.getPipeWaitingStatistics(pipe);
sk.addValue(waitingDuration);
pipeRunResult = pipeProcessor.processPipe(pipeLine, pipe, messageId, message, pipeLineSession);
} catch (InterruptedException e) {
throw new PipeRunException(pipe, "Interrupted acquiring semaphore", e);
} finally {
s.release();
}
} else {
// no restrictions on the maximum number of threads (s==null)
pipeRunResult = pipeProcessor.processPipe(pipeLine, pipe, messageId, message, pipeLineSession);
}
return pipeRunResult;
}
Aggregations