Search in sources :

Example 61 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project iaf by ibissource.

the class ShowMonitors method updateTrigger.

@PUT
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/{monitorName}/triggers/{trigger}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateTrigger(@PathParam("configuration") String configName, @PathParam("monitorName") String monitorName, @PathParam("trigger") int index, Map<String, Object> json) throws ApiException {
    MonitorManager mm = getMonitorManager(configName);
    Monitor monitor = mm.findMonitor(monitorName);
    if (monitor == null) {
        throw new ApiException("Monitor not found!", Status.NOT_FOUND);
    }
    ITrigger trigger = monitor.getTrigger(index);
    if (trigger == null) {
        throw new ApiException("Trigger not found!", Status.NOT_FOUND);
    }
    handleTrigger(trigger, json);
    return Response.status(Status.OK).build();
}
Also used : MonitorManager(nl.nn.adapterframework.monitoring.MonitorManager) Monitor(nl.nn.adapterframework.monitoring.Monitor) ITrigger(nl.nn.adapterframework.monitoring.ITrigger) 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 62 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project iaf by ibissource.

the class ShowMonitors method getTriggers.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/{monitorName}/triggers/{triggerId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getTriggers(@PathParam("configuration") String configName, @PathParam("monitorName") String monitorName, @PathParam("triggerId") Integer id) throws ApiException {
    MonitorManager mm = getMonitorManager(configName);
    Monitor monitor = mm.findMonitor(monitorName);
    if (monitor == null) {
        throw new ApiException("Monitor not found!", Status.NOT_FOUND);
    }
    Map<String, Object> returnMap = new HashMap<>();
    if (id != null) {
        ITrigger trigger = monitor.getTrigger(id);
        if (trigger == null) {
            throw new ApiException("Trigger not found!", Status.NOT_FOUND);
        } else {
            returnMap.put("trigger", mapTrigger(trigger));
        }
    }
    returnMap.put("severities", EnumUtils.getEnumList(SeverityEnum.class));
    returnMap.put("events", mm.getEvents());
    EntityTag etag = new EntityTag(returnMap.hashCode() + "");
    Response.ResponseBuilder response = null;
    // 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();
    }
    return Response.status(Status.OK).entity(returnMap).tag(etag).build();
}
Also used : Response(javax.ws.rs.core.Response) MonitorManager(nl.nn.adapterframework.monitoring.MonitorManager) Monitor(nl.nn.adapterframework.monitoring.Monitor) SeverityEnum(nl.nn.adapterframework.monitoring.SeverityEnum) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) EntityTag(javax.ws.rs.core.EntityTag) ITrigger(nl.nn.adapterframework.monitoring.ITrigger) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 63 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project iaf by ibissource.

the class ShowMonitors method getMonitors.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/")
public Response getMonitors(@PathParam("configuration") String configurationName, @QueryParam("xml") boolean showConfigXml) throws ApiException {
    Map<String, Object> returnMap = new HashMap<>();
    MonitorManager mm = getMonitorManager(configurationName);
    if (showConfigXml) {
        String xml = mm.toXml().toXML();
        return Response.status(Status.OK).type(MediaType.APPLICATION_XML).entity(xml).build();
    }
    List<Map<String, Object>> monitors = new ArrayList<Map<String, Object>>();
    for (int i = 0; i < mm.getMonitors().size(); i++) {
        Monitor monitor = mm.getMonitor(i);
        monitors.add(mapMonitor(monitor));
    }
    returnMap.put("monitors", monitors);
    returnMap.put("enabled", new Boolean(mm.isEnabled()));
    returnMap.put("eventTypes", EnumUtils.getEnumList(EventTypeEnum.class));
    returnMap.put("destinations", mm.getDestinations().keySet());
    return Response.status(Status.OK).type(MediaType.APPLICATION_JSON).entity(returnMap).build();
}
Also used : MonitorManager(nl.nn.adapterframework.monitoring.MonitorManager) Monitor(nl.nn.adapterframework.monitoring.Monitor) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) EventTypeEnum(nl.nn.adapterframework.monitoring.EventTypeEnum) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) GET(javax.ws.rs.GET)

Example 64 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project iaf by ibissource.

the class ShowMonitors method updateTrigger.

@POST
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/{monitorName}/triggers")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateTrigger(@PathParam("configuration") String configName, @PathParam("monitorName") String monitorName, Map<String, Object> json) {
    MonitorManager mm = getMonitorManager(configName);
    Monitor monitor = mm.findMonitor(monitorName);
    if (monitor == null) {
        throw new ApiException("Monitor not found!", Status.NOT_FOUND);
    }
    ITrigger trigger = SpringUtils.createBean(mm.getApplicationContext(), Trigger.class);
    handleTrigger(trigger, json);
    monitor.registerTrigger(trigger);
    monitor.configure();
    return Response.status(Status.OK).build();
}
Also used : MonitorManager(nl.nn.adapterframework.monitoring.MonitorManager) Monitor(nl.nn.adapterframework.monitoring.Monitor) ITrigger(nl.nn.adapterframework.monitoring.ITrigger) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 65 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project iaf by ibissource.

the class TestServiceListener method postServiceListeners.

@POST
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/test-servicelistener")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response postServiceListeners(MultipartBody inputDataMap) throws ApiException {
    Map<String, Object> result = new HashMap<String, Object>();
    String message = null, serviceName = null, dispatchResult = null;
    InputStream file = null;
    String fileEncoding = resolveTypeFromMap(inputDataMap, "encoding", String.class, Misc.DEFAULT_INPUT_STREAM_ENCODING);
    try {
        if (inputDataMap.getAttachment("service") != null) {
            serviceName = resolveStringFromMap(inputDataMap, "service");
        }
        if (inputDataMap.getAttachment("file") != null) {
            file = inputDataMap.getAttachment("file").getObject(InputStream.class);
            message = XmlUtils.readXml(IOUtils.toByteArray(file), fileEncoding, false);
        } else {
            message = resolveStringWithEncoding(inputDataMap, "message", fileEncoding);
        }
        if (message == null && file == null) {
            throw new ApiException("must provide either a message or file", 400);
        }
        if (!ServiceDispatcher.getInstance().isRegisteredServiceListener(serviceName)) {
            return Response.status(Response.Status.BAD_REQUEST).build();
        }
        try {
            @SuppressWarnings("rawtypes") Map context = new HashMap();
            dispatchResult = ServiceDispatcher.getInstance().dispatchRequest(serviceName, null, message, context);
        } catch (ListenerException e) {
            return Response.status(Response.Status.BAD_REQUEST).build();
        }
        result.put("state", ExitState.SUCCESS);
        result.put("result", dispatchResult);
    } catch (IOException e) {
        return Response.status(Response.Status.BAD_REQUEST).build();
    }
    return Response.status(Response.Status.CREATED).entity(result).build();
}
Also used : ListenerException(nl.nn.adapterframework.core.ListenerException) HashMap(java.util.HashMap) InputStream(java.io.InputStream) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes)

Aggregations

RolesAllowed (javax.annotation.security.RolesAllowed)191 Path (javax.ws.rs.Path)127 Produces (javax.ws.rs.Produces)110 Consumes (javax.ws.rs.Consumes)55 GET (javax.ws.rs.GET)54 POST (javax.ws.rs.POST)40 PUT (javax.ws.rs.PUT)35 HashMap (java.util.HashMap)34 ArrayList (java.util.ArrayList)32 IOException (java.io.IOException)30 ApiOperation (io.swagger.annotations.ApiOperation)29 ApiResponses (io.swagger.annotations.ApiResponses)29 Response (javax.ws.rs.core.Response)28 Adapter (nl.nn.adapterframework.core.Adapter)21 DELETE (javax.ws.rs.DELETE)19 WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)19 LinkedHashMap (java.util.LinkedHashMap)16 Locale (java.util.Locale)16 Map (java.util.Map)12 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)12