use of nl.nn.adapterframework.core.ISender in project iaf by ibissource.
the class ShowConfigurationStatus method mapAdapterPipes.
private ArrayList<Object> mapAdapterPipes(Adapter adapter) {
if (!adapter.configurationSucceeded())
return null;
PipeLine pipeline = adapter.getPipeLine();
int totalPipes = pipeline.getPipes().size();
ArrayList<Object> pipes = new ArrayList<Object>(totalPipes);
for (int i = 0; i < totalPipes; i++) {
Map<String, Object> pipesInfo = new HashMap<String, Object>();
IPipe pipe = pipeline.getPipe(i);
Map<String, PipeForward> pipeForwards = pipe.getForwards();
String pipename = pipe.getName();
Map<String, String> forwards = new HashMap<String, String>();
for (PipeForward fwrd : pipeForwards.values()) {
forwards.put(fwrd.getName(), fwrd.getPath());
}
pipesInfo.put("name", pipename);
pipesInfo.put("type", pipe.getType());
pipesInfo.put("forwards", forwards);
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
ISender sender = msp.getSender();
pipesInfo.put("sender", ClassUtils.nameOf(sender));
if (sender instanceof WebServiceSender) {
WebServiceSender s = (WebServiceSender) sender;
Map<String, Object> certInfo = addCertificateInfo(s);
if (certInfo != null)
pipesInfo.put("certificate", certInfo);
}
if (sender instanceof HttpSender) {
HttpSender s = (HttpSender) sender;
Map<String, Object> certInfo = addCertificateInfo(s);
if (certInfo != null)
pipesInfo.put("certificate", certInfo);
}
if (sender instanceof FtpSender) {
FtpSender s = (FtpSender) sender;
Map<String, Object> certInfo = addCertificateInfo(s);
if (certInfo != null)
pipesInfo.put("certificate", certInfo);
}
if (sender instanceof HasPhysicalDestination) {
pipesInfo.put("destination", ((HasPhysicalDestination) sender).getPhysicalDestinationName());
}
if (sender instanceof JdbcSenderBase) {
pipesInfo.put("isJdbcSender", true);
}
IListener listener = msp.getListener();
if (listener != null) {
pipesInfo.put("listenerName", listener.getName());
pipesInfo.put("listenerClass", ClassUtils.nameOf(listener));
if (listener instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) listener).getPhysicalDestinationName();
pipesInfo.put("listenerDestination", pd);
}
}
ITransactionalStorage messageLog = msp.getMessageLog();
if (messageLog != null) {
pipesInfo.put("hasMessageLog", true);
String messageLogCount;
try {
if (showCountMessageLog) {
messageLogCount = "" + messageLog.getMessageCount();
} else {
messageLogCount = "?";
}
} catch (Exception e) {
log.warn(e);
messageLogCount = "error";
}
pipesInfo.put("messageLogCount", messageLogCount);
Map<String, Object> message = new HashMap<String, Object>();
message.put("name", messageLog.getName());
message.put("type", "log");
message.put("slotId", messageLog.getSlotId());
message.put("count", messageLogCount);
pipesInfo.put("message", message);
}
}
pipes.add(pipesInfo);
}
return pipes;
}
use of nl.nn.adapterframework.core.ISender in project iaf by ibissource.
the class ShowConfigurationStatus method toPipesXml.
private XmlBuilder toPipesXml(Adapter adapter) {
XmlBuilder pipesElem = new XmlBuilder("pipes");
PipeLine pipeline = adapter.getPipeLine();
for (int i = 0; i < pipeline.getPipes().size(); i++) {
IPipe pipe = pipeline.getPipe(i);
String pipename = pipe.getName();
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
XmlBuilder pipeElem = new XmlBuilder("pipe");
pipeElem.addAttribute("name", pipename);
pipesElem.addSubElement(pipeElem);
ISender sender = msp.getSender();
pipeElem.addAttribute("sender", ClassUtils.nameOf(sender));
if (sender instanceof HasPhysicalDestination) {
pipeElem.addAttribute("destination", ((HasPhysicalDestination) sender).getPhysicalDestinationName());
}
if (sender instanceof JdbcSenderBase) {
pipeElem.addAttribute("isJdbcSender", "true");
}
IListener listener = msp.getListener();
if (listener != null) {
pipeElem.addAttribute("listenerName", listener.getName());
pipeElem.addAttribute("listenerClass", ClassUtils.nameOf(listener));
if (listener instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) listener).getPhysicalDestinationName();
pipeElem.addAttribute("listenerDestination", pd);
}
}
ITransactionalStorage messageLog = msp.getMessageLog();
if (messageLog != null) {
pipeElem.addAttribute("hasMessageLog", "true");
String messageLogCount;
try {
if (SHOW_COUNT_MESSAGELOG) {
messageLogCount = "" + messageLog.getMessageCount();
} else {
messageLogCount = "?";
}
} catch (Exception e) {
log.warn(e);
messageLogCount = "error";
}
pipeElem.addAttribute("messageLogCount", messageLogCount);
XmlBuilder browserElem = new XmlBuilder("browser");
browserElem.addAttribute("name", messageLog.getName());
browserElem.addAttribute("type", "log");
browserElem.addAttribute("slotId", messageLog.getSlotId());
browserElem.addAttribute("count", messageLogCount);
pipeElem.addSubElement(browserElem);
}
}
}
return pipesElem;
}
use of nl.nn.adapterframework.core.ISender in project iaf by ibissource.
the class ShowSecurityItems method addRegisteredAdapters.
private void addRegisteredAdapters(XmlBuilder securityItems) {
XmlBuilder registeredAdapters = new XmlBuilder("registeredAdapters");
securityItems.addSubElement(registeredAdapters);
for (IAdapter iAdapter : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) iAdapter;
XmlBuilder adapterXML = new XmlBuilder("adapter");
registeredAdapters.addSubElement(adapterXML);
adapterXML.addAttribute("name", adapter.getName());
Iterator recIt = adapter.getReceiverIterator();
if (recIt.hasNext()) {
XmlBuilder receiversXML = new XmlBuilder("receivers");
while (recIt.hasNext()) {
IReceiver receiver = (IReceiver) recIt.next();
XmlBuilder receiverXML = new XmlBuilder("receiver");
receiversXML.addSubElement(receiverXML);
receiverXML.addAttribute("name", receiver.getName());
if (receiver instanceof HasSender) {
ISender sender = ((HasSender) receiver).getSender();
if (sender != null) {
receiverXML.addAttribute("senderName", sender.getName());
}
}
}
adapterXML.addSubElement(receiversXML);
}
// make list of pipes to be displayed in configuration status
XmlBuilder pipesElem = new XmlBuilder("pipes");
adapterXML.addSubElement(pipesElem);
PipeLine pipeline = adapter.getPipeLine();
for (int i = 0; i < pipeline.getPipes().size(); i++) {
IPipe pipe = pipeline.getPipe(i);
String pipename = pipe.getName();
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
XmlBuilder pipeElem = new XmlBuilder("pipe");
pipeElem.addAttribute("name", pipename);
ISender sender = msp.getSender();
pipeElem.addAttribute("sender", ClassUtils.nameOf(sender));
pipesElem.addSubElement(pipeElem);
if (sender instanceof WebServiceSender) {
WebServiceSender s = (WebServiceSender) sender;
String certificate = s.getCertificate();
if (StringUtils.isNotEmpty(certificate)) {
XmlBuilder certElem = new XmlBuilder("certificate");
certElem.addAttribute("name", certificate);
String certificateAuthAlias = s.getCertificateAuthAlias();
certElem.addAttribute("authAlias", certificateAuthAlias);
URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
if (certificateUrl == null) {
certElem.addAttribute("url", "");
pipeElem.addSubElement(certElem);
XmlBuilder infoElem = new XmlBuilder("info");
infoElem.setCdataValue("*** ERROR ***");
certElem.addSubElement(infoElem);
} else {
certElem.addAttribute("url", certificateUrl.toString());
pipeElem.addSubElement(certElem);
String certificatePassword = s.getCertificatePassword();
CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
String keystoreType = s.getKeystoreType();
addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
}
}
} else {
if (sender instanceof HttpSender) {
HttpSender s = (HttpSender) sender;
String certificate = s.getCertificate();
if (StringUtils.isNotEmpty(certificate)) {
XmlBuilder certElem = new XmlBuilder("certificate");
certElem.addAttribute("name", certificate);
String certificateAuthAlias = s.getCertificateAuthAlias();
certElem.addAttribute("authAlias", certificateAuthAlias);
URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
if (certificateUrl == null) {
certElem.addAttribute("url", "");
pipeElem.addSubElement(certElem);
XmlBuilder infoElem = new XmlBuilder("info");
infoElem.setCdataValue("*** ERROR ***");
certElem.addSubElement(infoElem);
} else {
certElem.addAttribute("url", certificateUrl.toString());
pipeElem.addSubElement(certElem);
String certificatePassword = s.getCertificatePassword();
CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
String keystoreType = s.getKeystoreType();
addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
}
}
} else {
if (sender instanceof FtpSender) {
FtpSender s = (FtpSender) sender;
String certificate = s.getCertificate();
if (StringUtils.isNotEmpty(certificate)) {
XmlBuilder certElem = new XmlBuilder("certificate");
certElem.addAttribute("name", certificate);
String certificateAuthAlias = s.getCertificateAuthAlias();
certElem.addAttribute("authAlias", certificateAuthAlias);
URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
if (certificateUrl == null) {
certElem.addAttribute("url", "");
pipeElem.addSubElement(certElem);
XmlBuilder infoElem = new XmlBuilder("info");
infoElem.setCdataValue("*** ERROR ***");
certElem.addSubElement(infoElem);
} else {
certElem.addAttribute("url", certificateUrl.toString());
pipeElem.addSubElement(certElem);
String certificatePassword = s.getCertificatePassword();
CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
String keystoreType = s.getCertificateType();
addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
}
}
}
}
}
}
}
}
}
use of nl.nn.adapterframework.core.ISender in project iaf by ibissource.
the class MessageSendingPipe method configure.
/**
* Checks whether a sender is defined for this pipe.
*/
@Override
public void configure() throws ConfigurationException {
super.configure();
if (StringUtils.isNotEmpty(getStubFileName())) {
URL stubUrl;
try {
stubUrl = ClassUtils.getResourceURL(classLoader, getStubFileName());
} catch (Throwable e) {
throw new ConfigurationException(getLogPrefix(null) + "got exception finding resource for stubfile [" + getStubFileName() + "]", e);
}
if (stubUrl == null) {
throw new ConfigurationException(getLogPrefix(null) + "could not find resource for stubfile [" + getStubFileName() + "]");
}
try {
returnString = Misc.resourceToString(stubUrl, SystemUtils.LINE_SEPARATOR);
} catch (Throwable e) {
throw new ConfigurationException(getLogPrefix(null) + "got exception loading stubfile [" + getStubFileName() + "] from resource [" + stubUrl.toExternalForm() + "]", e);
}
} else {
propagateName();
if (getSender() == null) {
throw new ConfigurationException(getLogPrefix(null) + "no sender defined ");
}
try {
if (getSender() instanceof PipeAware) {
((PipeAware) getSender()).setPipe(this);
}
getSender().configure();
} catch (ConfigurationException e) {
throw new ConfigurationException(getLogPrefix(null) + "while configuring sender", e);
}
if (getSender() instanceof HasPhysicalDestination) {
log.info(getLogPrefix(null) + "has sender on " + ((HasPhysicalDestination) getSender()).getPhysicalDestinationName());
}
if (getListener() != null) {
if (getSender().isSynchronous()) {
throw new ConfigurationException(getLogPrefix(null) + "cannot have listener with synchronous sender");
}
try {
getListener().configure();
} catch (ConfigurationException e) {
throw new ConfigurationException(getLogPrefix(null) + "while configuring listener", e);
}
if (getListener() instanceof HasPhysicalDestination) {
log.info(getLogPrefix(null) + "has listener on " + ((HasPhysicalDestination) getListener()).getPhysicalDestinationName());
}
}
if (!(getLinkMethod().equalsIgnoreCase("MESSAGEID")) && (!(getLinkMethod().equalsIgnoreCase("CORRELATIONID")))) {
throw new ConfigurationException(getLogPrefix(null) + "Invalid argument for property LinkMethod [" + getLinkMethod() + "]. it should be either MESSAGEID or CORRELATIONID");
}
if (!(getHideMethod().equalsIgnoreCase("all")) && (!(getHideMethod().equalsIgnoreCase("firstHalf")))) {
throw new ConfigurationException(getLogPrefix(null) + "invalid value for hideMethod [" + getHideMethod() + "], must be 'all' or 'firstHalf'");
}
if (isCheckXmlWellFormed() || StringUtils.isNotEmpty(getCheckRootTag())) {
if (findForward(ILLEGAL_RESULT_FORWARD) == null)
throw new ConfigurationException(getLogPrefix(null) + "has no forward with name [illegalResult]");
}
if (!ConfigurationUtils.stubConfiguration()) {
if (StringUtils.isNotEmpty(getTimeOutOnResult())) {
throw new ConfigurationException(getLogPrefix(null) + "timeOutOnResult only allowed in stub mode");
}
if (StringUtils.isNotEmpty(getExceptionOnResult())) {
throw new ConfigurationException(getLogPrefix(null) + "exceptionOnResult only allowed in stub mode");
}
}
if (getMaxRetries() > 0) {
ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
if (getRetryMinInterval() < MIN_RETRY_INTERVAL) {
String msg = "retryMinInterval [" + getRetryMinInterval() + "] should be greater than or equal to [" + MIN_RETRY_INTERVAL + "], assuming the lower limit";
configWarnings.add(log, msg);
setRetryMinInterval(MIN_RETRY_INTERVAL);
}
if (getRetryMaxInterval() > MAX_RETRY_INTERVAL) {
String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be less than or equal to [" + MAX_RETRY_INTERVAL + "], assuming the upper limit";
configWarnings.add(log, msg);
setRetryMaxInterval(MAX_RETRY_INTERVAL);
}
if (getRetryMaxInterval() < getRetryMinInterval()) {
String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be greater than or equal to [" + getRetryMinInterval() + "], assuming the lower limit";
configWarnings.add(log, msg);
setRetryMaxInterval(getRetryMinInterval());
}
}
}
ITransactionalStorage messageLog = getMessageLog();
if (checkMessageLog) {
if (!getSender().isSynchronous() && getListener() == null && !(getSender() instanceof nl.nn.adapterframework.senders.IbisLocalSender)) {
if (messageLog == null) {
ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
String msg = "asynchronous sender [" + getSender().getName() + "] without sibling listener has no messageLog. Integrity check not possible";
configWarnings.add(log, msg);
}
}
}
if (messageLog != null) {
messageLog.configure();
if (messageLog instanceof HasPhysicalDestination) {
String msg = getLogPrefix(null) + "has messageLog in " + ((HasPhysicalDestination) messageLog).getPhysicalDestinationName();
log.info(msg);
if (getAdapter() != null)
getAdapter().getMessageKeeper().add(msg);
}
if (StringUtils.isNotEmpty(getAuditTrailXPath())) {
auditTrailTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getAuditTrailNamespaceDefs(), getAuditTrailXPath(), null, "text", false, null);
}
if (StringUtils.isNotEmpty(getCorrelationIDXPath()) || StringUtils.isNotEmpty(getCorrelationIDStyleSheet())) {
correlationIDTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getCorrelationIDNamespaceDefs(), getCorrelationIDXPath(), getCorrelationIDStyleSheet(), "text", false, null);
}
if (StringUtils.isNotEmpty(getLabelXPath()) || StringUtils.isNotEmpty(getLabelStyleSheet())) {
labelTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getLabelNamespaceDefs(), getLabelXPath(), getLabelStyleSheet(), "text", false, null);
}
}
if (StringUtils.isNotEmpty(getRetryXPath())) {
retryTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getRetryNamespaceDefs(), getRetryXPath(), null, "text", false, null);
}
IPipe inputValidator = getInputValidator();
IPipe outputValidator = getOutputValidator();
if (inputValidator != null && outputValidator == null && inputValidator instanceof IDualModeValidator) {
outputValidator = ((IDualModeValidator) inputValidator).getResponseValidator();
setOutputValidator(outputValidator);
}
if (inputValidator != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
inputValidator.registerForward(pf);
// inputValidator.configure(); // configure is handled in PipeLine.configure()
}
if (outputValidator != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
outputValidator.registerForward(pf);
// outputValidator.configure(); // configure is handled in PipeLine.configure()
}
if (getInputWrapper() != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
getInputWrapper().registerForward(pf);
if (getInputWrapper() instanceof EsbSoapWrapperPipe) {
EsbSoapWrapperPipe eswPipe = (EsbSoapWrapperPipe) getInputWrapper();
ISender sender = getSender();
eswPipe.retrievePhysicalDestinationFromSender(sender);
}
}
if (getOutputWrapper() != null) {
PipeForward pf = new PipeForward();
pf.setName(SUCCESS_FORWARD);
getOutputWrapper().registerForward(pf);
}
registerEvent(PIPE_TIMEOUT_MONITOR_EVENT);
registerEvent(PIPE_CLEAR_TIMEOUT_MONITOR_EVENT);
registerEvent(PIPE_EXCEPTION_MONITOR_EVENT);
}
use of nl.nn.adapterframework.core.ISender in project iaf by ibissource.
the class MessageSendingPipe method propagateName.
protected void propagateName() {
ISender sender = getSender();
if (sender != null && StringUtils.isEmpty(sender.getName())) {
sender.setName(getName() + "-sender");
}
ICorrelatedPullingListener listener = getListener();
if (listener != null && StringUtils.isEmpty(listener.getName())) {
listener.setName(getName() + "-replylistener");
}
}
Aggregations