Search in sources :

Example 16 with XmlBuilder

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

the class TestPipeLine method retrieveFormInput.

private String retrieveFormInput(IPipeLineSession session) {
    List<String> adapterNames = new ArrayList<String>();
    adapterNames.add("-- select an adapter --");
    adapterNames.addAll(RestListenerUtils.retrieveIbisManager(session).getSortedStartedAdapterNames());
    XmlBuilder adaptersXML = new XmlBuilder("adapters");
    for (int i = 0; i < adapterNames.size(); i++) {
        XmlBuilder adapterXML = new XmlBuilder("adapter");
        adapterXML.setValue(adapterNames.get(i));
        adaptersXML.addSubElement(adapterXML);
    }
    adaptersXML.addAttribute("timeout", getTimeout());
    return adaptersXML.toXML();
}
Also used : ArrayList(java.util.ArrayList) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 17 with XmlBuilder

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

the class ShowEnvironmentVariables method executeSub.

public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    // Initialize action
    initAction(request);
    if (ibisManager == null)
        return (mapping.findForward("noIbisContext"));
    DynaActionForm configurationPropertiesForm = getPersistentForm(mapping, form, request);
    Logger rl = LogUtil.getRootLogger();
    configurationPropertiesForm.set("logLevel", rl.getLevel().toString());
    configurationPropertiesForm.set("logIntermediaryResults", new Boolean(false));
    if (AppConstants.getInstance().getResolvedProperty("log.logIntermediaryResults") != null) {
        if (AppConstants.getInstance().getResolvedProperty("log.logIntermediaryResults").equalsIgnoreCase("true")) {
            configurationPropertiesForm.set("logIntermediaryResults", new Boolean(true));
        }
    }
    Appender appender = rl.getAppender("appwrap");
    if (appender != null && appender instanceof IbisAppenderWrapper) {
        IbisAppenderWrapper iaw = (IbisAppenderWrapper) appender;
        configurationPropertiesForm.set("lengthLogRecords", iaw.getMaxMessageLength());
    } else {
        configurationPropertiesForm.set("lengthLogRecords", -1);
    }
    // Retrieve environment variables for browsing
    XmlBuilder configurationsXml = new XmlBuilder("configurations");
    List<Configuration> configurations = ibisManager.getConfigurations();
    for (Configuration configuration : configurations) {
        XmlBuilder configurationXml = new XmlBuilder("configuration");
        configurationXml.setValue(configuration.getConfigurationName());
        configurationXml.addAttribute("nameUC", Misc.toSortName(configuration.getConfigurationName()));
        configurationsXml.addSubElement(configurationXml);
    }
    request.setAttribute("configurations", configurationsXml.toXML());
    Configuration configuration;
    String configurationName = request.getParameter("configuration");
    if (configurationName == null) {
        configurationName = (String) request.getSession().getAttribute("configurationName");
    }
    if (configurationName == null || configurationName.equalsIgnoreCase(CONFIG_ALL) || ibisManager.getConfiguration(configurationName) == null) {
        configuration = configurations.get(0);
        request.getSession().setAttribute("configurationName", configuration.getName());
    } else {
        configuration = ibisManager.getConfiguration(configurationName);
        request.getSession().setAttribute("configurationName", configuration.getName());
    }
    List<String> propsToHide = new ArrayList<String>();
    String propertiesHideString = AppConstants.getInstance(configuration.getClassLoader()).getString("properties.hide", null);
    if (propertiesHideString != null) {
        propsToHide.addAll(Arrays.asList(propertiesHideString.split("[,\\s]+")));
    }
    XmlBuilder envVars = new XmlBuilder("environmentVariables");
    addPropertiesToXmlBuilder(envVars, AppConstants.getInstance(configuration.getClassLoader()), "Application Constants", propsToHide, true);
    addPropertiesToXmlBuilder(envVars, System.getProperties(), "System Properties", propsToHide);
    try {
        addPropertiesToXmlBuilder(envVars, Misc.getEnvironmentVariables(), "Environment Variables");
    } catch (Throwable t) {
        log.warn("caught Throwable while getting EnvironmentVariables", t);
    }
    addPropertiesToXmlBuilder(envVars, JdbcUtil.retrieveJdbcPropertiesFromDatabase(), "Jdbc Properties", propsToHide);
    request.setAttribute("envVars", envVars.toXML());
    // Forward control to the specified success URI
    log.debug("forward to success");
    return (mapping.findForward("success"));
}
Also used : Appender(org.apache.log4j.Appender) DynaActionForm(org.apache.struts.action.DynaActionForm) Configuration(nl.nn.adapterframework.configuration.Configuration) ArrayList(java.util.ArrayList) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) Logger(org.apache.log4j.Logger) IbisAppenderWrapper(nl.nn.adapterframework.extensions.log4j.IbisAppenderWrapper)

Example 18 with XmlBuilder

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

the class ShowEnvironmentVariables method addPropertiesToXmlBuilder.

public void addPropertiesToXmlBuilder(XmlBuilder container, Properties props, String setName, List<String> propsToHide, boolean skipResolve) {
    Enumeration enumeration = props.keys();
    XmlBuilder propertySet = new XmlBuilder("propertySet");
    propertySet.addAttribute("name", setName);
    container.addSubElement(propertySet);
    while (enumeration.hasMoreElements()) {
        String propName = (String) enumeration.nextElement();
        XmlBuilder property = new XmlBuilder("property");
        property.addAttribute("name", XmlUtils.encodeCdataString(propName));
        String propValue;
        if (skipResolve && props instanceof AppConstants) {
            propValue = ((AppConstants) props).getUnresolvedProperty(propName);
        } else {
            propValue = props.getProperty(propName);
        }
        if (propsToHide != null && propsToHide.contains(propName)) {
            propValue = Misc.hide(propValue);
        }
        property.setCdataValue(XmlUtils.encodeCdataString(propValue));
        propertySet.addSubElement(property);
    }
}
Also used : Enumeration(java.util.Enumeration) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 19 with XmlBuilder

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

the class SlotIdRecord method getResult.

@Override
protected String getResult(ResultSet resultset, Object blobSessionVar, Object clobSessionVar, HttpServletResponse response, String contentType, String contentDisposition) throws JdbcException, SQLException, IOException {
    XmlBuilder result = new XmlBuilder("result");
    String previousType = null;
    XmlBuilder typeXml = null;
    String previousSlot = null;
    XmlBuilder slotXml = null;
    int typeslotcount = 0;
    int typedatecount = 0;
    int typemsgcount = 0;
    int slotdatecount = 0;
    int slotmsgcount = 0;
    while (resultset.next()) {
        String type = resultset.getString("type");
        String slotid = resultset.getString("slotid");
        String date = resultset.getString("msgdate");
        int count = resultset.getInt("msgcount");
        if (type == null) {
            type = "";
        }
        if (slotid == null) {
            slotid = "";
        }
        if (!type.equals(previousType)) {
            if (typeXml != null) {
                typeXml.addAttribute("slotcount", typeslotcount);
                typeXml.addAttribute("datecount", typedatecount);
                typeXml.addAttribute("msgcount", typemsgcount);
                typeslotcount = 0;
                typedatecount = 0;
                typemsgcount = 0;
                previousSlot = null;
            }
            typeXml = new XmlBuilder("type");
            typeXml.addAttribute("id", type);
            if (type.equalsIgnoreCase("E")) {
                typeXml.addAttribute("name", "errorlog");
            } else {
                typeXml.addAttribute("name", "messagelog");
            }
            result.addSubElement(typeXml);
            previousType = type;
        }
        if (!slotid.equals(previousSlot)) {
            if (slotXml != null) {
                slotXml.addAttribute("datecount", slotdatecount);
                slotXml.addAttribute("msgcount", slotmsgcount);
                slotdatecount = 0;
                slotmsgcount = 0;
            }
            slotXml = new XmlBuilder("slot");
            slotXml.addAttribute("id", slotid);
            if (StringUtils.isNotEmpty(slotid)) {
                SlotIdRecord sir = (SlotIdRecord) slotmap.get(type + "/" + slotid);
                if (sir != null) {
                    slotXml.addAttribute("adapter", sir.adapterName);
                    if (StringUtils.isNotEmpty(sir.receiverName)) {
                        slotXml.addAttribute("receiver", sir.receiverName);
                    }
                    if (StringUtils.isNotEmpty(sir.pipeName)) {
                        slotXml.addAttribute("pipe", sir.pipeName);
                    }
                }
            }
            typeXml.addSubElement(slotXml);
            previousSlot = slotid;
            typeslotcount++;
        }
        typemsgcount += count;
        typedatecount++;
        slotmsgcount += count;
        slotdatecount++;
        XmlBuilder dateXml = new XmlBuilder("date");
        dateXml.addAttribute("id", date);
        dateXml.addAttribute("count", count);
        slotXml.addSubElement(dateXml);
    }
    if (typeXml != null) {
        typeXml.addAttribute("slotcount", typeslotcount);
        typeXml.addAttribute("datecount", typedatecount);
        typeXml.addAttribute("msgcount", typemsgcount);
    }
    if (slotXml != null) {
        slotXml.addAttribute("datecount", slotdatecount);
        slotXml.addAttribute("msgcount", slotmsgcount);
        slotdatecount = 0;
        slotmsgcount = 0;
    }
    return result.toXML();
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 20 with XmlBuilder

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

the class ShowSecurityItems method addApplicationDeploymentDescriptor.

private void addApplicationDeploymentDescriptor(XmlBuilder securityItems) {
    XmlBuilder appDD = new XmlBuilder("applicationDeploymentDescriptor");
    String appDDString = null;
    try {
        appDDString = Misc.getApplicationDeploymentDescriptor();
        appDDString = XmlUtils.skipXmlDeclaration(appDDString);
        appDDString = XmlUtils.skipDocTypeDeclaration(appDDString);
        appDDString = XmlUtils.removeNamespaces(appDDString);
    } catch (IOException e) {
        appDDString = "*** ERROR ***";
    }
    appDD.setValue(appDDString, false);
    securityItems.addSubElement(appDD);
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) IOException(java.io.IOException)

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