use of nl.nn.adapterframework.parameters.ParameterValue 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.parameters.ParameterValue in project iaf by ibissource.
the class MailSender method sendMessage.
public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException {
String from = null;
String subject = null;
String threadTopic = null;
String messageType = null;
String messageBase64 = null;
String charset = null;
Collection<Recipient> recipients = null;
Collection<Attachment> attachments = null;
ParameterValueList pvl;
ParameterValue pv;
String messageInMailSafeForm;
if (paramList == null) {
messageInMailSafeForm = sendEmail(message, prc);
} else {
try {
pvl = prc.getValues(paramList);
pv = pvl.getParameterValue("from");
if (pv != null) {
from = pv.asStringValue(null);
log.debug("MailSender [" + getName() + "] retrieved from-parameter [" + from + "]");
}
pv = pvl.getParameterValue("subject");
if (pv != null) {
subject = pv.asStringValue(null);
log.debug("MailSender [" + getName() + "] retrieved subject-parameter [" + subject + "]");
}
pv = pvl.getParameterValue("threadTopic");
if (pv != null) {
threadTopic = pv.asStringValue(null);
log.debug("MailSender [" + getName() + "] retrieved threadTopic-parameter [" + threadTopic + "]");
}
pv = pvl.getParameterValue("message");
if (pv != null) {
message = pv.asStringValue(message);
log.debug("MailSender [" + getName() + "] retrieved message-parameter [" + message + "]");
}
pv = pvl.getParameterValue("messageType");
if (pv != null) {
messageType = pv.asStringValue(null);
log.debug("MailSender [" + getName() + "] retrieved messageType-parameter [" + messageType + "]");
}
pv = pvl.getParameterValue("messageBase64");
if (pv != null) {
messageBase64 = pv.asStringValue(null);
log.debug("MailSender [" + getName() + "] retrieved messageBase64-parameter [" + messageBase64 + "]");
}
pv = pvl.getParameterValue("charset");
if (pv != null) {
charset = pv.asStringValue(null);
log.debug("MailSender [" + getName() + "] retrieved charset-parameter [" + charset + "]");
}
pv = pvl.getParameterValue("recipients");
if (pv != null) {
recipients = retrieveRecipients(pv.asCollection());
log.debug("MailSender [" + getName() + "] retrieved recipients-parameter [" + recipients + "]");
}
pv = pvl.getParameterValue("attachments");
if (pv != null) {
attachments = retrieveAttachments(pv.asCollection(), prc);
log.debug("MailSender [" + getName() + "] retrieved attachments-parameter [" + attachments + "]");
}
} catch (ParameterException e) {
throw new SenderException("MailSender [" + getName() + "] got exception determining parametervalues", e);
}
messageInMailSafeForm = sendEmail(from, subject, threadTopic, message, messageType, messageBase64, charset, recipients, attachments);
}
prc.getSession().put("messageInMailSafeForm", messageInMailSafeForm);
return correlationID;
}
Aggregations