use of nl.nn.adapterframework.util.DomBuilderException in project iaf by ibissource.
the class XmlQuerySender method sendMessage.
@Override
protected String sendMessage(Connection connection, String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException {
Element queryElement;
String tableName = null;
Vector columns = null;
String where = null;
String order = null;
String result = null;
try {
queryElement = XmlUtils.buildElement(message);
String root = queryElement.getTagName();
tableName = XmlUtils.getChildTagAsString(queryElement, "tableName");
Element columnsElement = XmlUtils.getFirstChildTag(queryElement, "columns");
if (columnsElement != null) {
columns = getColumns(columnsElement);
}
where = XmlUtils.getChildTagAsString(queryElement, "where");
order = XmlUtils.getChildTagAsString(queryElement, "order");
if (root.equalsIgnoreCase("select")) {
result = selectQuery(connection, correlationID, tableName, columns, where, order);
} else {
if (root.equalsIgnoreCase("insert")) {
result = insertQuery(connection, correlationID, prc, tableName, columns);
} else {
if (root.equalsIgnoreCase("delete")) {
result = deleteQuery(connection, correlationID, tableName, where);
} else {
if (root.equalsIgnoreCase("update")) {
result = updateQuery(connection, correlationID, tableName, columns, where);
} else {
if (root.equalsIgnoreCase("alter")) {
String sequenceName = XmlUtils.getChildTagAsString(queryElement, "sequenceName");
int startWith = Integer.parseInt(XmlUtils.getChildTagAsString(queryElement, "startWith"));
result = alterQuery(connection, sequenceName, startWith);
} else {
if (root.equalsIgnoreCase("sql")) {
String type = XmlUtils.getChildTagAsString(queryElement, "type");
String query = XmlUtils.getChildTagAsString(queryElement, "query");
result = sql(connection, correlationID, query, type);
} else {
throw new SenderException(getLogPrefix() + "unknown root element [" + root + "]");
}
}
}
}
}
}
} catch (DomBuilderException e) {
throw new SenderException(getLogPrefix() + "got exception parsing [" + message + "]", e);
} catch (JdbcException e) {
throw new SenderException(getLogPrefix() + "got exception preparing [" + message + "]", e);
}
return result;
}
use of nl.nn.adapterframework.util.DomBuilderException in project iaf by ibissource.
the class FixedResultSender method sendMessage.
public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException {
String result = returnString;
if (prc != null) {
ParameterValueList pvl;
try {
pvl = prc.getValues(paramList);
} catch (ParameterException e) {
throw new SenderException("exception extracting parameters", e);
}
if (pvl != null) {
for (int i = 0; i < pvl.size(); i++) {
ParameterValue pv = pvl.getParameterValue(i);
result = replace(result, "${" + pv.getDefinition().getName() + "}", pv.asStringValue(""));
}
}
}
if (getSubstituteVars()) {
result = StringResolver.substVars(returnString, prc.getSession());
}
if (StringUtils.isNotEmpty(styleSheetName)) {
URL xsltSource = ClassUtils.getResourceURL(classLoader, styleSheetName);
if (xsltSource != null) {
try {
String xsltResult = null;
Transformer transformer = XmlUtils.createTransformer(xsltSource);
xsltResult = XmlUtils.transformXml(transformer, result);
result = xsltResult;
} catch (IOException e) {
throw new SenderException("cannot retrieve [" + styleSheetName + "], resource [" + xsltSource.toString() + "]", e);
} catch (TransformerConfigurationException te) {
throw new SenderException("got error creating transformer from file [" + styleSheetName + "]", te);
} catch (TransformerException te) {
throw new SenderException("got error transforming resource [" + xsltSource.toString() + "] from [" + styleSheetName + "]", te);
} catch (DomBuilderException te) {
throw new SenderException("caught DomBuilderException", te);
}
}
}
log.debug("returning fixed result [" + result + "]");
return result;
}
use of nl.nn.adapterframework.util.DomBuilderException in project iaf by ibissource.
the class MailSender method sendEmail.
/**
* Send a mail conforming to the XML input
*/
protected String sendEmail(String input, ParameterResolutionContext prc) throws SenderException {
// initialize this request
String from;
String subject;
String threadTopic;
String message;
String messageType;
String messageBase64;
String charset;
Collection<Recipient> recipients;
Collection<Attachment> attachments = null;
Element emailElement;
try {
emailElement = XmlUtils.buildElement(input);
from = XmlUtils.getChildTagAsString(emailElement, "from");
subject = XmlUtils.getChildTagAsString(emailElement, "subject");
threadTopic = XmlUtils.getChildTagAsString(emailElement, "threadTopic");
message = XmlUtils.getChildTagAsString(emailElement, "message");
messageType = XmlUtils.getChildTagAsString(emailElement, "messageType");
messageBase64 = XmlUtils.getChildTagAsString(emailElement, "messageBase64");
charset = XmlUtils.getChildTagAsString(emailElement, "charset");
Element recipientsElement = XmlUtils.getFirstChildTag(emailElement, "recipients");
recipients = retrieveRecipients(XmlUtils.getChildTags(recipientsElement, "recipient"));
Element attachmentsElement = XmlUtils.getFirstChildTag(emailElement, "attachments");
if (attachmentsElement != null)
attachments = retrieveAttachments(XmlUtils.getChildTags(attachmentsElement, "attachment"), prc);
} catch (DomBuilderException e) {
throw new SenderException("exception parsing [" + input + "]", e);
}
return sendEmail(from, subject, threadTopic, message, messageType, messageBase64, charset, recipients, attachments);
}
Aggregations