use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class ShowConfigurationStatus method toSummaryXml.
private XmlBuilder toSummaryXml(ShowConfigurationStatusManager showConfigurationStatusManager) {
XmlBuilder summaryXML = new XmlBuilder("summary");
XmlBuilder adapterStateXML = new XmlBuilder("adapterState");
adapterStateXML.addAttribute("starting", showConfigurationStatusManager.countAdapterStateStarting + "");
adapterStateXML.addAttribute("started", showConfigurationStatusManager.countAdapterStateStarted + "");
adapterStateXML.addAttribute("stopping", showConfigurationStatusManager.countAdapterStateStopping + "");
adapterStateXML.addAttribute("stopped", showConfigurationStatusManager.countAdapterStateStopped + "");
adapterStateXML.addAttribute("error", showConfigurationStatusManager.countAdapterStateError + "");
summaryXML.addSubElement(adapterStateXML);
XmlBuilder receiverStateXML = new XmlBuilder("receiverState");
receiverStateXML.addAttribute("starting", showConfigurationStatusManager.countReceiverStateStarting + "");
receiverStateXML.addAttribute("started", showConfigurationStatusManager.countReceiverStateStarted + "");
receiverStateXML.addAttribute("stopping", showConfigurationStatusManager.countReceiverStateStopping + "");
receiverStateXML.addAttribute("stopped", showConfigurationStatusManager.countReceiverStateStopped + "");
receiverStateXML.addAttribute("error", showConfigurationStatusManager.countReceiverStateError + "");
summaryXML.addSubElement(receiverStateXML);
XmlBuilder messageLevelXML = new XmlBuilder("messageLevel");
messageLevelXML.addAttribute("error", showConfigurationStatusManager.countMessagesError + "");
messageLevelXML.addAttribute("warn", showConfigurationStatusManager.countMessagesWarn + "");
messageLevelXML.addAttribute("info", showConfigurationStatusManager.countMessagesInfo + "");
summaryXML.addSubElement(messageLevelXML);
return summaryXML;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class ShowConfigurationStatus method toReceiversXml.
private XmlBuilder toReceiversXml(Configuration configurationSelected, Adapter adapter, ShowConfigurationStatusManager showConfigurationStatusManager, ShowConfigurationStatusAdapterManager showConfigurationStatusAdapterManager) {
Iterator recIt = adapter.getReceiverIterator();
if (!recIt.hasNext()) {
return null;
}
XmlBuilder receiversXML = new XmlBuilder("receivers");
while (recIt.hasNext()) {
IReceiver receiver = (IReceiver) recIt.next();
XmlBuilder receiverXML = new XmlBuilder("receiver");
receiversXML.addSubElement(receiverXML);
RunStateEnum receiverRunState = receiver.getRunState();
receiverXML.addAttribute("isStarted", "" + (receiverRunState.equals(RunStateEnum.STARTED)));
receiverXML.addAttribute("state", receiverRunState.toString());
if (receiverRunState.equals(RunStateEnum.STARTING)) {
showConfigurationStatusManager.countReceiverStateStarting++;
} else if ((receiverRunState.equals(RunStateEnum.STARTED))) {
showConfigurationStatusManager.countReceiverStateStarted++;
} else if ((receiverRunState.equals(RunStateEnum.STOPPING))) {
showConfigurationStatusManager.countReceiverStateStopping++;
} else if ((receiverRunState.equals(RunStateEnum.STOPPED))) {
showConfigurationStatusManager.countReceiverStateStopped++;
} else if ((receiverRunState.equals(RunStateEnum.ERROR))) {
showConfigurationStatusManager.countReceiverStateError++;
}
if (!showConfigurationStatusAdapterManager.stateAlert && !(receiverRunState.equals(RunStateEnum.STARTED))) {
showConfigurationStatusAdapterManager.stateAlert = true;
}
receiverXML.addAttribute("name", receiver.getName());
receiverXML.addAttribute("class", ClassUtils.nameOf(receiver));
receiverXML.addAttribute("messagesReceived", "" + receiver.getMessagesReceived());
receiverXML.addAttribute("messagesRetried", "" + receiver.getMessagesRetried());
receiverXML.addAttribute("messagesRejected", "" + receiver.getMessagesRejected());
if (configurationSelected != null) {
ISender sender = null;
if (receiver instanceof ReceiverBase) {
ReceiverBase rb = (ReceiverBase) receiver;
IListener listener = rb.getListener();
receiverXML.addAttribute("listenerClass", ClassUtils.nameOf(listener));
if (listener instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) rb.getListener()).getPhysicalDestinationName();
receiverXML.addAttribute("listenerDestination", pd);
}
if (listener instanceof HasSender) {
sender = ((HasSender) listener).getSender();
}
ITransactionalStorage ts;
ts = rb.getErrorStorage();
receiverXML.addAttribute("hasErrorStorage", "" + (ts != null));
if (ts != null) {
try {
if (SHOW_COUNT_ERRORSTORE) {
receiverXML.addAttribute("errorStorageCount", ts.getMessageCount());
} else {
receiverXML.addAttribute("errorStorageCount", "?");
}
} catch (Exception e) {
log.warn(e);
receiverXML.addAttribute("errorStorageCount", "error");
}
}
ts = rb.getMessageLog();
receiverXML.addAttribute("hasMessageLog", "" + (ts != null));
if (ts != null) {
try {
if (SHOW_COUNT_MESSAGELOG) {
receiverXML.addAttribute("messageLogCount", ts.getMessageCount());
} else {
receiverXML.addAttribute("messageLogCount", "?");
}
} catch (Exception e) {
log.warn(e);
receiverXML.addAttribute("messageLogCount", "error");
}
}
boolean isRestListener = (listener instanceof RestListener);
receiverXML.addAttribute("isRestListener", isRestListener);
if (isRestListener) {
RestListener rl = (RestListener) listener;
receiverXML.addAttribute("restUriPattern", rl.getRestUriPattern());
receiverXML.addAttribute("isView", (rl.isView() == null ? false : rl.isView()));
String matchingPattern = RestServiceDispatcher.getInstance().findMatchingPattern("/" + rl.getUriPattern());
receiverXML.addAttribute("isAvailable", (matchingPattern == null ? false : true));
}
if (showConfigurationStatusManager.count) {
if (listener instanceof JmsListenerBase) {
JmsListenerBase jlb = (JmsListenerBase) listener;
JmsMessageBrowser jmsBrowser;
if (StringUtils.isEmpty(jlb.getMessageSelector())) {
jmsBrowser = new JmsMessageBrowser();
} else {
jmsBrowser = new JmsMessageBrowser(jlb.getMessageSelector());
}
jmsBrowser.setName("MessageBrowser_" + jlb.getName());
jmsBrowser.setJmsRealm(jlb.getJmsRealName());
jmsBrowser.setDestinationName(jlb.getDestinationName());
jmsBrowser.setDestinationType(jlb.getDestinationType());
String numMsgs;
try {
int messageCount = jmsBrowser.getMessageCount();
numMsgs = String.valueOf(messageCount);
} catch (Throwable t) {
log.warn(t);
numMsgs = "?";
}
receiverXML.addAttribute("pendingMessagesCount", numMsgs);
}
}
boolean isEsbJmsFFListener = false;
if (listener instanceof EsbJmsListener) {
EsbJmsListener ejl = (EsbJmsListener) listener;
if ("FF".equalsIgnoreCase(ejl.getMessageProtocol())) {
isEsbJmsFFListener = true;
}
if (showConfigurationStatusManager.count) {
String esbNumMsgs = EsbUtils.getQueueMessageCount(ejl);
if (esbNumMsgs == null) {
esbNumMsgs = "?";
}
receiverXML.addAttribute("esbPendingMessagesCount", esbNumMsgs);
}
}
receiverXML.addAttribute("isEsbJmsFFListener", isEsbJmsFFListener);
}
if (receiver instanceof HasSender) {
ISender rsender = ((HasSender) receiver).getSender();
if (rsender != null) {
// this sender has preference, but
// avoid overwriting listeners
// sender with null
sender = rsender;
}
}
if (sender != null) {
receiverXML.addAttribute("senderName", sender.getName());
receiverXML.addAttribute("senderClass", ClassUtils.nameOf(sender));
if (sender instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) sender).getPhysicalDestinationName();
receiverXML.addAttribute("senderDestination", pd);
}
}
if (receiver instanceof IThreadCountControllable) {
IThreadCountControllable tcc = (IThreadCountControllable) receiver;
if (tcc.isThreadCountReadable()) {
receiverXML.addAttribute("threadCount", tcc.getCurrentThreadCount() + "");
receiverXML.addAttribute("maxThreadCount", tcc.getMaxThreadCount() + "");
}
if (tcc.isThreadCountControllable()) {
receiverXML.addAttribute("threadCountControllable", "true");
}
}
}
}
return receiversXML;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class ShowConfigurationStatus method toAdaptersXml.
private XmlBuilder toAdaptersXml(IbisManager ibisManager, List<Configuration> configurations, Configuration configurationSelected, List<IAdapter> registeredAdapters, ShowConfigurationStatusManager showConfigurationStatusManager) {
XmlBuilder adapters = new XmlBuilder("registeredAdapters");
if (configurationSelected != null) {
adapters.addAttribute("all", false);
} else {
adapters.addAttribute("all", true);
}
if (showConfigurationStatusManager.alert != null) {
adapters.addAttribute("alert", showConfigurationStatusManager.alert);
}
XmlBuilder configurationMessagesXml = toConfigurationMessagesXml(ibisManager, configurationSelected);
adapters.addSubElement(configurationMessagesXml);
XmlBuilder configurationExceptionsXml = toConfigurationExceptionsXml(configurations, configurationSelected);
if (configurationExceptionsXml != null) {
adapters.addSubElement(configurationExceptionsXml);
}
XmlBuilder configurationWarningsXml = toConfigurationWarningsXml(configurations, configurationSelected);
if (configurationWarningsXml != null) {
adapters.addSubElement(configurationWarningsXml);
}
for (IAdapter iAdapter : registeredAdapters) {
Adapter adapter = (Adapter) iAdapter;
XmlBuilder adapterXml = toAdapterXml(configurationSelected, adapter, showConfigurationStatusManager);
adapters.addSubElement(adapterXml);
}
XmlBuilder summaryXml = toSummaryXml(showConfigurationStatusManager);
adapters.addSubElement(summaryXml);
return adapters;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class ShowMonitorExecute method performAction.
protected String performAction(DynaActionForm monitorForm, String action, int index, int triggerIndex, HttpServletResponse response) throws MonitorException {
log.debug("performing action [" + action + "] on monitorName nr [" + index + "]");
MonitorManager mm = MonitorManager.getInstance();
if (StringUtils.isEmpty(action)) {
log.warn("monitorHandler did not find action");
return null;
}
if (action.equals("edit")) {
FormFile form_file = (FormFile) monitorForm.get("configFile");
if (form_file != null && form_file.getFileSize() > 0) {
log.debug("Upload of file [" + form_file.getFileName() + "] ContentType[" + form_file.getContentType() + "]");
Digester d = new Digester();
mm.setDigesterRules(d);
mm.getMonitors().clear();
d.push(mm);
try {
d.parse(form_file.getInputStream());
} catch (Exception e) {
error("cannot parse file [" + form_file.getFileName() + "]", e);
}
} else {
mm.updateDestinations((String[]) monitorForm.get("selDestinations"));
}
mm.setEnabled(((Boolean) monitorForm.get("enabled")).booleanValue());
return null;
}
if (action.equals("createMonitor")) {
Monitor monitor = new Monitor();
int i = 1;
while (mm.findMonitor("monitor " + i) != null) {
i++;
}
monitor.setName("monitor " + i);
mm.addMonitor(monitor);
return null;
}
if (action.equals("deleteMonitor")) {
Monitor monitor = mm.getMonitor(index);
if (monitor != null) {
log.info("removing monitor nr [" + index + "] name [" + monitor.getName() + "]");
mm.removeMonitor(index);
}
return null;
}
if (action.equals("clearMonitor")) {
Monitor monitor = mm.getMonitor(index);
if (monitor != null) {
log.info("clearing monitor [" + monitor.getName() + "]");
monitor.changeState(new Date(), false, SeverityEnum.WARNING, null, null, null);
}
return null;
}
if (action.equals("raiseMonitor")) {
Monitor monitor = mm.getMonitor(index);
if (monitor != null) {
log.info("raising monitor [" + monitor.getName() + "]");
monitor.changeState(new Date(), true, SeverityEnum.WARNING, null, null, null);
}
return null;
}
if (action.equals("exportConfig")) {
try {
response.setContentType("text/xml; charset=" + Misc.DEFAULT_INPUT_STREAM_ENCODING);
response.setHeader("Content-Disposition", "attachment; filename=\"monitorConfig-" + AppConstants.getInstance().getProperty("instance.name", "") + ".xml\"");
PrintWriter writer = response.getWriter();
XmlBuilder config = mm.toXml();
writer.print(config.toXML());
writer.close();
} catch (IOException e) {
error("could not export config", e);
}
return null;
}
log.debug("should performing action [" + action + "]");
return null;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class ShowSecurityItems method buildProvidedJmsDestinationsXml.
private XmlBuilder buildProvidedJmsDestinationsXml(String confResString, List<JmsDestination> usedJmsDestinations) throws DomBuilderException, IOException, TransformerException {
XmlBuilder providedJmsDestinationsXml = new XmlBuilder("providedJmsDestinations");
String providedJmsDestinations = Misc.getJmsDestinations(confResString);
Element providedJmsDestinationsElement = XmlUtils.buildElement(providedJmsDestinations);
Collection providedConnectionFactories = XmlUtils.getChildTags(providedJmsDestinationsElement, "connectionFactory");
Iterator providedConnectionFactoriesIterator = providedConnectionFactories.iterator();
while (providedConnectionFactoriesIterator.hasNext()) {
Element providedConnectionFactoryElement = (Element) providedConnectionFactoriesIterator.next();
String providedConnectionFactoryJndiName = providedConnectionFactoryElement.getAttribute("jndiName");
XmlBuilder providedConnectionFactoryXml = new XmlBuilder("connectionFactory");
providedConnectionFactoryXml.addAttribute("jndiName", providedConnectionFactoryJndiName);
providedJmsDestinationsXml.addSubElement(providedConnectionFactoryXml);
Collection providedDestinations = XmlUtils.getChildTags(providedConnectionFactoryElement, "destination");
Iterator providedDestinationsIterator = providedDestinations.iterator();
while (providedDestinationsIterator.hasNext()) {
Element providedDestinationElement = (Element) providedDestinationsIterator.next();
String providedValue = XmlUtils.getStringValue(providedDestinationElement);
String providedJndiName = providedDestinationElement.getAttribute("jndiName");
XmlBuilder providedDestinationXml = new XmlBuilder("destination");
providedConnectionFactoryXml.addSubElement(providedDestinationXml);
providedDestinationXml.setValue(providedValue);
providedDestinationXml.addAttribute("jndiName", providedJndiName);
if (providedConnectionFactoryJndiName != null && !usedJmsDestinations.isEmpty() && usedJmsDestinations.contains(new JmsDestination(providedConnectionFactoryJndiName, providedJndiName))) {
providedDestinationXml.addAttribute("used", "true");
}
}
}
return providedJmsDestinationsXml;
}
Aggregations