Search in sources :

Example 21 with Adapter

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

the class IbisSoapServlet method zip.

private void zip(HttpServletRequest req, HttpServletResponse res) throws IOException, XMLStreamException, NamingException, ConfigurationException {
    Adapter adapter = getAdapter(ibisManager, req.getPathInfo());
    Wsdl wsdl = new Wsdl(adapter.getPipeLine());
    wsdl.setUseIncludes(true);
    setDocumentation(wsdl, req);
    wsdl.init();
    res.setHeader("Content-Disposition", "inline;filename=\"" + wsdl.getFilename() + ".zip\"");
    String servlet = HttpUtils.getRequestURL(req).toString();
    servlet = servlet.substring(0, servlet.lastIndexOf(".")) + getWsdlExtention();
    wsdl.zip(res.getOutputStream(), servlet);
}
Also used : Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter)

Example 22 with Adapter

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

the class ShowConfigurationStatusTest method testAllConfigs.

@Test
public void testAllConfigs() throws ConfigurationException, PipeRunException, DomBuilderException, SAXException, IOException, TransformerException {
    ShowConfigurationStatus showConfigurationStatus = new ShowConfigurationStatus();
    PipeLine pipeLine = new PipeLine();
    Adapter adapter = (Adapter) ibisContext.getIbisManager().getRegisteredAdapter("WebControlShowConfigurationStatus");
    pipeLine.setAdapter(adapter);
    showConfigurationStatus.registerForward(createPipeSuccessForward());
    showConfigurationStatus.configure(pipeLine);
    session.put("configuration", "*ALL*");
    MockHttpServletRequest request = new MockHttpServletRequest();
    session.put(IPipeLineSession.HTTP_REQUEST_KEY, request);
    PipeRunResult pipeRunResult = showConfigurationStatus.doPipe(null, session);
    compareXML("webcontrol/allConfigs.xml", (String) pipeRunResult.getResult());
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Adapter(nl.nn.adapterframework.core.Adapter) PipeLine(nl.nn.adapterframework.core.PipeLine) Test(org.junit.Test)

Example 23 with Adapter

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

the class ShowConfigurationStatus method getAdapter.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{name}")
@Produces(MediaType.APPLICATION_JSON)
public Response getAdapter(@PathParam("name") String name, @QueryParam("expanded") String expanded, @QueryParam("showPendingMsgCount") boolean showPendingMsgCount) throws ApiException {
    initBase(servletConfig);
    Adapter adapter = (Adapter) ibisManager.getRegisteredAdapter(name);
    if (adapter == null) {
        throw new ApiException("Adapter not found!");
    }
    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!");
        }
    }
    Response.ResponseBuilder response = null;
    // Calculate the ETag on last modified date of user resource
    EntityTag etag = new EntityTag(adapterInfo.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(adapterInfo).tag(etag);
    return response.build();
}
Also used : Response(javax.ws.rs.core.Response) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) EntityTag(javax.ws.rs.core.EntityTag) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 24 with Adapter

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

the class ShowConfigurationStatus method updateReceiver.

@PUT
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{adapterName}/receivers/{receiverName}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateReceiver(@PathParam("adapterName") String adapterName, @PathParam("receiverName") String receiverName, LinkedHashMap<String, Object> json) throws ApiException {
    initBase(servletConfig);
    Adapter adapter = (Adapter) ibisManager.getRegisteredAdapter(adapterName);
    if (adapter == null) {
        throw new ApiException("Adapter 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")) {
            // Start or stop an adapter!
            String action = null;
            if (value.equals("stop")) {
                action = "stopreceiver";
            }
            if (value.equals("start")) {
                action = "startreceiver";
            }
            ibisManager.handleAdapter(action, "", adapterName, receiverName, null, false);
            response.entity("{\"status\":\"ok\"}");
        }
    }
    return response.build();
}
Also used : Response(javax.ws.rs.core.Response) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) 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 25 with Adapter

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

the class ShowConfigurationStatus method updateAdapter.

@PUT
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{adapterName}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateAdapter(@PathParam("adapterName") String adapterName, LinkedHashMap<String, Object> json) throws ApiException {
    initBase(servletConfig);
    Adapter adapter = (Adapter) ibisManager.getRegisteredAdapter(adapterName);
    if (adapter == null) {
        throw new ApiException("Adapter 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")) {
            // Start or stop an adapter!
            String action = null;
            if (value.equals("stop")) {
                action = "stopadapter";
            }
            if (value.equals("start")) {
                action = "startadapter";
            }
            ibisManager.handleAdapter(action, "", adapterName, null, null, false);
            response.entity("{\"status\":\"ok\"}");
        }
    }
    return response.build();
}
Also used : Response(javax.ws.rs.core.Response) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) 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)

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