use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class ShowConfigurationStatus method toConfigurationMessagesXml.
private XmlBuilder toConfigurationMessagesXml(IbisManager ibisManager, Configuration configurationSelected) {
XmlBuilder configurationMessages = new XmlBuilder("configurationMessages");
MessageKeeper messageKeeper;
if (configurationSelected != null) {
messageKeeper = ibisManager.getIbisContext().getMessageKeeper(configurationSelected.getName());
} else {
messageKeeper = ibisManager.getIbisContext().getMessageKeeper(CONFIG_ALL);
}
for (int t = 0; t < messageKeeper.size(); t++) {
XmlBuilder configurationMessage = new XmlBuilder("configurationMessage");
String msg = messageKeeper.getMessage(t).getMessageText();
if (MAX_MESSAGE_SIZE > 0 && msg.length() > MAX_MESSAGE_SIZE) {
msg = msg.substring(0, MAX_MESSAGE_SIZE) + "...(" + (msg.length() - MAX_MESSAGE_SIZE) + " characters more)";
}
configurationMessage.setValue(msg, true);
configurationMessage.addAttribute("date", DateUtils.format(messageKeeper.getMessage(t).getMessageDate(), DateUtils.FORMAT_FULL_GENERIC));
String level = messageKeeper.getMessage(t).getMessageLevel();
configurationMessage.addAttribute("level", level);
configurationMessages.addSubElement(configurationMessage);
}
return configurationMessages;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class ShowConfigurationStatus method doGet.
@Override
protected String doGet(IPipeLineSession session) throws PipeRunException {
IbisManager ibisManager = retrieveIbisManager();
String configurationName = null;
ShowConfigurationStatusManager showConfigurationStatusManager = new ShowConfigurationStatusManager();
String countStr = (String) session.get("count");
showConfigurationStatusManager.count = Boolean.parseBoolean(countStr);
String alertStr = (String) session.get("alert");
if (alertStr != null) {
showConfigurationStatusManager.alert = Boolean.parseBoolean(alertStr);
configurationName = CONFIG_ALL;
}
if (configurationName == null) {
configurationName = retrieveConfigurationName(session);
}
Configuration configuration = null;
boolean configAll;
if (configurationName == null || configurationName.equalsIgnoreCase(CONFIG_ALL)) {
configAll = true;
} else {
configuration = ibisManager.getConfiguration(configurationName);
if (configuration == null) {
configAll = true;
} else {
configAll = false;
}
}
List<Configuration> allConfigurations = ibisManager.getConfigurations();
XmlBuilder configurationsXml = toConfigurationsXml(allConfigurations);
List<IAdapter> registeredAdapters = retrieveRegisteredAdapters(ibisManager, configAll, configuration);
storeConfiguration(session, configAll, configuration);
XmlBuilder adapters = toAdaptersXml(ibisManager, allConfigurations, configuration, registeredAdapters, showConfigurationStatusManager);
XmlBuilder root = new XmlBuilder("root");
root.addSubElement(configurationsXml);
root.addSubElement(adapters);
return root.toXML();
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class ShowConfigurationStatus method toConfigurationWarningsXml.
private XmlBuilder toConfigurationWarningsXml(List<Configuration> configurations, Configuration configurationSelected) {
ConfigurationWarnings globalConfigurationWarnings = ConfigurationWarnings.getInstance();
List<ErrorStoreCounter> errorStoreCounters = retrieveErrorStoreCounters(configurations, configurationSelected);
List<String[]> selectedConfigurationWarnings = new ArrayList<String[]>();
if (configurationSelected != null) {
BaseConfigurationWarnings configWarns = configurationSelected.getConfigurationWarnings();
for (int j = 0; j < configWarns.size(); j++) {
String[] item = new String[2];
item[0] = configurationSelected.getName();
item[1] = (String) configWarns.get(j);
selectedConfigurationWarnings.add(item);
}
} else {
for (Configuration configuration : configurations) {
BaseConfigurationWarnings configWarns = configuration.getConfigurationWarnings();
for (int j = 0; j < configWarns.size(); j++) {
String[] item = new String[2];
item[0] = configuration.getName();
item[1] = (String) configWarns.get(j);
selectedConfigurationWarnings.add(item);
}
}
}
if (!globalConfigurationWarnings.isEmpty() || !errorStoreCounters.isEmpty() || !SHOW_COUNT_ERRORSTORE || !selectedConfigurationWarnings.isEmpty()) {
XmlBuilder warningsXML = new XmlBuilder("warnings");
if (!SHOW_COUNT_ERRORSTORE) {
XmlBuilder warningXML = new XmlBuilder("warning");
warningXML.setValue("Errorlog might contain records. This is unknown because errorStore.count.show is not set to true");
warningXML.addAttribute("severe", true);
warningsXML.addSubElement(warningXML);
}
for (int j = 0; j < errorStoreCounters.size(); j++) {
ErrorStoreCounter esr = errorStoreCounters.get(j);
XmlBuilder warningXML = new XmlBuilder("warning");
warningXML.addAttribute("config", esr.config);
if (esr.counter == 1) {
warningXML.setValue("Errorlog contains 1 record. Service management should check whether this record has to be resent or deleted");
} else {
warningXML.setValue("Errorlog contains " + esr.counter + " records. Service Management should check whether these records have to be resent or deleted");
}
warningXML.addAttribute("severe", true);
warningsXML.addSubElement(warningXML);
}
for (int j = 0; j < globalConfigurationWarnings.size(); j++) {
XmlBuilder warningXML = new XmlBuilder("warning");
warningXML.setValue((String) globalConfigurationWarnings.get(j));
warningsXML.addSubElement(warningXML);
}
for (int j = 0; j < selectedConfigurationWarnings.size(); j++) {
XmlBuilder warningXML = new XmlBuilder("warning");
warningXML.addAttribute("config", selectedConfigurationWarnings.get(j)[0]);
warningXML.setValue((String) selectedConfigurationWarnings.get(j)[1]);
warningsXML.addSubElement(warningXML);
}
return warningsXML;
}
return null;
}
use of nl.nn.adapterframework.util.XmlBuilder 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.util.XmlBuilder in project iaf by ibissource.
the class ShowConfigurationStatus method toAdapterMessagesXmlSelected.
private XmlBuilder toAdapterMessagesXmlSelected(Adapter adapter, ShowConfigurationStatusManager showConfigurationStatusManager) {
XmlBuilder adapterMessages = new XmlBuilder("adapterMessages");
for (int t = 0; t < adapter.getMessageKeeper().size(); t++) {
XmlBuilder adapterMessage = new XmlBuilder("adapterMessage");
String msg = adapter.getMessageKeeper().getMessage(t).getMessageText();
if (MAX_MESSAGE_SIZE > 0 && msg.length() > MAX_MESSAGE_SIZE) {
msg = msg.substring(0, MAX_MESSAGE_SIZE) + "...(" + (msg.length() - MAX_MESSAGE_SIZE) + " characters more)";
}
adapterMessage.setValue(msg, true);
adapterMessage.addAttribute("date", DateUtils.format(adapter.getMessageKeeper().getMessage(t).getMessageDate(), DateUtils.FORMAT_FULL_GENERIC));
String level = adapter.getMessageKeeper().getMessage(t).getMessageLevel();
adapterMessage.addAttribute("level", level);
adapterMessages.addSubElement(adapterMessage);
if (level.equals(MessageKeeperMessage.ERROR_LEVEL)) {
showConfigurationStatusManager.countMessagesError++;
} else {
if (level.equals(MessageKeeperMessage.WARN_LEVEL)) {
showConfigurationStatusManager.countMessagesWarn++;
} else {
showConfigurationStatusManager.countMessagesInfo++;
}
}
}
return adapterMessages;
}
Aggregations