Search in sources :

Example 26 with Adapter

use of nl.nn.adapterframework.core.Adapter in project iaf by ibissource.

the class ShowConfigurationStatus method getAdapterReceivers.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{name}/receivers")
@Produces(MediaType.APPLICATION_JSON)
public Response getAdapterReceivers(@PathParam("name") String adapterName, @QueryParam("showPendingMsgCount") boolean showPendingMsgCount) throws ApiException {
    initBase(servletConfig);
    if (ibisManager == null) {
        throw new ApiException("Config not found!");
    }
    Adapter adapter = (Adapter) ibisManager.getRegisteredAdapter(adapterName);
    if (adapter == null) {
        throw new ApiException("Adapter not found!");
    }
    ArrayList<Object> receiverInfo = mapAdapterReceivers(adapter, showPendingMsgCount);
    return Response.status(Response.Status.CREATED).entity(receiverInfo).build();
}
Also used : Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 27 with Adapter

use of nl.nn.adapterframework.core.Adapter in project iaf by ibissource.

the class ShowConfigurationStatus method getAdapterMessages.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{name}/messages")
@Produces(MediaType.APPLICATION_JSON)
public Response getAdapterMessages(@PathParam("name") String adapterName) throws ApiException {
    initBase(servletConfig);
    Adapter adapter = (Adapter) ibisManager.getRegisteredAdapter(adapterName);
    if (adapter == null) {
        throw new ApiException("Adapter not found!");
    }
    ArrayList<Object> adapterInfo = mapAdapterMessages(adapter);
    return Response.status(Response.Status.CREATED).entity(adapterInfo).build();
}
Also used : Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 28 with Adapter

use of nl.nn.adapterframework.core.Adapter in project iaf by ibissource.

the class ShowConfigurationStatus method toAdaptersXml.

private XmlBuilder toAdaptersXml(IbisManager ibisManager, List<Configuration> configurations, Configuration configurationSelected, List<IAdapter> registeredAdapters, ShowConfigurationStatusManager showConfigurationStatusManager) {
    XmlBuilder adapters = new XmlBuilder("registeredAdapters");
    if (configurationSelected != null) {
        adapters.addAttribute("all", false);
    } else {
        adapters.addAttribute("all", true);
    }
    if (showConfigurationStatusManager.alert != null) {
        adapters.addAttribute("alert", showConfigurationStatusManager.alert);
    }
    XmlBuilder configurationMessagesXml = toConfigurationMessagesXml(ibisManager, configurationSelected);
    adapters.addSubElement(configurationMessagesXml);
    XmlBuilder configurationExceptionsXml = toConfigurationExceptionsXml(configurations, configurationSelected);
    if (configurationExceptionsXml != null) {
        adapters.addSubElement(configurationExceptionsXml);
    }
    XmlBuilder configurationWarningsXml = toConfigurationWarningsXml(configurations, configurationSelected);
    if (configurationWarningsXml != null) {
        adapters.addSubElement(configurationWarningsXml);
    }
    for (IAdapter iAdapter : registeredAdapters) {
        Adapter adapter = (Adapter) iAdapter;
        XmlBuilder adapterXml = toAdapterXml(configurationSelected, adapter, showConfigurationStatusManager);
        adapters.addSubElement(adapterXml);
    }
    XmlBuilder summaryXml = toSummaryXml(showConfigurationStatusManager);
    adapters.addSubElement(summaryXml);
    return adapters;
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) IAdapter(nl.nn.adapterframework.core.IAdapter)

Example 29 with Adapter

use of nl.nn.adapterframework.core.Adapter 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)

Example 30 with Adapter

use of nl.nn.adapterframework.core.Adapter in project iaf by ibissource.

the class ServerStatistics method getServerConfiguration.

@GET
@PermitAll
@Path("/server/warnings")
@Produces(MediaType.APPLICATION_JSON)
public Response getServerConfiguration() throws ApiException {
    initBase(servletConfig);
    ConfigurationWarnings globalConfigWarnings = ConfigurationWarnings.getInstance();
    // (globalConfigWarnings.size() + 1); //Add 1 for ESR
    List<Object> warnings = new ArrayList<Object>();
    boolean showCountErrorStore = AppConstants.getInstance().getBoolean("errorStore.count.show", true);
    List<IAdapter> registeredAdapters = ibisManager.getRegisteredAdapters();
    long esr = 0;
    if (showCountErrorStore) {
        for (Iterator<IAdapter> adapterIt = registeredAdapters.iterator(); adapterIt.hasNext(); ) {
            Adapter adapter = (Adapter) adapterIt.next();
            for (Iterator<?> receiverIt = adapter.getReceiverIterator(); receiverIt.hasNext(); ) {
                ReceiverBase receiver = (ReceiverBase) receiverIt.next();
                ITransactionalStorage errorStorage = receiver.getErrorStorage();
                if (errorStorage != null) {
                    try {
                        esr += errorStorage.getMessageCount();
                    } catch (Exception e) {
                        // error("error occured on getting number of errorlog records for adapter ["+adapter.getName()+"]",e);
                        log.warn("Assuming there are no errorlog records for adapter [" + adapter.getName() + "]");
                    }
                }
            }
        }
    } else {
        esr = -1;
    }
    if (esr != 0) {
        Map<String, Object> messageObj = new HashMap<String, Object>(2);
        String message;
        if (esr == -1) {
            message = "Errorlog might contain records. This is unknown because errorStore.count.show is not set to true";
        } else if (esr == 1) {
            message = "Errorlog contains 1 record. Service management should check whether this record has to be resent or deleted";
        } else {
            message = "Errorlog contains " + esr + " records. Service Management should check whether these records have to be resent or deleted";
        }
        messageObj.put("message", message);
        messageObj.put("type", "severe");
        warnings.add(messageObj);
    }
    for (Configuration config : ibisManager.getConfigurations()) {
        if (config.getConfigurationException() != null) {
            Map<String, Object> messageObj = new HashMap<String, Object>(2);
            String message = config.getConfigurationException().getMessage();
            messageObj.put("message", message);
            messageObj.put("type", "exception");
            warnings.add(messageObj);
        }
    }
    // Configuration specific warnings
    for (Configuration configuration : ibisManager.getConfigurations()) {
        BaseConfigurationWarnings configWarns = configuration.getConfigurationWarnings();
        for (int j = 0; j < configWarns.size(); j++) {
            Map<String, Object> messageObj = new HashMap<String, Object>(1);
            messageObj.put("message", configWarns.get(j));
            messageObj.put("configuration", configuration.getName());
            warnings.add(messageObj);
        }
    }
    // Global warnings
    if (globalConfigWarnings.size() > 0) {
        for (int j = 0; j < globalConfigWarnings.size(); j++) {
            Map<String, Object> messageObj = new HashMap<String, Object>(1);
            messageObj.put("message", globalConfigWarnings.get(j));
            warnings.add(messageObj);
        }
    }
    return Response.status(Response.Status.CREATED).entity(warnings).build();
}
Also used : ReceiverBase(nl.nn.adapterframework.receivers.ReceiverBase) ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings) BaseConfigurationWarnings(nl.nn.adapterframework.configuration.BaseConfigurationWarnings) Configuration(nl.nn.adapterframework.configuration.Configuration) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) ITransactionalStorage(nl.nn.adapterframework.core.ITransactionalStorage) IAdapter(nl.nn.adapterframework.core.IAdapter) BaseConfigurationWarnings(nl.nn.adapterframework.configuration.BaseConfigurationWarnings) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) PermitAll(javax.annotation.security.PermitAll)

Aggregations

Adapter (nl.nn.adapterframework.core.Adapter)31 IAdapter (nl.nn.adapterframework.core.IAdapter)24 Iterator (java.util.Iterator)10 Path (javax.ws.rs.Path)10 Produces (javax.ws.rs.Produces)10 ReceiverBase (nl.nn.adapterframework.receivers.ReceiverBase)10 RolesAllowed (javax.annotation.security.RolesAllowed)9 IReceiver (nl.nn.adapterframework.core.IReceiver)9 GET (javax.ws.rs.GET)8 PipeLine (nl.nn.adapterframework.core.PipeLine)8 ArrayList (java.util.ArrayList)7 Configuration (nl.nn.adapterframework.configuration.Configuration)7 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)5 IListener (nl.nn.adapterframework.core.IListener)5 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)5 ServletException (javax.servlet.ServletException)4 Response (javax.ws.rs.core.Response)4 IPipe (nl.nn.adapterframework.core.IPipe)4