javax.ws.rs.DELETE Java Examples
The following examples show how to use
javax.ws.rs.DELETE.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SetsResource.java From cantor with BSD 3-Clause "New" or "Revised" License | 7 votes |
@DELETE @Path("/{namespace}/{set}/{entry}") @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Delete a specific entry by name") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Provides single property json with a boolean which is only true if the key was found and the entry was deleted", content = @Content(schema = @Schema(implementation = HttpModels.DeleteResponse.class))), @ApiResponse(responseCode = "500", description = serverErrorMessage) }) public Response delete(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace, @Parameter(description = "Name of the set") @PathParam("set") final String set, @Parameter(description = "Name of the entry") @PathParam("entry") final String entry) throws IOException { logger.info("received request to delete entry {} in set/namespace {}/{}", entry, set, namespace); final Map<String, Boolean> completed = new HashMap<>(); completed.put(jsonFieldResults, this.cantor.sets().delete(namespace, set, entry)); return Response.ok(parser.toJson(completed)).build(); }
Example #2
Source File: ObjectsResource.java From cantor with BSD 3-Clause "New" or "Revised" License | 6 votes |
@DELETE @Path("/{namespace}/{key}") @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Delete an object by its key") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Provides single property json with a boolean which is only true if the key was found and the object was deleted", content = @Content(schema = @Schema(implementation = HttpModels.DeleteResponse.class))), @ApiResponse(responseCode = "500", description = serverErrorMessage) }) public Response deleteByKey(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace, @Parameter(description = "Key of the object") @PathParam("key") final String key) throws IOException { logger.info("received request to delete object '{}' in namespace {}", key, namespace); final Map<String, Boolean> completed = new HashMap<>(); completed.put(jsonFieldResults, this.cantor.objects().delete(namespace, key)); return Response.ok(parser.toJson(completed)).build(); }
Example #3
Source File: EventsResource.java From cantor with BSD 3-Clause "New" or "Revised" License | 6 votes |
@DELETE @Path("/delete/{namespace}") @Operation(summary = "Delete events") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "All specified events were deleted", content = @Content(schema = @Schema(implementation = HttpModels.CountResponse.class))), @ApiResponse(responseCode = "500", description = serverErrorMessage) }) public Response dropEvents(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace, @BeanParam final EventsDataSourceBean bean) throws IOException { logger.info("received request to drop namespace {}", namespace); final int eventsDeleted = this.cantor.events().delete( namespace, bean.getStart(), bean.getEnd(), bean.getMetadataQuery(), bean.getDimensionQuery()); final Map<String, Integer> countResponse = new HashMap<>(); countResponse.put(jsonFieldCount, eventsDeleted); return Response.ok(parser.toJson(countResponse)).build(); }
Example #4
Source File: RestResourceTemplate.java From kogito-runtimes with Apache License 2.0 | 6 votes |
@DELETE() @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) public $Type$Output deleteResource_$name$(@PathParam("id") final String id) { return org.kie.kogito.services.uow.UnitOfWorkExecutor.executeInUnitOfWork(application.unitOfWorkManager(), () -> { ProcessInstance<$Type$> pi = process.instances() .findById(id) .orElse(null); if (pi == null) { return null; } else { pi.abort(); return getModel(pi); } }); }
Example #5
Source File: ReactiveRestResourceTemplate.java From kogito-runtimes with Apache License 2.0 | 6 votes |
@DELETE() @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) public CompletionStage<$Type$Output> deleteResource_$name$(@PathParam("id") final String id) { return CompletableFuture.supplyAsync(() -> { return org.kie.kogito.services.uow.UnitOfWorkExecutor.executeInUnitOfWork(application.unitOfWorkManager(), () -> { ProcessInstance<$Type$> pi = process.instances() .findById(id) .orElse(null); if (pi == null) { return null; } else { pi.abort(); return getModel(pi); } }); }); }
Example #6
Source File: SetsResource.java From cantor with BSD 3-Clause "New" or "Revised" License | 6 votes |
@DELETE @Path("/pop/{namespace}/{set}") @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Pop entries from a set") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Entries and weights of elements popped matching query parameters", content = @Content(schema = @Schema(implementation = Map.class))), @ApiResponse(responseCode = "400", description = "One of the query parameters has a bad value"), @ApiResponse(responseCode = "500", description = serverErrorMessage) }) public Response pop(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace, @Parameter(description = "Name of the set") @PathParam("set") final String set, @BeanParam final SetsDataSourceBean bean) throws IOException { logger.info("received request to pop off set/namespace {}/{}", set, namespace); logger.debug("request parameters: {}", bean); final Map<String, Long> entries = this.cantor.sets().pop( namespace, set, bean.getMin(), bean.getMax(), bean.getStart(), bean.getCount(), bean.isAscending()); return Response.ok(parser.toJson(entries)).build(); }
Example #7
Source File: ExperimentRestApi.java From submarine with Apache License 2.0 | 6 votes |
/** * Returns the experiment that deleted * @param id experiment id * @return the detailed info about deleted experiment */ @DELETE @Path("/{id}") @Operation(summary = "Delete the experiment", tags = {"experiment"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class))), @ApiResponse(responseCode = "404", description = "Experiment not found")}) public Response deleteExperiment(@PathParam(RestConstants.ID) String id) { try { Experiment experiment = experimentManager.deleteExperiment(id); return new JsonResponse.Builder<Experiment>(Response.Status.OK).success(true) .result(experiment).build(); } catch (SubmarineRuntimeException e) { return parseExperimentServiceException(e); } }
Example #8
Source File: SetsResource.java From cantor with BSD 3-Clause "New" or "Revised" License | 6 votes |
@DELETE @Path("/{namespace}/{set}") @Operation(summary = "Delete entries in a set between provided weights") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully deleted entries between and including provided weights"), @ApiResponse(responseCode = "400", description = "One of the query parameters has a bad value"), @ApiResponse(responseCode = "500", description = serverErrorMessage) }) public Response delete(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace, @Parameter(description = "Name of the set") @PathParam("set") final String set, @Parameter(description = "Minimum weight for an entry", example = "0") @QueryParam("min") final long min, @Parameter(description = "Maximum weight for an entry", example = "0") @QueryParam("max") final long max) throws IOException { logger.info("received request to delete entries in set/namespace {}/{} between weights {}-{}", set, namespace, min, max); this.cantor.sets().delete(namespace, set, min, max); return Response.ok().build(); }
Example #9
Source File: SysDeptRestApi.java From submarine with Apache License 2.0 | 6 votes |
@DELETE @Path("/deleteBatch") @SubmarineApi public Response deleteBatch(@QueryParam("ids") String ids) { LOG.info("deleteBatch({})", ids.toString()); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { SysDeptMapper sysDeptMapper = sqlSession.getMapper(SysDeptMapper.class); sysDeptMapper.deleteBatch(Arrays.asList(ids.split(","))); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); return new JsonResponse.Builder<>(Response.Status.OK) .message("Batch delete department failed!").success(false).build(); } return new JsonResponse.Builder<>(Response.Status.OK) .message("Batch delete department successfully!").success(true).build(); }
Example #10
Source File: SysDeptRestApi.java From submarine with Apache License 2.0 | 6 votes |
@DELETE @Path("/remove") @SubmarineApi public Response remove(String id) { LOG.info("remove({})", id); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { SysDeptMapper sysDeptMapper = sqlSession.getMapper(SysDeptMapper.class); sysDeptMapper.deleteById(id); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); return new JsonResponse.Builder<>(Response.Status.OK) .message("Delete department failed!").success(false).build(); } return new JsonResponse.Builder<>(Response.Status.OK) .message("Delete department successfully!").success(true).build(); }
Example #11
Source File: TeamRestApi.java From submarine with Apache License 2.0 | 6 votes |
@DELETE @Path("/delete") @SubmarineApi public Response delete(@QueryParam("id") String id) { // TODO(zhulinhao): At the front desk need to id LOG.info("delete team:{}", id); // Delete data in a team and team_member table // TODO(zhulinhao):delete sys_message's invite messages try { teamService.delete(id); } catch (Exception e) { LOG.error(e.getMessage(), e); return new JsonResponse.Builder<>(Response.Status.OK).success(false) .message("delete team failed!").build(); } return new JsonResponse.Builder<>(Response.Status.OK) .message("Delete team successfully!").success(true).build(); }
Example #12
Source File: ProjectRestApi.java From submarine with Apache License 2.0 | 6 votes |
@DELETE @Path("/delete") @SubmarineApi public Response delete(@QueryParam("id") String id) { // TODO(zhulinhao): At the front desk need to id LOG.info("delete project:{}", id); try { projectService.delete(id); } catch (Exception e) { LOG.error(e.getMessage(), e); return new JsonResponse.Builder<>(Response.Status.OK).success(false) .message("Delete project failed!").build(); } return new JsonResponse.Builder<>(Response.Status.OK) .message("Delete project successfully!").success(true).build(); }
Example #13
Source File: SysUserRestApi.java From submarine with Apache License 2.0 | 6 votes |
@DELETE @Path("/delete") @SubmarineApi public Response delete(@QueryParam("id") String id) { LOG.info("delete({})", id); try { userService.delete(id); } catch (Exception e) { LOG.error(e.getMessage(), e); return new JsonResponse.Builder<>(Response.Status.OK).success(false) .message("delete user failed!").build(); } return new JsonResponse.Builder<>(Response.Status.OK) .success(true).message("delete user successfully!").build(); }
Example #14
Source File: BucketEndpoint.java From hadoop-ozone with Apache License 2.0 | 6 votes |
/** * Rest endpoint to delete specific bucket. * <p> * See: https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketDELETE.html * for more details. */ @DELETE public Response delete(@PathParam("bucket") String bucketName) throws IOException, OS3Exception { try { deleteS3Bucket(bucketName); } catch (OMException ex) { if (ex.getResult() == ResultCodes.BUCKET_NOT_EMPTY) { throw S3ErrorTable.newError(S3ErrorTable .BUCKET_NOT_EMPTY, bucketName); } else if (ex.getResult() == ResultCodes.BUCKET_NOT_FOUND) { throw S3ErrorTable.newError(S3ErrorTable .NO_SUCH_BUCKET, bucketName); } else { throw ex; } } return Response .status(HttpStatus.SC_NO_CONTENT) .build(); }
Example #15
Source File: ProxyResource.java From presto with Apache License 2.0 | 6 votes |
@DELETE @Path("/v1/proxy") @Produces(APPLICATION_JSON) public void cancelQuery( @QueryParam("uri") String uri, @QueryParam("hmac") String hash, @Context HttpServletRequest servletRequest, @Suspended AsyncResponse asyncResponse) { if (!hmac.hashString(uri, UTF_8).equals(HashCode.fromString(hash))) { throw badRequest(FORBIDDEN, "Failed to validate HMAC of URI"); } Request.Builder request = prepareDelete().setUri(URI.create(uri)); performRequest(servletRequest, asyncResponse, request, response -> responseWithHeaders(noContent(), response)); }
Example #16
Source File: TestingHttpBackupResource.java From presto with Apache License 2.0 | 6 votes |
@DELETE @Path("{uuid}") public synchronized Response deleteRequest( @HeaderParam(PRESTO_ENVIRONMENT) String environment, @PathParam("uuid") UUID uuid) { checkEnvironment(environment); if (!shards.containsKey(uuid)) { return Response.status(NOT_FOUND).build(); } if (shards.get(uuid) == null) { return Response.status(GONE).build(); } shards.put(uuid, null); return Response.noContent().build(); }
Example #17
Source File: DeviceResource.java From hmdm-server with Apache License 2.0 | 6 votes |
@ApiOperation( value = "Delete device", notes = "Delete an existing device" ) @DELETE @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) public Response removeDevice(@PathParam("id") @ApiParam("Device ID") Integer id) { final boolean canEditDevices = SecurityContext.get().hasPermission("edit_devices"); if (!(canEditDevices)) { log.error("Unauthorized attempt to delete device", SecurityException.onCustomerDataAccessViolation(id, "device")); return Response.PERMISSION_DENIED(); } this.deviceDAO.removeDeviceById(id); return Response.OK(); }
Example #18
Source File: CustomerService.java From micro-integrator with Apache License 2.0 | 6 votes |
@DELETE @Path("/customers/{id}/") public Response deleteCustomer(@PathParam("id") String id) { System.out.println("----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; }
Example #19
Source File: QueryResource.java From presto with Apache License 2.0 | 6 votes |
@ResourceSecurity(AUTHENTICATED_USER) @DELETE @Path("{queryId}") public void cancelQuery(@PathParam("queryId") QueryId queryId, @Context HttpServletRequest servletRequest, @Context HttpHeaders httpHeaders) { requireNonNull(queryId, "queryId is null"); try { BasicQueryInfo queryInfo = dispatchManager.getQueryInfo(queryId); checkCanKillQueryOwnedBy(extractAuthorizedIdentity(servletRequest, httpHeaders, accessControl, groupProvider), queryInfo.getSession().getUser(), accessControl); dispatchManager.cancelQuery(queryId); } catch (AccessDeniedException e) { throw new ForbiddenException(); } catch (NoSuchElementException ignored) { } }
Example #20
Source File: UserResource.java From hmdm-server with Apache License 2.0 | 6 votes |
@ApiOperation( value = "Delete user", notes = "Deletes a user account referenced by the specified ID" ) @DELETE @Path("/other/{id}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response deleteUser(@PathParam("id") @ApiParam("User ID") int id) { try { userDAO.deleteUser(id); return Response.OK(); } catch (Exception e) { return Response.ERROR(e.getMessage()); } }
Example #21
Source File: TaskResource.java From presto with Apache License 2.0 | 6 votes |
@ResourceSecurity(INTERNAL_ONLY) @DELETE @Path("{taskId}") @Produces(MediaType.APPLICATION_JSON) public TaskInfo deleteTask( @PathParam("taskId") TaskId taskId, @QueryParam("abort") @DefaultValue("true") boolean abort, @Context UriInfo uriInfo) { requireNonNull(taskId, "taskId is null"); TaskInfo taskInfo; if (abort) { taskInfo = taskManager.abortTask(taskId); } else { taskInfo = taskManager.cancelTask(taskId); } if (shouldSummarize(uriInfo)) { taskInfo = taskInfo.summarize(); } return taskInfo; }
Example #22
Source File: LegumeApi.java From quarkus-in-prod with Apache License 2.0 | 5 votes |
@DELETE @Path("{id}") @Operation( operationId = "DeleteLegume", summary = "Delete a Legume" ) @APIResponse( responseCode = "204", description = "Empty response" ) @APIResponse( name = "notFound", responseCode = "404", description = "Legume not found" ) @APIResponse( name = "internalError", responseCode = "500", description = "Internal Server Error" ) Response delete( @Parameter(name = "id", description = "Id of the Legume to delete", required = true, example = "81471222-5798-11e9-ae24-57fa13b361e1", schema = @Schema(description = "uuid", required = true)) @PathParam("id") @NotEmpty final String legumeId);
Example #23
Source File: CafeResource.java From jakartaee-azure with MIT License | 5 votes |
@DELETE @Path("{id}") public void deleteCoffee(@PathParam("id") Long coffeeId) { try { this.cafeRepository.removeCoffeeById(coffeeId); } catch (IllegalArgumentException ex) { logger.log(Level.SEVERE, "Error calling deleteCoffee() for coffeeId {0}: {1}.", new Object[] { coffeeId, ex }); throw new WebApplicationException(Response.Status.NOT_FOUND); } }
Example #24
Source File: PersonServiceWithJDBC.java From microshed-testing with Apache License 2.0 | 5 votes |
@DELETE @Path("/{personId}") public void removePerson(@PathParam("personId") long id) { try (Connection conn = defaultDataSource.getConnection(); PreparedStatement ps = conn.prepareStatement("DELETE FROM people WHERE id = ?")){ ps.setLong(1,id); if (ps.executeUpdate() > 0) { return; }; throw new NotFoundException("Person with id " + id + " not found."); } catch (SQLException e) { e.printStackTrace(System.out); } throw new InternalServerErrorException("Could not delete person"); }
Example #25
Source File: CafeResource.java From jakartaee-azure with MIT License | 5 votes |
@DELETE @Path("{id}") public void deleteCoffee(@PathParam("id") Long coffeeId) { try { this.cafeRepository.removeCoffeeById(coffeeId); } catch (IllegalArgumentException ex) { logger.log(Level.SEVERE, "Error calling deleteCoffee() for coffeeId {0}: {1}.", new Object[] { coffeeId, ex }); throw new WebApplicationException(Response.Status.NOT_FOUND); } }
Example #26
Source File: CafeResource.java From jakartaee-azure with MIT License | 5 votes |
@DELETE @Path("{id}") public void deleteCoffee(@PathParam("id") Long coffeeId) { try { this.cafeRepository.removeCoffeeById(coffeeId); } catch (IllegalArgumentException ex) { logger.log(Level.SEVERE, "Error calling deleteCoffee() for coffeeId {0}: {1}.", new Object[] { coffeeId, ex }); throw new WebApplicationException(Response.Status.NOT_FOUND); } }
Example #27
Source File: ElasticsearchRestResource.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Path("/delete") @DELETE @Produces(MediaType.TEXT_PLAIN) public Response deleteData(@QueryParam("indexId") String indexId) throws Exception { producerTemplate.requestBody("elasticsearch-rest://elasticsearch?operation=Delete&indexName=test", indexId); return Response.noContent().build(); }
Example #28
Source File: CustomerResource.java From hmdm-server with Apache License 2.0 | 5 votes |
@DELETE @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) public Response removeCustomer(@PathParam("id") Integer id) { try { this.customerDAO.removeCustomerById(id); return Response.OK(); } catch (Exception e) { log.error("Unexpected error when deleting customer account #{}", id, e); return Response.INTERNAL_ERROR(); } }
Example #29
Source File: MongodbGridfsResource.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Path("/delete/{fileName}") @DELETE public Response deleteFile(@PathParam("fileName") String fileName) { producerTemplate.requestBodyAndHeader("mongodb-gridfs:camelMongoClient?database=test&operation=remove", null, Exchange.FILE_NAME, fileName); return Response.noContent().build(); }
Example #30
Source File: CafeResource.java From jakartaee-azure with MIT License | 5 votes |
@DELETE @Path("{id}") public void deleteCoffee(@PathParam("id") Long coffeeId) { try { this.cafeRepository.removeCoffeeById(coffeeId); } catch (IllegalArgumentException ex) { logger.log(Level.SEVERE, "Error calling deleteCoffee() for coffeeId {0}: {1}.", new Object[] { coffeeId, ex }); throw new WebApplicationException(Response.Status.NOT_FOUND); } }