use of nl.nn.adapterframework.core.ITransactionalStorage 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.ITransactionalStorage in project iaf by ibissource.
the class SlotIdRecord method getSlotmap.
private Map<String, SlotIdRecord> getSlotmap() {
Map<String, SlotIdRecord> slotmap = new HashMap<String, SlotIdRecord>();
for (IAdapter iAdapter : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) iAdapter;
for (Iterator<?> receiverIt = adapter.getReceiverIterator(); receiverIt.hasNext(); ) {
ReceiverBase receiver = (ReceiverBase) receiverIt.next();
ITransactionalStorage errorStorage = receiver.getErrorStorage();
if (errorStorage != null) {
String slotId = errorStorage.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
String type = errorStorage.getType();
slotmap.put(type + "/" + slotId, sir);
}
}
ITransactionalStorage messageLog = receiver.getMessageLog();
if (messageLog != null) {
String slotId = messageLog.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
String type = messageLog.getType();
slotmap.put(type + "/" + slotId, sir);
}
}
}
PipeLine pipeline = adapter.getPipeLine();
if (pipeline != null) {
for (int i = 0; i < pipeline.getPipeLineSize(); i++) {
IPipe pipe = pipeline.getPipe(i);
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
ITransactionalStorage messageLog = msp.getMessageLog();
if (messageLog != null) {
String slotId = messageLog.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), null, msp.getName());
String type = messageLog.getType();
slotmap.put(type + "/" + slotId, sir);
slotmap.put(slotId, sir);
}
}
}
}
}
}
return slotmap;
}
use of nl.nn.adapterframework.core.ITransactionalStorage in project iaf by ibissource.
the class ShowConfigurationStatus method retrieveErrorStoragesMessageCount.
private int retrieveErrorStoragesMessageCount(Adapter adapter) {
int counter = 0;
for (Iterator receiverIt = adapter.getReceiverIterator(); receiverIt.hasNext(); ) {
ReceiverBase receiver = (ReceiverBase) receiverIt.next();
ITransactionalStorage errorStorage = receiver.getErrorStorage();
if (errorStorage != null) {
try {
counter += errorStorage.getMessageCount();
} catch (Exception e) {
log.warn("error occured on getting number of errorlog records for adapter [" + adapter.getName() + "], assuming there are no errorlog records", e);
}
}
}
return counter;
}
use of nl.nn.adapterframework.core.ITransactionalStorage 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.ITransactionalStorage in project iaf by ibissource.
the class SlotIdRecord method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
IniDynaActionForm showIbisstoreSummaryForm = (IniDynaActionForm) form;
// Initialize action
initAction(request);
if (ibisManager == null)
return (mapping.findForward("noIbisContext"));
String jmsRealm = (String) showIbisstoreSummaryForm.get("jmsRealm");
String cookieName = AppConstants.getInstance().getString(SHOWIBISSTORECOOKIE, SHOWIBISSTORECOOKIE);
if (StringUtils.isEmpty(jmsRealm)) {
// get jmsRealm value from cookie
Cookie[] cookies = request.getCookies();
if (null != cookies) {
for (int i = 0; i < cookies.length; i++) {
Cookie aCookie = cookies[i];
if (aCookie.getName().equals(cookieName)) {
jmsRealm = aCookie.getValue();
log.debug("jmsRealm from cookie [" + jmsRealm + "]");
}
}
}
}
for (IAdapter iAdapter : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) iAdapter;
for (Iterator receiverIt = adapter.getReceiverIterator(); receiverIt.hasNext(); ) {
ReceiverBase receiver = (ReceiverBase) receiverIt.next();
ITransactionalStorage errorStorage = receiver.getErrorStorage();
if (errorStorage != null) {
String slotId = errorStorage.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
String type = errorStorage.getType();
slotmap.put(type + "/" + slotId, sir);
}
}
ITransactionalStorage messageLog = receiver.getMessageLog();
if (messageLog != null) {
String slotId = messageLog.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
String type = messageLog.getType();
slotmap.put(type + "/" + slotId, sir);
}
}
}
PipeLine pipeline = adapter.getPipeLine();
if (pipeline != null) {
for (int i = 0; i < pipeline.getPipeLineSize(); i++) {
IPipe pipe = pipeline.getPipe(i);
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
ITransactionalStorage messageLog = msp.getMessageLog();
if (messageLog != null) {
String slotId = messageLog.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), null, msp.getName());
String type = messageLog.getType();
slotmap.put(type + "/" + slotId, sir);
slotmap.put(slotId, sir);
}
}
}
}
}
}
List jmsRealms = JmsRealmFactory.getInstance().getRegisteredRealmNamesAsList();
if (jmsRealms.size() == 0) {
jmsRealms.add("no realms defined");
} else {
if (StringUtils.isEmpty(jmsRealm)) {
jmsRealm = (String) jmsRealms.get(0);
}
}
showIbisstoreSummaryForm.set("jmsRealms", jmsRealms);
if (StringUtils.isNotEmpty(jmsRealm)) {
String result = "<none/>";
try {
IbisstoreSummaryQuerySender qs;
qs = (IbisstoreSummaryQuerySender) ibisManager.getIbisContext().createBeanAutowireByName(IbisstoreSummaryQuerySender.class);
qs.setSlotmap(slotmap);
try {
qs.setName("QuerySender");
qs.setJmsRealm(jmsRealm);
qs.setQueryType("select");
qs.setBlobSmartGet(true);
qs.configure(true);
qs.open();
result = qs.sendMessage("dummy", qs.getDbmsSupport().getIbisStoreSummaryQuery());
} catch (Throwable t) {
error("error occured on executing jdbc query", t);
} finally {
qs.close();
}
} catch (Exception e) {
error("error occured on creating or closing connection", e);
}
if (log.isDebugEnabled())
log.debug("result [" + result + "]");
request.setAttribute("result", result);
}
if (!errors.isEmpty()) {
saveErrors(request, errors);
return (mapping.findForward("success"));
}
// Successfull: store cookie
String cookieValue = jmsRealm;
Cookie cookie = new Cookie(cookieName, cookieValue);
cookie.setMaxAge(Integer.MAX_VALUE);
log.debug("Store cookie for " + request.getServletPath() + " cookieName[" + cookieName + "] " + " cookieValue[" + cookieValue + "]");
try {
response.addCookie(cookie);
} catch (Throwable t) {
log.warn("unable to add cookie to request. cookie value [" + cookie.getValue() + "]", t);
}
log.debug("forward to success");
return (mapping.findForward("success"));
}
Aggregations