use of nl.nn.adapterframework.core.PipeForward in project iaf by ibissource.
the class IfMultipart method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String forward;
PipeForward pipeForward = null;
if (input == null) {
forward = elseForwardName;
} else {
if (!(input instanceof HttpServletRequest)) {
throw new PipeRunException(this, getLogPrefix(null) + "expected HttpServletRequest as input, got [" + ClassUtils.nameOf(input) + "]");
}
HttpServletRequest request = (HttpServletRequest) input;
String contentType = request.getContentType();
if (StringUtils.isNotEmpty(contentType) && contentType.startsWith("multipart")) {
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.PipeForward in project iaf by ibissource.
the class IsXmlIfPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String forward = "";
if (input == null) {
if (isElseForwardOnEmptyInput()) {
forward = elseForwardName;
} else {
forward = thenForwardName;
}
} else {
String sInput = input.toString();
if (StringUtils.isEmpty(sInput)) {
if (isElseForwardOnEmptyInput()) {
forward = elseForwardName;
} else {
forward = thenForwardName;
}
} else {
String firstChar = sInput.replaceAll("^\\s+", "").substring(0, 1);
if (firstChar.equals("<")) {
forward = thenForwardName;
} else {
forward = elseForwardName;
}
}
}
log.debug(getLogPrefix(session) + "determined forward [" + forward + "]");
PipeForward 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.PipeForward in project iaf by ibissource.
the class FtpFileRetrieverPipe method doPipe.
/**
* @see nl.nn.adapterframework.core.IPipe#doPipe(Object, IPipeLineSession)
*/
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String orgFilename = (String) input;
try {
boolean close = !deleteAfterGet;
String localFilename = ftpSession.get(getParameterList(), session, localDirectory, remoteDirectory, orgFilename, localFilenamePattern, close);
if (deleteAfterGet) {
ftpSession.deleteRemote(remoteDirectory, orgFilename, true);
}
return new PipeRunResult(getForward(), localFilename);
} catch (Exception e) {
String msg = "Error while getting file [" + remoteDirectory + "/" + input + "]";
PipeForward exceptionForward = findForward(EXCEPTIONFORWARD);
if (exceptionForward != null) {
log.warn(msg, e);
return new PipeRunResult(exceptionForward, input);
}
throw new PipeRunException(this, msg, e);
}
}
use of nl.nn.adapterframework.core.PipeForward 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.PipeForward in project iaf by ibissource.
the class XmlValidator method determineForward.
protected PipeForward determineForward(String resultEvent, IPipeLineSession session, boolean responseMode) throws PipeRunException {
throwEvent(resultEvent);
if (AbstractXmlValidator.XML_VALIDATOR_VALID_MONITOR_EVENT.equals(resultEvent)) {
return getForward();
}
PipeForward forward = null;
if (AbstractXmlValidator.XML_VALIDATOR_PARSER_ERROR_MONITOR_EVENT.equals(resultEvent)) {
if (responseMode) {
forward = findForward("outputParserError");
}
if (forward == null) {
forward = findForward("parserError");
}
}
if (forward == null) {
if (responseMode) {
forward = findForward("outputFailure");
}
if (forward == null) {
forward = findForward("failure");
}
}
if (forward == null) {
if (isForwardFailureToSuccess()) {
forward = findForward("success");
} else {
throw new PipeRunException(this, "not implemented: should get reason from validator");
}
}
return forward;
}
Aggregations