Search in sources :

Example 56 with XmlBuilder

use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.

the class Monitor method toXml.

public XmlBuilder toXml() {
    XmlBuilder monitor = new XmlBuilder("monitor");
    monitor.addAttribute("name", getName());
    monitor.addAttribute("type", getType());
    monitor.addAttribute("destinations", getDestinationsAsString());
    for (Iterator<Trigger> it = triggers.iterator(); it.hasNext(); ) {
        Trigger trigger = (Trigger) it.next();
        trigger.toXml(monitor);
    }
    return monitor;
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 57 with XmlBuilder

use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.

the class MonitorAdapterBase method makeXml.

public String makeXml(String subSource, EventTypeEnum eventType, SeverityEnum severity, String message, Throwable t) {
    XmlBuilder eventXml = new XmlBuilder("event");
    eventXml.addAttribute("hostname", hostname);
    eventXml.addAttribute("source", sourceId);
    eventXml.addAttribute("subSource", subSource);
    eventXml.addAttribute("eventType", eventType.getName());
    eventXml.addAttribute("severity", severity.getName());
    eventXml.addAttribute("message", message);
    return eventXml.toXML();
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 58 with XmlBuilder

use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.

the class MonitorManager method toXml.

public XmlBuilder toXml() {
    XmlBuilder configXml = new XmlBuilder("monitoring");
    configXml.addAttribute("enabled", isEnabled());
    XmlBuilder destinationsXml = new XmlBuilder("destinations");
    for (Iterator it = destinations.keySet().iterator(); it.hasNext(); ) {
        String name = (String) it.next();
        IMonitorAdapter ma = getDestination(name);
        XmlBuilder destinationXml = new XmlBuilder("destination");
        destinationXml.addAttribute("name", ma.getName());
        destinationXml.addAttribute("className", ma.getClass().getName());
        destinationsXml.addSubElement(ma.toXml());
    }
    configXml.addSubElement(destinationsXml);
    XmlBuilder monitorsXml = new XmlBuilder("monitors");
    for (int i = 0; i < monitors.size(); i++) {
        Monitor monitor = getMonitor(i);
        monitorsXml.addSubElement(monitor.toXml());
    }
    configXml.addSubElement(monitorsXml);
    return configXml;
}
Also used : Iterator(java.util.Iterator) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 59 with XmlBuilder

use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.

the class SenderMonitorAdapter method toXml.

public XmlBuilder toXml() {
    XmlBuilder result = super.toXml();
    XmlBuilder senderXml = new XmlBuilder("sender");
    senderXml.addAttribute("className", getSender().getClass().getName());
    try {
        Map properties = BeanUtils.describe(sender);
        for (Iterator it = properties.keySet().iterator(); it.hasNext(); ) {
            String property = (String) it.next();
            if (!property.equals("name")) {
                addNonDefaultAttribute(senderXml, sender, property);
            }
        }
    } catch (Exception e) {
        log.error("cannot set attributes of sender [" + ClassUtils.nameOf(sender) + "]");
    }
    result.addSubElement(senderXml);
    return result;
}
Also used : Iterator(java.util.Iterator) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) Map(java.util.Map) SenderException(nl.nn.adapterframework.core.SenderException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 60 with XmlBuilder

use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.

the class Trigger method toXml.

public void toXml(XmlBuilder monitor) {
    XmlBuilder trigger = new XmlBuilder(isAlarm() ? "alarm" : "clearing");
    monitor.addSubElement(trigger);
    if (getSeverity() != null) {
        trigger.addAttribute("severity", getSeverity());
    }
    if (getThreshold() > 0) {
        trigger.addAttribute("threshold", getThreshold());
    }
    if (getPeriod() > 0) {
        trigger.addAttribute("period", getPeriod());
    }
    XmlBuilder events = new XmlBuilder("events");
    trigger.addSubElement(events);
    for (int i = 0; i < eventCodes.size(); i++) {
        XmlBuilder event = new XmlBuilder("event");
        events.addSubElement(event);
        event.setValue((String) eventCodes.get(i));
    }
    if (getAdapterFilters() != null) {
        XmlBuilder filtersXml = new XmlBuilder("filters");
        filtersXml.addAttribute("filterExclusive", isFilterExclusive());
        trigger.addSubElement(filtersXml);
        if (getSourceFiltering() != SOURCE_FILTERING_NONE) {
            for (Iterator<String> it = getAdapterFilters().keySet().iterator(); it.hasNext(); ) {
                String adapterName = (String) it.next();
                AdapterFilter af = (AdapterFilter) getAdapterFilters().get(adapterName);
                XmlBuilder adapter = new XmlBuilder("adapterfilter");
                filtersXml.addSubElement(adapter);
                adapter.addAttribute("adapter", adapterName);
                if (isFilterOnLowerLevelObjects()) {
                    XmlBuilder sourcesXml = new XmlBuilder("sources");
                    adapter.addSubElement(sourcesXml);
                    List subobjectList = af.getSubObjectList();
                    if (subobjectList != null) {
                        for (Iterator it2 = subobjectList.iterator(); it2.hasNext(); ) {
                            String subObjectName = (String) it2.next();
                            XmlBuilder sourceXml = new XmlBuilder("source");
                            sourcesXml.addSubElement(sourceXml);
                            sourceXml.setValue(subObjectName);
                        }
                    }
                }
            }
        }
    }
}
Also used : Iterator(java.util.Iterator) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList)

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