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);
}
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());
}
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();
}
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();
}
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();
}
Aggregations