Search in sources :

Example 96 with DELETE

use of javax.ws.rs.DELETE in project iaf by ibissource.

the class ShowScheduler method PutSchedules.

@DELETE
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/schedules/{groupName}/{jobName}")
@Relation("schedules")
@Produces(MediaType.APPLICATION_JSON)
public Response PutSchedules(@PathParam("jobName") String jobName, @QueryParam("groupName") String groupName) throws ApiException {
    initBase(servletConfig);
    DefaultIbisManager manager = (DefaultIbisManager) ibisManager;
    SchedulerHelper sh = manager.getSchedulerHelper();
    Scheduler scheduler;
    try {
        scheduler = sh.getScheduler();
    } catch (SchedulerException e) {
        throw new ApiException("Cannot find scheduler");
    }
    try {
        String commandIssuedBy = servletConfig.getInitParameter("remoteHost");
        commandIssuedBy += servletConfig.getInitParameter("remoteAddress");
        commandIssuedBy += servletConfig.getInitParameter("remoteUser");
        log.info("delete job jobName [" + jobName + "] groupName [" + groupName + "] " + commandIssuedBy);
        scheduler.deleteJob(jobName, groupName);
    } catch (Exception e) {
        throw new ApiException("Failed to delete job");
    }
    return Response.status(Response.Status.OK).build();
}
Also used : SchedulerHelper(nl.nn.adapterframework.scheduler.SchedulerHelper) SchedulerException(org.quartz.SchedulerException) Scheduler(org.quartz.Scheduler) DefaultIbisManager(nl.nn.adapterframework.unmanaged.DefaultIbisManager) SchedulerException(org.quartz.SchedulerException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces)

Example 97 with DELETE

use of javax.ws.rs.DELETE in project iaf by ibissource.

the class Init method getAllResources.

@GET
@PermitAll
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getAllResources(@QueryParam("allowedRoles") boolean displayAllowedRoles) {
    List<Object> JSONresources = new ArrayList<Object>();
    Map<String, Object> HALresources = new HashMap<String, Object>();
    Map<String, Object> resources = new HashMap<String, Object>(1);
    ResourceMethodRegistry registry = (ResourceMethodRegistry) dispatcher.getRegistry();
    StringBuffer requestPath = httpServletRequest.getRequestURL();
    if (requestPath.substring(requestPath.length() - 1).equals("/"))
        requestPath.setLength(requestPath.length() - 1);
    for (Map.Entry<String, List<ResourceInvoker>> entry : registry.getBounded().entrySet()) {
        for (ResourceInvoker invoker : entry.getValue()) {
            Method method = invoker.getMethod();
            String relation = null;
            if (method.getDeclaringClass() == getClass()) {
                continue;
            }
            if (method.getDeclaringClass().getName().endsWith("ShowMonitors") && !AppConstants.getInstance().getBoolean("monitoring.enabled", false)) {
                continue;
            }
            Map<String, Object> resource = new HashMap<String, Object>(4);
            if (method.isAnnotationPresent(GET.class))
                resource.put("type", "GET");
            else if (method.isAnnotationPresent(POST.class))
                resource.put("type", "POST");
            else if (method.isAnnotationPresent(PUT.class))
                resource.put("type", "PUT");
            else if (method.isAnnotationPresent(DELETE.class))
                resource.put("type", "DELETE");
            Path path = method.getAnnotation(Path.class);
            if (path != null) {
                String p = path.value();
                if (!p.startsWith("/"))
                    p = "/" + p;
                resource.put("href", requestPath + p);
            }
            RolesAllowed rolesAllowed = method.getAnnotation(RolesAllowed.class);
            if (rolesAllowed != null && displayAllowedRoles) {
                resource.put("allowed", rolesAllowed.value());
            }
            if ((HATEOASImplementation.equalsIgnoreCase("hal"))) {
                if (method.isAnnotationPresent(Relation.class))
                    relation = method.getAnnotation(Relation.class).value();
                if (relation != null) {
                    if (HALresources.containsKey(relation)) {
                        Object prevRelation = HALresources.get(relation);
                        List<Object> tmpList = null;
                        if (prevRelation instanceof List)
                            tmpList = (List) prevRelation;
                        else {
                            tmpList = new ArrayList<Object>();
                            tmpList.add(prevRelation);
                        }
                        tmpList.add(resource);
                        HALresources.put(relation, tmpList);
                    } else
                        HALresources.put(relation, resource);
                }
            } else {
                if (method.isAnnotationPresent(Relation.class))
                    resource.put("rel", method.getAnnotation(Relation.class).value());
                JSONresources.add(resource);
            }
        }
    }
    if ((HATEOASImplementation.equalsIgnoreCase("hal")))
        resources.put(ResourceKey, HALresources);
    else
        resources.put(ResourceKey, JSONresources);
    return Response.status(Response.Status.CREATED).entity(resources).build();
}
Also used : Path(javax.ws.rs.Path) HashMap(java.util.HashMap) POST(javax.ws.rs.POST) ArrayList(java.util.ArrayList) ResourceMethodRegistry(org.jboss.resteasy.core.ResourceMethodRegistry) Method(java.lang.reflect.Method) ResourceInvoker(org.jboss.resteasy.core.ResourceInvoker) DELETE(javax.ws.rs.DELETE) RolesAllowed(javax.annotation.security.RolesAllowed) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) PermitAll(javax.annotation.security.PermitAll)

Example 98 with DELETE

use of javax.ws.rs.DELETE in project habot by ghys.

the class HABotResource method unsetCardBookmark.

@DELETE
@Path("/cards/{cardUID}/bookmark")
@ApiOperation(value = "Removes the bookmark on a card.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "The card with the provided UID doesn't exist"), @ApiResponse(code = 500, message = "An error occured") })
public Response unsetCardBookmark(@PathParam("cardUID") @ApiParam(value = "cardUID", required = true) String cardUID) {
    Card card = this.cardRegistry.get(cardUID);
    if (card == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    card.setBookmark(false);
    this.cardRegistry.update(card);
    return Response.ok().build();
}
Also used : Card(org.openhab.ui.habot.card.Card) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 99 with DELETE

use of javax.ws.rs.DELETE in project ligoj-api by ligoj.

the class SubscriptionResource method delete.

/**
 * Delete entity and cascaded associations : parameters, events then subscription.
 *
 * @param id
 *            the entity identifier.
 * @param deleteRemoteData
 *            When <code>true</code>, remote data will be also destroyed.
 * @throws Exception
 *             When the delete fails. Managed at JAX-RS level.
 */
@Path("{id:\\d+}/{deleteRemoteData}")
@DELETE
public void delete(@PathParam("id") final int id, @PathParam("deleteRemoteData") final boolean deleteRemoteData) throws Exception {
    final Subscription entity = checkVisibleSubscription(id);
    checkManagedProject(entity.getProject().getId());
    // Delete the events
    eventRepository.deleteAllBy("subscription", entity);
    // Delegate the deletion
    deleteWithTasks(entity.getNode().getId(), id, deleteRemoteData);
    parameterValueResource.deleteBySubscription(id);
    repository.delete(entity);
}
Also used : Subscription(org.ligoj.app.model.Subscription) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 100 with DELETE

use of javax.ws.rs.DELETE in project 2TDSS-Digital by thiagoyama.

the class SelecaoResource method apagar.

@DELETE
@Path("{id}")
public void apagar(@PathParam("id") int codigo) {
    try {
        dao.remover(codigo);
        dao.commit();
    } catch (Exception e) {
        e.printStackTrace();
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) WebApplicationException(javax.ws.rs.WebApplicationException) CommitException(br.com.fiap.jpa.exception.CommitException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Aggregations

DELETE (javax.ws.rs.DELETE)587 Path (javax.ws.rs.Path)539 Produces (javax.ws.rs.Produces)194 ApiOperation (io.swagger.annotations.ApiOperation)153 ApiResponses (io.swagger.annotations.ApiResponses)127 Consumes (javax.ws.rs.Consumes)78 Timed (com.codahale.metrics.annotation.Timed)59 Response (javax.ws.rs.core.Response)54 IOException (java.io.IOException)47 WebApplicationException (javax.ws.rs.WebApplicationException)46 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)42 Identity (org.olat.core.id.Identity)36 AuditEvent (org.graylog2.audit.jersey.AuditEvent)32 NotFoundException (javax.ws.rs.NotFoundException)23 POST (javax.ws.rs.POST)21 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)20 ApiResponse (io.swagger.annotations.ApiResponse)20 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)20 HashMap (java.util.HashMap)19 GET (javax.ws.rs.GET)19