Search in sources :

Example 1 with ApiListener

use of nl.nn.adapterframework.http.rest.ApiListener in project iaf by ibissource.

the class Webservices method list.

private String list(IbisManager ibisManager) {
    XmlBuilder webservicesXML = new XmlBuilder("webservices");
    // RestListeners
    XmlBuilder restsXML = new XmlBuilder("rests");
    for (IAdapter a : ibisManager.getRegisteredAdapters()) {
        Adapter adapter = (Adapter) a;
        Iterator recIt = adapter.getReceiverIterator();
        while (recIt.hasNext()) {
            IReceiver receiver = (IReceiver) recIt.next();
            if (receiver instanceof ReceiverBase) {
                ReceiverBase rb = (ReceiverBase) receiver;
                IListener listener = rb.getListener();
                if (listener instanceof RestListener) {
                    RestListener rl = (RestListener) listener;
                    if (rl.isView()) {
                        XmlBuilder restXML = new XmlBuilder("rest");
                        restXML.addAttribute("name", rb.getName());
                        restXML.addAttribute("uriPattern", rl.getUriPattern());
                        restsXML.addSubElement(restXML);
                    }
                }
            }
        }
    }
    webservicesXML.addSubElement(restsXML);
    // WSDL's
    XmlBuilder wsdlsXML = new XmlBuilder("wsdls");
    for (IAdapter a : ibisManager.getRegisteredAdapters()) {
        XmlBuilder wsdlXML = new XmlBuilder("wsdl");
        try {
            Adapter adapter = (Adapter) a;
            Wsdl wsdl = new Wsdl(adapter.getPipeLine());
            wsdlXML.addAttribute("name", wsdl.getName());
            wsdlXML.addAttribute("extention", getWsdlExtention());
        } catch (Exception e) {
            wsdlXML.addAttribute("name", a.getName());
            XmlBuilder errorXML = new XmlBuilder("error");
            if (e.getMessage() != null) {
                errorXML.setCdataValue(e.getMessage());
            } else {
                errorXML.setCdataValue(e.toString());
            }
            wsdlXML.addSubElement(errorXML);
        }
        wsdlsXML.addSubElement(wsdlXML);
    }
    webservicesXML.addSubElement(wsdlsXML);
    // ApiListeners
    XmlBuilder apiListenerXML = new XmlBuilder("apiListeners");
    SortedMap<String, ApiDispatchConfig> patternClients = ApiServiceDispatcher.getInstance().getPatternClients();
    for (Entry<String, ApiDispatchConfig> client : patternClients.entrySet()) {
        XmlBuilder apiXML = new XmlBuilder("apiListener");
        ApiDispatchConfig config = client.getValue();
        Set<String> methods = config.getMethods();
        for (String method : methods) {
            ApiListener listener = config.getApiListener(method);
            XmlBuilder methodXML = new XmlBuilder(method);
            String name = listener.getName();
            if (name.contains("listener of ["))
                name = name.substring(13, name.length() - 1);
            methodXML.addAttribute("name", name);
            methodXML.addAttribute("updateEtag", listener.getUpdateEtag());
            methodXML.addAttribute("isRunning", listener.isRunning());
            apiXML.addSubElement(methodXML);
        }
        apiXML.addAttribute("uriPattern", config.getUriPattern());
        apiListenerXML.addSubElement(apiXML);
    }
    webservicesXML.addSubElement(apiListenerXML);
    return webservicesXML.toXML();
}
Also used : ReceiverBase(nl.nn.adapterframework.receivers.ReceiverBase) IListener(nl.nn.adapterframework.core.IListener) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) Wsdl(nl.nn.adapterframework.soap.Wsdl) PipeRunException(nl.nn.adapterframework.core.PipeRunException) NamingException(javax.naming.NamingException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) RestListener(nl.nn.adapterframework.http.RestListener) IReceiver(nl.nn.adapterframework.core.IReceiver) ApiListener(nl.nn.adapterframework.http.rest.ApiListener) Iterator(java.util.Iterator) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) ApiDispatchConfig(nl.nn.adapterframework.http.rest.ApiDispatchConfig) IAdapter(nl.nn.adapterframework.core.IAdapter)

Aggregations

IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 NamingException (javax.naming.NamingException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 Adapter (nl.nn.adapterframework.core.Adapter)1 IAdapter (nl.nn.adapterframework.core.IAdapter)1 IListener (nl.nn.adapterframework.core.IListener)1 IReceiver (nl.nn.adapterframework.core.IReceiver)1 PipeRunException (nl.nn.adapterframework.core.PipeRunException)1 RestListener (nl.nn.adapterframework.http.RestListener)1 ApiDispatchConfig (nl.nn.adapterframework.http.rest.ApiDispatchConfig)1 ApiListener (nl.nn.adapterframework.http.rest.ApiListener)1 ReceiverBase (nl.nn.adapterframework.receivers.ReceiverBase)1 Wsdl (nl.nn.adapterframework.soap.Wsdl)1 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)1