use of nl.nn.adapterframework.core.PipeRunException in project iaf by ibissource.
the class WsdlGeneratorPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String result = null;
IAdapter adapter;
if ("input".equals(getFrom())) {
adapter = ((Adapter) getAdapter()).getConfiguration().getIbisManager().getRegisteredAdapter((String) input);
if (adapter == null) {
throw new PipeRunException(this, "Could not find adapter: " + input);
}
} else {
adapter = getPipeLine().getAdapter();
}
try {
Wsdl wsdl = new Wsdl(((Adapter) adapter).getPipeLine());
wsdl.setDocumentation("Generated at " + AppConstants.getInstance().getResolvedProperty("otap.stage") + "-" + AppConstants.getInstance().getResolvedProperty("otap.side") + " on " + DateUtils.getIsoTimeStamp() + ".");
wsdl.init();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
wsdl.wsdl(outputStream, null);
result = outputStream.toString("UTF-8");
} catch (Exception e) {
throw new PipeRunException(this, "Could not generate WSDL for adapter '" + adapter.getName() + "'", e);
}
return new PipeRunResult(getForward(), result);
}
use of nl.nn.adapterframework.core.PipeRunException in project iaf by ibissource.
the class XQueryPipe method doPipe.
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());
}
try {
String stringResult = (String) input;
// We already specifically use Saxon in this pipe, hence set xslt2
// to true to make XmlUtils use the Saxon
// DocumentBuilderFactoryImpl.
ParameterResolutionContext prc = new ParameterResolutionContext(stringResult, session, isNamespaceAware(), true);
Map parametervalues = null;
if (getParameterList() != null) {
parametervalues = prc.getValueMap(getParameterList());
}
preparedExpression.bindDocument(XQConstants.CONTEXT_ITEM, stringResult, null, null);
Iterator iterator = getParameterList().iterator();
while (iterator.hasNext()) {
Parameter parameter = (Parameter) iterator.next();
preparedExpression.bindObject(new QName(parameter.getName()), parametervalues.get(parameter.getName()), null);
}
XQResultSequence resultSequence = preparedExpression.executeQuery();
stringResult = resultSequence.getSequenceAsString(null);
return new PipeRunResult(getForward(), stringResult);
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on running xquery", e);
}
}
use of nl.nn.adapterframework.core.PipeRunException 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.PipeRunException 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.PipeRunException in project iaf by ibissource.
the class XmlValidator method getMessageToValidate.
@Deprecated
private String getMessageToValidate(Object input, IPipeLineSession session) throws PipeRunException {
String inputStr = input.toString();
if (XmlUtils.isWellFormed(inputStr, "Envelope")) {
String inputRootNs;
try {
inputRootNs = transformerPoolGetRootNamespace.transform(inputStr, null);
} catch (Exception e) {
throw new PipeRunException(this, "cannot extract root namespace", e);
}
if (inputRootNs.equals(getSoapNamespace())) {
log.debug(getLogPrefix(session) + "message to validate is a SOAP message");
boolean extractSoapBody = true;
if (StringUtils.isNotEmpty(getSchemaLocation())) {
StringTokenizer st = new StringTokenizer(getSchemaLocation(), ", \t\r\n\f");
while (st.hasMoreTokens() && extractSoapBody) {
if (st.nextToken().equals(getSoapNamespace())) {
extractSoapBody = false;
}
}
}
if (extractSoapBody) {
log.debug(getLogPrefix(session) + "extract SOAP body for validation");
try {
inputStr = transformerPoolExtractSoapBody.transform(inputStr, null, true);
} catch (Exception e) {
throw new PipeRunException(this, "cannot extract SOAP body", e);
}
try {
inputRootNs = transformerPoolGetRootNamespace.transform(inputStr, null);
} catch (Exception e) {
throw new PipeRunException(this, "cannot extract root namespace", e);
}
if (StringUtils.isNotEmpty(inputRootNs) && StringUtils.isEmpty(getSchemaLocation())) {
log.debug(getLogPrefix(session) + "remove namespaces from extracted SOAP body");
try {
inputStr = transformerPoolRemoveNamespaces.transform(inputStr, null);
} catch (Exception e) {
throw new PipeRunException(this, "cannot remove namespaces", e);
}
}
}
}
}
return inputStr;
}
Aggregations