Search in sources :

Example 11 with XmlBuilder

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;
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) MessageKeeper(nl.nn.adapterframework.util.MessageKeeper)

Example 12 with XmlBuilder

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();
}
Also used : IbisManager(nl.nn.adapterframework.configuration.IbisManager) Configuration(nl.nn.adapterframework.configuration.Configuration) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) IAdapter(nl.nn.adapterframework.core.IAdapter)

Example 13 with XmlBuilder

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;
}
Also used : ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings) BaseConfigurationWarnings(nl.nn.adapterframework.configuration.BaseConfigurationWarnings) Configuration(nl.nn.adapterframework.configuration.Configuration) ArrayList(java.util.ArrayList) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) BaseConfigurationWarnings(nl.nn.adapterframework.configuration.BaseConfigurationWarnings)

Example 14 with XmlBuilder

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;
}
Also used : MessageSendingPipe(nl.nn.adapterframework.pipes.MessageSendingPipe) ISender(nl.nn.adapterframework.core.ISender) IListener(nl.nn.adapterframework.core.IListener) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) PipeLine(nl.nn.adapterframework.core.PipeLine) IPipe(nl.nn.adapterframework.core.IPipe) JdbcSenderBase(nl.nn.adapterframework.jdbc.JdbcSenderBase) PipeRunException(nl.nn.adapterframework.core.PipeRunException) HasPhysicalDestination(nl.nn.adapterframework.core.HasPhysicalDestination) ITransactionalStorage(nl.nn.adapterframework.core.ITransactionalStorage)

Example 15 with XmlBuilder

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;
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Aggregations

XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)108 IOException (java.io.IOException)18 Iterator (java.util.Iterator)17 ArrayList (java.util.ArrayList)12 Date (java.util.Date)12 SenderException (nl.nn.adapterframework.core.SenderException)12 DomBuilderException (nl.nn.adapterframework.util.DomBuilderException)10 Configuration (nl.nn.adapterframework.configuration.Configuration)9 SchedulerException (org.quartz.SchedulerException)8 ServletException (javax.servlet.ServletException)7 TransformerException (javax.xml.transform.TransformerException)7 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)6 PipeRunException (nl.nn.adapterframework.core.PipeRunException)6 JdbcException (nl.nn.adapterframework.jdbc.JdbcException)6 JmsException (nl.nn.adapterframework.jms.JmsException)6 HashMap (java.util.HashMap)5 List (java.util.List)5 Adapter (nl.nn.adapterframework.core.Adapter)5 SimpleDateFormat (java.text.SimpleDateFormat)4 Map (java.util.Map)4