Search in sources :

Example 26 with Configuration

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

the class ShowConfiguration method reloadConfiguration.

@PUT
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/configurations/{configuration}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response reloadConfiguration(@PathParam("configuration") String configurationName, LinkedHashMap<String, Object> json) throws ApiException {
    initBase(servletConfig);
    Configuration configuration = ibisManager.getConfiguration(configurationName);
    if (configuration == null) {
        throw new ApiException("Configuration not found!");
    }
    // PUT defaults to no content
    Response.ResponseBuilder response = Response.status(Response.Status.NO_CONTENT);
    for (Entry<String, Object> entry : json.entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
        if (key.equalsIgnoreCase("action")) {
            if (value.equals("reload")) {
                ibisManager.handleAdapter("RELOAD", configurationName, "", "", null, false);
            }
            response.entity("{\"status\":\"ok\"}");
        }
    }
    return response.build();
}
Also used : Response(javax.ws.rs.core.Response) Configuration(nl.nn.adapterframework.configuration.Configuration) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 27 with Configuration

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

the class ConfigurationBase method toConfigurationsXml.

protected XmlBuilder toConfigurationsXml(List<Configuration> configurations) {
    XmlBuilder configurationsXml = new XmlBuilder("configurations");
    XmlBuilder configurationAllXml = new XmlBuilder("configuration");
    configurationAllXml.setValue(CONFIG_ALL);
    configurationAllXml.addAttribute("nameUC", "0" + Misc.toSortName(CONFIG_ALL));
    configurationsXml.addSubElement(configurationAllXml);
    for (Configuration configuration : configurations) {
        XmlBuilder configurationXml = new XmlBuilder("configuration");
        configurationXml.setValue(configuration.getConfigurationName());
        configurationXml.addAttribute("nameUC", "1" + Misc.toSortName(configuration.getConfigurationName()));
        configurationsXml.addSubElement(configurationXml);
    }
    return configurationsXml;
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 28 with Configuration

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

the class ShowConfiguration method doGet.

@Override
protected String doGet(IPipeLineSession session) throws PipeRunException {
    IbisManager ibisManager = retrieveIbisManager();
    String 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);
    StringBuilder sb = new StringBuilder();
    boolean showConfigurationOriginal = AppConstants.getInstance().getBoolean("showConfiguration.original", false);
    if (configAll) {
        sb.append("<configurations>");
        for (Configuration configuration_iter : allConfigurations) {
            if (showConfigurationOriginal) {
                sb.append(XmlUtils.skipXmlDeclaration(configuration_iter.getOriginalConfiguration()));
            } else {
                sb.append(XmlUtils.skipXmlDeclaration(configuration_iter.getLoadedConfiguration()));
            }
        }
        sb.append("</configurations>");
    } else {
        if (showConfigurationOriginal) {
            sb.append(configuration.getOriginalConfiguration());
        } else {
            sb.append(configuration.getLoadedConfiguration());
        }
    }
    XmlBuilder configSource = new XmlBuilder("configSource");
    configSource.setCdataValue(sb.toString());
    configSource.addAttribute("original", showConfigurationOriginal);
    storeConfiguration(session, configAll, configuration);
    XmlBuilder root = new XmlBuilder("root");
    root.addSubElement(configurationsXml);
    root.addSubElement(configSource);
    return root.toXML();
}
Also used : IbisManager(nl.nn.adapterframework.configuration.IbisManager) Configuration(nl.nn.adapterframework.configuration.Configuration) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 29 with Configuration

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

the class ShowSecurityItems method retrieveUsedJmsDestinations.

private List<JmsDestination> retrieveUsedJmsDestinations() throws DomBuilderException {
    List<JmsDestination> usedJmsDestinations = new ArrayList<JmsDestination>();
    StringBuilder config = new StringBuilder("<config>");
    for (Configuration configuration : ibisManager.getConfigurations()) {
        config.append(configuration.getLoadedConfiguration());
    }
    config.append("</config>");
    Document document = XmlUtils.buildDomDocument(config.toString());
    NodeList nodeList = document.getElementsByTagName("*");
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element) node;
            if (element.hasAttribute("destinationName") && !"false".equalsIgnoreCase(element.getAttribute("lookupDestination"))) {
                JmsRealm jmsRealm = JmsRealmFactory.getInstance().getJmsRealm(element.getAttribute("jmsRealm"));
                if (jmsRealm != null) {
                    String connectionFactory = jmsRealm.retrieveConnectionFactoryName();
                    usedJmsDestinations.add(new JmsDestination(connectionFactory, element.getAttribute("destinationName")));
                }
            }
        }
    }
    return usedJmsDestinations;
}
Also used : JmsRealm(nl.nn.adapterframework.jms.JmsRealm) Configuration(nl.nn.adapterframework.configuration.Configuration) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document)

Example 30 with Configuration

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

the class ShowSecurityItems method addAuthEntries.

private void addAuthEntries(XmlBuilder securityItems) {
    XmlBuilder aes = new XmlBuilder("authEntries");
    securityItems.addSubElement(aes);
    List entries = new ArrayList();
    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.getLoadedConfiguration();
                String authEntries = XmlUtils.transformXml(t, configString);
                log.debug("authentication aliases for configuration [" + configuration.getName() + "] found [" + authEntries.trim() + "]");
                Collection<String> c = XmlUtils.evaluateXPathNodeSet(authEntries, "authEntries/entry/@alias");
                if (c != null && c.size() > 0) {
                    for (Iterator<String> cit = c.iterator(); cit.hasNext(); ) {
                        String entry = cit.next();
                        if (!entries.contains(entry)) {
                            entries.add(entry);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        XmlBuilder ae = new XmlBuilder("entry");
        aes.addSubElement(ae);
        ae.addAttribute("alias", "*** ERROR ***");
    }
    if (entries != null) {
        Collections.sort(entries);
        Iterator iter = entries.iterator();
        while (iter.hasNext()) {
            String alias = (String) iter.next();
            CredentialFactory cf = new CredentialFactory(alias, null, null);
            XmlBuilder ae = new XmlBuilder("entry");
            aes.addSubElement(ae);
            ae.addAttribute("alias", alias);
            String userName;
            String passWord;
            try {
                userName = cf.getUsername();
                passWord = StringUtils.repeat("*", cf.getPassword().length());
            } catch (Exception e) {
                userName = "*** ERROR ***";
                passWord = "*** ERROR ***";
            }
            ae.addAttribute("userName", userName);
            ae.addAttribute("passWord", passWord);
        }
    }
}
Also used : Transformer(javax.xml.transform.Transformer) Configuration(nl.nn.adapterframework.configuration.Configuration) CredentialFactory(nl.nn.adapterframework.util.CredentialFactory) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) URL(java.net.URL) ServletException(javax.servlet.ServletException) DomBuilderException(nl.nn.adapterframework.util.DomBuilderException) TransformerException(javax.xml.transform.TransformerException) JdbcException(nl.nn.adapterframework.jdbc.JdbcException) JmsException(nl.nn.adapterframework.jms.JmsException) IOException(java.io.IOException)

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