Search in sources :

Example 6 with IAdapter

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

the class Trigger method getAdapterList.

public List<IAdapter> getAdapterList() {
    List<IAdapter> result = new LinkedList<IAdapter>();
    MonitorManager mm = MonitorManager.getInstance();
    for (Iterator<String> it = adapterFilters.keySet().iterator(); it.hasNext(); ) {
        String adapterName = (String) it.next();
        IAdapter adapter = mm.findAdapterByName(adapterName);
        if (adapter != null) {
            result.add(adapter);
            if (log.isDebugEnabled()) {
                log.debug(getLogPrefix() + "getAdapterList() returns adapter [" + adapterName + "]");
            }
        } else {
            log.warn(getLogPrefix() + "getAdapterList() cannot find adapter [" + adapterName + "]");
        }
    }
    return result;
}
Also used : IAdapter(nl.nn.adapterframework.core.IAdapter) LinkedList(java.util.LinkedList)

Example 7 with IAdapter

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

the class ShowConfigurationStatus method getAdapters.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters")
@Produces(MediaType.APPLICATION_JSON)
public Response getAdapters(@QueryParam("expanded") String expanded, @QueryParam("showPendingMsgCount") boolean showPendingMsgCount) throws ApiException {
    initBase(servletConfig);
    if (ibisManager == null) {
        throw new ApiException("Config not found!");
    }
    Map<String, Object> adapterList = new HashMap<String, Object>();
    List<IAdapter> registeredAdapters = ibisManager.getRegisteredAdapters();
    for (Iterator<IAdapter> adapterIt = registeredAdapters.iterator(); adapterIt.hasNext(); ) {
        Adapter adapter = (Adapter) adapterIt.next();
        Map<String, Object> adapterInfo = mapAdapter(adapter);
        if (expanded != null && !expanded.isEmpty()) {
            if (expanded.equalsIgnoreCase("all")) {
                adapterInfo.put("receivers", mapAdapterReceivers(adapter, showPendingMsgCount));
                adapterInfo.put("pipes", mapAdapterPipes(adapter));
                adapterInfo.put("messages", mapAdapterMessages(adapter));
            } else if (expanded.equalsIgnoreCase("receivers")) {
                adapterInfo.put("receivers", mapAdapterReceivers(adapter, showPendingMsgCount));
            } else if (expanded.equalsIgnoreCase("pipes")) {
                adapterInfo.put("pipes", mapAdapterPipes(adapter));
            } else if (expanded.equalsIgnoreCase("messages")) {
                adapterInfo.put("messages", mapAdapterMessages(adapter));
            } else {
                throw new ApiException("Invalid value [" + expanded + "] for parameter expanded supplied!");
            }
        }
        adapterList.put((String) adapterInfo.get("name"), adapterInfo);
    }
    Response.ResponseBuilder response = null;
    // Calculate the ETag on last modified date of user resource
    EntityTag etag = new EntityTag(adapterList.hashCode() + "");
    // Verify if it matched with etag available in http request
    response = request.evaluatePreconditions(etag);
    // If ETag matches the response will be non-null;
    if (response != null) {
        return response.tag(etag).build();
    }
    response = Response.status(Response.Status.CREATED).entity(adapterList).tag(etag);
    return response.build();
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) EntityTag(javax.ws.rs.core.EntityTag) 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 8 with IAdapter

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

the class SlotIdRecord method getSlotmap.

private Map<String, SlotIdRecord> getSlotmap() {
    Map<String, SlotIdRecord> slotmap = new HashMap<String, SlotIdRecord>();
    for (IAdapter iAdapter : ibisManager.getRegisteredAdapters()) {
        Adapter adapter = (Adapter) iAdapter;
        for (Iterator<?> receiverIt = adapter.getReceiverIterator(); receiverIt.hasNext(); ) {
            ReceiverBase receiver = (ReceiverBase) receiverIt.next();
            ITransactionalStorage errorStorage = receiver.getErrorStorage();
            if (errorStorage != null) {
                String slotId = errorStorage.getSlotId();
                if (StringUtils.isNotEmpty(slotId)) {
                    SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
                    String type = errorStorage.getType();
                    slotmap.put(type + "/" + slotId, sir);
                }
            }
            ITransactionalStorage messageLog = receiver.getMessageLog();
            if (messageLog != null) {
                String slotId = messageLog.getSlotId();
                if (StringUtils.isNotEmpty(slotId)) {
                    SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
                    String type = messageLog.getType();
                    slotmap.put(type + "/" + slotId, sir);
                }
            }
        }
        PipeLine pipeline = adapter.getPipeLine();
        if (pipeline != null) {
            for (int i = 0; i < pipeline.getPipeLineSize(); i++) {
                IPipe pipe = pipeline.getPipe(i);
                if (pipe instanceof MessageSendingPipe) {
                    MessageSendingPipe msp = (MessageSendingPipe) pipe;
                    ITransactionalStorage messageLog = msp.getMessageLog();
                    if (messageLog != null) {
                        String slotId = messageLog.getSlotId();
                        if (StringUtils.isNotEmpty(slotId)) {
                            SlotIdRecord sir = new SlotIdRecord(adapter.getName(), null, msp.getName());
                            String type = messageLog.getType();
                            slotmap.put(type + "/" + slotId, sir);
                            slotmap.put(slotId, sir);
                        }
                    }
                }
            }
        }
    }
    return slotmap;
}
Also used : ReceiverBase(nl.nn.adapterframework.receivers.ReceiverBase) MessageSendingPipe(nl.nn.adapterframework.pipes.MessageSendingPipe) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) ITransactionalStorage(nl.nn.adapterframework.core.ITransactionalStorage) PipeLine(nl.nn.adapterframework.core.PipeLine) IAdapter(nl.nn.adapterframework.core.IAdapter) IPipe(nl.nn.adapterframework.core.IPipe)

Example 9 with IAdapter

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

the class Webservices method getLogDirectory.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/webservices")
@Relation("webservices")
@Produces(MediaType.APPLICATION_JSON)
public Response getLogDirectory() throws ApiException {
    initBase(servletConfig);
    Map<String, Object> returnMap = new HashMap<String, Object>();
    List<Map<String, Object>> webServices = new ArrayList<Map<String, Object>>();
    for (IAdapter a : ibisManager.getRegisteredAdapters()) {
        Adapter adapter = (Adapter) a;
        Iterator<IReceiver> recIt = adapter.getReceiverIterator();
        while (recIt.hasNext()) {
            IReceiver receiver = 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()) {
                        Map<String, Object> service = new HashMap<String, Object>(2);
                        service.put("name", rb.getName());
                        service.put("uriPattern", rl.getUriPattern());
                        webServices.add(service);
                    }
                }
            }
        }
    }
    returnMap.put("services", webServices);
    List<Map<String, Object>> wsdls = new ArrayList<Map<String, Object>>();
    for (IAdapter a : ibisManager.getRegisteredAdapters()) {
        Map<String, Object> wsdlMap = new HashMap<String, Object>(2);
        try {
            Adapter adapter = (Adapter) a;
            Wsdl wsdl = new Wsdl(adapter.getPipeLine());
            wsdlMap.put("name", wsdl.getName());
            wsdlMap.put("extention", getWsdlExtention());
        } catch (Exception e) {
            wsdlMap.put("name", a.getName());
            if (e.getMessage() != null) {
                wsdlMap.put("error", e.getMessage());
            } else {
                wsdlMap.put("error", e.toString());
            }
        }
        wsdls.add(wsdlMap);
    }
    returnMap.put("wsdls", wsdls);
    return Response.status(Response.Status.OK).entity(returnMap).build();
}
Also used : ReceiverBase(nl.nn.adapterframework.receivers.ReceiverBase) HashMap(java.util.HashMap) IListener(nl.nn.adapterframework.core.IListener) ArrayList(java.util.ArrayList) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) Wsdl(nl.nn.adapterframework.soap.Wsdl) RestListener(nl.nn.adapterframework.http.RestListener) IReceiver(nl.nn.adapterframework.core.IReceiver) HashMap(java.util.HashMap) Map(java.util.Map) 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 10 with IAdapter

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

IAdapter (nl.nn.adapterframework.core.IAdapter)41 Adapter (nl.nn.adapterframework.core.Adapter)15 Iterator (java.util.Iterator)13 ArrayList (java.util.ArrayList)12 ReceiverBase (nl.nn.adapterframework.receivers.ReceiverBase)11 IReceiver (nl.nn.adapterframework.core.IReceiver)10 IOException (java.io.IOException)8 List (java.util.List)8 Configuration (nl.nn.adapterframework.configuration.Configuration)7 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)7 HashMap (java.util.HashMap)6 LinkedList (java.util.LinkedList)6 IListener (nl.nn.adapterframework.core.IListener)6 PipeRunException (nl.nn.adapterframework.core.PipeRunException)6 ITransactionalStorage (nl.nn.adapterframework.core.ITransactionalStorage)5 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 IPipe (nl.nn.adapterframework.core.IPipe)4 PipeLineResult (nl.nn.adapterframework.core.PipeLineResult)4 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)4