Search in sources :

Example 6 with Configuration

use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.

the class ShowSecurityItems method addAuthEntries.

private ArrayList<Object> addAuthEntries() {
    ArrayList<Object> authEntries = new ArrayList<Object>();
    Collection<Node> entries = null;
    try {
        URL url = ClassUtils.getResourceURL(this, AUTHALIAS_XSLT);
        if (url != null) {
            for (Configuration configuration : ibisManager.getConfigurations()) {
                Transformer t = XmlUtils.createTransformer(url, true);
                String configString = configuration.getOriginalConfiguration();
                configString = StringResolver.substVars(configString, AppConstants.getInstance());
                configString = ConfigurationUtils.getActivatedConfiguration(configuration, configString);
                String ae = XmlUtils.transformXml(t, configString);
                Element authEntriesElement = XmlUtils.buildElement(ae);
                if (entries == null) {
                    entries = XmlUtils.getChildTags(authEntriesElement, "entry");
                } else {
                    entries.addAll(XmlUtils.getChildTags(authEntriesElement, "entry"));
                }
            }
        }
    } catch (Exception e) {
        authEntries.add("*** ERROR ***");
    }
    if (entries != null) {
        Iterator<Node> iter = entries.iterator();
        while (iter.hasNext()) {
            Map<String, Object> ae = new HashMap<String, Object>();
            Element itemElement = (Element) iter.next();
            String alias = itemElement.getAttribute("alias");
            ae.put("alias", alias);
            CredentialFactory cf = new CredentialFactory(alias, null, null);
            String userName;
            String passWord;
            try {
                userName = cf.getUsername();
                passWord = StringUtils.repeat("*", cf.getPassword().length());
            } catch (Exception e) {
                userName = "*** ERROR ***";
                passWord = "*** ERROR ***";
            }
            ae.put("username", userName);
            ae.put("password", passWord);
            authEntries.add(ae);
        }
    }
    return authEntries;
}
Also used : Transformer(javax.xml.transform.Transformer) Configuration(nl.nn.adapterframework.configuration.Configuration) HashMap(java.util.HashMap) CredentialFactory(nl.nn.adapterframework.util.CredentialFactory) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) URL(java.net.URL) JdbcException(nl.nn.adapterframework.jdbc.JdbcException) JmsException(nl.nn.adapterframework.jms.JmsException) IOException(java.io.IOException)

Example 7 with Configuration

use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.

the class ConfigurationBase method doGet.

/**
 * When extending this class, copy and extend the doGet method in the new
 * child class.
 */
protected String doGet(IPipeLineSession session) throws PipeRunException {
    IbisManager ibisManager = RestListenerUtils.retrieveIbisManager(session);
    String configurationName = null;
    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);
    storeConfiguration(session, configAll, configuration);
    XmlBuilder root = new XmlBuilder("root");
    root.addSubElement(configurationsXml);
    return root.toXML();
}
Also used : IbisManager(nl.nn.adapterframework.configuration.IbisManager) Configuration(nl.nn.adapterframework.configuration.Configuration) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 8 with Configuration

use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.

the class ShowConfigurationStatus method toConfigurationExceptionsXml.

private XmlBuilder toConfigurationExceptionsXml(List<Configuration> configurations, Configuration configurationSelected) {
    List<String[]> configurationExceptions = new ArrayList<String[]>();
    if (configurationSelected != null) {
        if (configurationSelected.getConfigurationException() != null) {
            String[] item = new String[2];
            item[0] = configurationSelected.getName();
            item[1] = configurationSelected.getConfigurationException().getMessage();
            configurationExceptions.add(item);
        }
    } else {
        for (Configuration configuration : configurations) {
            if (configuration.getConfigurationException() != null) {
                String[] item = new String[2];
                item[0] = configuration.getName();
                item[1] = configuration.getConfigurationException().getMessage();
                configurationExceptions.add(item);
            }
        }
    }
    if (!configurationExceptions.isEmpty()) {
        XmlBuilder exceptionsXML = new XmlBuilder("exceptions");
        for (int j = 0; j < configurationExceptions.size(); j++) {
            XmlBuilder exceptionXML = new XmlBuilder("exception");
            exceptionXML.addAttribute("config", configurationExceptions.get(j)[0]);
            exceptionXML.setValue(configurationExceptions.get(j)[1]);
            exceptionsXML.addSubElement(exceptionXML);
        }
        return exceptionsXML;
    }
    return null;
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) ArrayList(java.util.ArrayList) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 9 with Configuration

use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.

the class ShowConfigurationStatus method retrieveErrorStoreCounters.

private List<ErrorStoreCounter> retrieveErrorStoreCounters(List<Configuration> configurations, Configuration configurationSelected) {
    List<ErrorStoreCounter> errorStoreCounters = new ArrayList<ErrorStoreCounter>();
    if (SHOW_COUNT_ERRORSTORE) {
        errorStoreCounters = new ArrayList<ErrorStoreCounter>();
        if (configurationSelected != null) {
            String config = configurationSelected.getName();
            int counter = 0;
            for (Iterator adapterIt = configurationSelected.getRegisteredAdapters().iterator(); adapterIt.hasNext(); ) {
                Adapter adapter = (Adapter) adapterIt.next();
                counter += retrieveErrorStoragesMessageCount(adapter);
            }
            if (counter > 0) {
                errorStoreCounters.add(new ErrorStoreCounter(config, counter));
            }
        } else {
            for (Configuration configuration : configurations) {
                String config = configuration.getName();
                int counter = 0;
                for (Iterator adapterIt = configuration.getRegisteredAdapters().iterator(); adapterIt.hasNext(); ) {
                    Adapter adapter = (Adapter) adapterIt.next();
                    counter += retrieveErrorStoragesMessageCount(adapter);
                }
                if (counter > 0) {
                    errorStoreCounters.add(new ErrorStoreCounter(config, counter));
                }
            }
        }
    }
    return errorStoreCounters;
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter)

Example 10 with Configuration

use of nl.nn.adapterframework.configuration.Configuration 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)

Aggregations

Configuration (nl.nn.adapterframework.configuration.Configuration)31 ArrayList (java.util.ArrayList)12 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)9 IAdapter (nl.nn.adapterframework.core.IAdapter)8 Path (javax.ws.rs.Path)7 Produces (javax.ws.rs.Produces)7 Adapter (nl.nn.adapterframework.core.Adapter)7 HashMap (java.util.HashMap)6 GET (javax.ws.rs.GET)6 Iterator (java.util.Iterator)5 LinkedHashMap (java.util.LinkedHashMap)5 RolesAllowed (javax.annotation.security.RolesAllowed)5 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)4 IbisManager (nl.nn.adapterframework.configuration.IbisManager)4 ReceiverBase (nl.nn.adapterframework.receivers.ReceiverBase)4 IOException (java.io.IOException)3 URL (java.net.URL)3 Date (java.util.Date)3 Transformer (javax.xml.transform.Transformer)3 IReceiver (nl.nn.adapterframework.core.IReceiver)3