use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class CreateRestViewPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
HttpServletRequest httpServletRequest = (HttpServletRequest) session.get(IPipeLineSession.HTTP_REQUEST_KEY);
String requestURL = httpServletRequest.getRequestURL().toString();
String servletPath = httpServletRequest.getServletPath();
String uri = StringUtils.substringAfter(requestURL, servletPath);
int countSrcPrefix = StringUtils.countMatches(uri, "/");
String srcPrefix = StringUtils.repeat("../", countSrcPrefix);
session.put(SRCPREFIX, srcPrefix);
log.debug(getLogPrefix(session) + "stored [" + srcPrefix + "] in pipeLineSession under key [" + SRCPREFIX + "]");
PipeRunResult prr = super.doPipe(input, session);
String result = (String) prr.getResult();
log.debug("transforming page [" + result + "] to view");
String newResult = null;
ServletContext servletContext = (ServletContext) session.get(IPipeLineSession.SERVLET_CONTEXT_KEY);
try {
Map parameters = retrieveParameters(httpServletRequest, servletContext, srcPrefix);
newResult = XmlUtils.getAdapterSite(result, parameters);
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on transforming page to view", e);
}
session.put(CONTENTTYPE, getContentType());
log.debug(getLogPrefix(session) + "stored [" + getContentType() + "] in pipeLineSession under key [" + CONTENTTYPE + "]");
return new PipeRunResult(getForward(), newResult);
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class CredentialCheckingPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
CredentialFactory cf = new CredentialFactory(getAuthAlias(), getDefaultUserid(), getDefaultPassword());
String result = "";
if (!getTargetUserid().equals(cf.getUsername())) {
result += "username does not match target";
}
if (!getTargetPassword().equals(cf.getPassword())) {
result += "password does not match target";
}
if (StringUtils.isEmpty(result)) {
result = "OK";
}
return new PipeRunResult(getForward(), result);
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class CrlPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
X509CRL crl;
InputStream inputStream = (InputStream) input;
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
crl = (X509CRL) cf.generateCRL(inputStream);
} catch (CertificateException e) {
throw new PipeRunException(this, "Could not read CRL", e);
} catch (CRLException e) {
throw new PipeRunException(this, "Could not read CRL", e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
log.warn("Could not close CRL input stream", e);
}
}
}
String result = null;
if (isCRLOK(crl, (InputStream) session.get(getIssuerSessionKey()))) {
XmlBuilder root = new XmlBuilder("SerialNumbers");
Iterator<? extends X509CRLEntry> it = crl.getRevokedCertificates().iterator();
while (it.hasNext()) {
X509CRLEntry e = (X509CRLEntry) it.next();
XmlBuilder serialNumber = new XmlBuilder("SerialNumber");
serialNumber.setValue(e.getSerialNumber().toString(16));
root.addSubElement(serialNumber);
}
result = root.toXML();
}
return new PipeRunResult(getForward(), result);
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class DomainTransformerPipe method doPipe.
public PipeRunResult doPipe(Object invoer, IPipeLineSession session) throws PipeRunException {
Connection conn = null;
PreparedStatement stmt = null;
StringBuffer buffer = new StringBuffer();
try {
conn = qs.getConnection();
stmt = conn.prepareStatement(query);
String invoerString = invoer.toString();
int startPos = invoerString.indexOf(DT_START);
if (startPos == -1)
return new PipeRunResult(getForward(), invoerString);
char[] invoerChars = invoerString.toCharArray();
int copyFrom = 0;
while (startPos != -1) {
buffer.append(invoerChars, copyFrom, startPos - copyFrom);
int nextStartPos = invoerString.indexOf(DT_START, startPos + DT_START.length());
if (nextStartPos == -1) {
nextStartPos = invoerString.length();
}
int endPos = invoerString.indexOf(DT_END, startPos + DT_START.length());
if (endPos == -1 || endPos > nextStartPos) {
log.warn(getLogPrefix(session) + "Found a start delimiter without an end delimiter at position [" + startPos + "] in [" + invoerString + "]");
buffer.append(invoerChars, startPos, nextStartPos - startPos);
copyFrom = nextStartPos;
} else {
String invoerSubstring = invoerString.substring(startPos + DT_START.length(), endPos);
StringTokenizer st = new StringTokenizer(invoerSubstring, DT_SEPARATOR);
int aantalTokens = st.countTokens();
if (aantalTokens < 2 || aantalTokens > 3) {
log.warn(getLogPrefix(session) + "Only 2 or 3 tokens are allowed in [" + invoerSubstring + "]");
buffer.append(invoerChars, startPos, endPos - startPos + DT_END.length());
copyFrom = endPos + DT_END.length();
} else {
String label = st.nextToken();
String valueIn = st.nextToken();
String type = TYPE_STRING;
if (st.hasMoreTokens()) {
type = st.nextToken();
}
if (!type.equals(TYPE_STRING) && !type.equals(TYPE_NUMBER)) {
log.warn(getLogPrefix(session) + "Only types [" + TYPE_STRING + "," + TYPE_NUMBER + "] are allowed in [" + invoerSubstring + "]");
buffer.append(invoerChars, startPos, endPos - startPos + DT_END.length());
copyFrom = endPos + DT_END.length();
} else {
String valueOut = null;
valueOut = getValueOut(label, valueIn, type, stmt);
if (valueOut != null) {
buffer.append(valueOut);
}
copyFrom = endPos + DT_END.length();
}
}
}
startPos = invoerString.indexOf(DT_START, copyFrom);
}
buffer.append(invoerChars, copyFrom, invoerChars.length - copyFrom);
} catch (Throwable t) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on transforming domain", t);
} finally {
JdbcUtil.fullClose(conn, stmt);
}
return new PipeRunResult(getForward(), buffer.toString());
}
use of nl.nn.adapterframework.core.PipeRunResult in project iaf by ibissource.
the class FilenameSwitch method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String forward = "";
String sInput = (String) input;
PipeForward pipeForward = null;
int slashPos = sInput.lastIndexOf('/');
if (slashPos > 0) {
sInput = sInput.substring(slashPos + 1);
}
slashPos = sInput.lastIndexOf('\\');
if (slashPos > 0) {
sInput = sInput.substring(slashPos + 1);
}
forward = sInput;
if (isToLowercase()) {
forward = forward.toLowerCase();
}
log.debug(getLogPrefix(session) + "determined forward [" + forward + "]");
if (findForward(forward) != null)
pipeForward = findForward(forward);
else {
log.info(getLogPrefix(session) + "determined forward [" + forward + "], which is not defined. Will use [" + getNotFoundForwardName() + "] instead");
pipeForward = findForward(getNotFoundForwardName());
}
if (pipeForward == null) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot find forward or pipe named [" + forward + "]");
}
return new PipeRunResult(pipeForward, input);
}
Aggregations