Search in sources :

Example 91 with DELETE

use of javax.ws.rs.DELETE in project fabric8 by jboss-fuse.

the class CustomerService method deleteCustomer.

@DELETE
@Path("/customers/{id}/")
public Response deleteCustomer(@PathParam("id") String id) {
    long idNumber = Long.parseLong(id);
    Customer c = customers.get(idNumber);
    Response r;
    if (c != null) {
        r = Response.ok().build();
        customers.remove(idNumber);
    } else {
        r = Response.notModified().build();
    }
    if (idNumber == currentId.get()) {
        currentId.decrementAndGet();
    }
    return r;
}
Also used : Response(javax.ws.rs.core.Response) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 92 with DELETE

use of javax.ws.rs.DELETE in project smarthome by eclipse.

the class ConfigurableServiceResource method deleteConfiguration.

@DELETE
@Path("/{serviceId}/config")
@Produces({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "Deletes a service configuration for given service ID and returns the old configuration.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = String.class), @ApiResponse(code = 204, message = "No old configuration"), @ApiResponse(code = 500, message = "Configuration can not be deleted due to internal error") })
public Response deleteConfiguration(@PathParam("serviceId") @ApiParam(value = "service ID", required = true) String serviceId) {
    try {
        Configuration oldConfiguration = configurationService.get(serviceId);
        configurationService.delete(serviceId);
        return oldConfiguration != null ? Response.ok(oldConfiguration).build() : Response.noContent().build();
    } catch (IOException ex) {
        logger.error("Cannot delete configuration for service {}: {}", serviceId, ex.getMessage(), ex);
        return Response.status(Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration) IOException(java.io.IOException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 93 with DELETE

use of javax.ws.rs.DELETE in project Singularity by HubSpot.

the class PriorityResource method deleteActivePriorityFreeze.

@DELETE
@Path("/freeze")
@ApiOperation("Stops the active priority freeze.")
@ApiResponses({ @ApiResponse(code = 202, message = "The active priority freeze was deleted."), @ApiResponse(code = 400, message = "There was no active priority freeze to delete.") })
public void deleteActivePriorityFreeze(@Auth SingularityUser user) {
    authorizationHelper.checkAdminAuthorization(user);
    final SingularityDeleteResult deleteResult = priorityManager.deleteActivePriorityFreeze();
    checkBadRequest(deleteResult == SingularityDeleteResult.DELETED, "No active priority freeze to delete.");
    priorityManager.clearPriorityKill();
}
Also used : SingularityDeleteResult(com.hubspot.singularity.SingularityDeleteResult) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Example 94 with DELETE

use of javax.ws.rs.DELETE in project knox by apache.

the class TopologiesResource method deleteProviderConfiguration.

@DELETE
@Produces(APPLICATION_JSON)
@Path(SINGLE_PROVIDERCONFIG_API_PATH)
public Response deleteProviderConfiguration(@PathParam("name") String name) {
    Response response;
    GatewayServices services = (GatewayServices) request.getServletContext().getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
    TopologyService ts = services.getService(GatewayServices.TOPOLOGY_SERVICE);
    if (ts.deleteProviderConfiguration(name)) {
        response = ok().entity("{ \"deleted\" : \"provider config " + name + "\" }").build();
    } else {
        response = notModified().build();
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) GatewayServices(org.apache.knox.gateway.services.GatewayServices) TopologyService(org.apache.knox.gateway.services.topology.TopologyService) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Example 95 with DELETE

use of javax.ws.rs.DELETE in project fabric8 by jboss-fuse.

the class CustomerService method deleteCustomer.

/**
 * This method is mapped to an HTTP DELETE of 'http://localhost:8181/cxf/crm/customerservice/customers/{id}'.  The value for
 * {id} will be passed to this message as a parameter, using the @PathParam annotation.
 * <p/>
 * The method uses the Response class to create the HTTP response: either HTTP Status 200/OK if the customer object was
 * successfully removed from the local data map or a HTTP Status 304/Not Modified if it failed to remove the object.
 */
@com.wordnik.swagger.annotations.ApiOperation(value = "deleteCustomer", notes = "/** \n * This method is mapped to an HTTP DELETE of 'http://localhost:8181/cxf/crm/customerservice/customers/{id}'.  The value for {id} will be passed to this message as a parameter, using the @PathParam annotation. <p/> The method uses the Response class to create the HTTP response: either HTTP Status 200/OK if the customer object was successfully removed from the local data map or a HTTP Status 304/Not Modified if it failed to remove the object.\n */\n")
@DELETE
@Path("/customers/{id}/")
public Response deleteCustomer(@com.wordnik.swagger.annotations.ApiParam(value = "id") @PathParam("id") String id) {
    LOG.info("Invoking deleteCustomer, Customer id is: {}", id);
    long idNumber = Long.parseLong(id);
    Customer c = customers.get(idNumber);
    Response r;
    if (c != null) {
        r = Response.ok().build();
        customers.remove(idNumber);
    } else {
        r = Response.notModified().build();
    }
    return r;
}
Also used : Response(javax.ws.rs.core.Response) 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