Java 类javax.ws.rs.DELETE 实例源码
项目:Equella
文件:EquellaItemResource.java
@DELETE
@Path("/{uuid}/{version}/comment")
@ApiOperation(value = "Delete a comment")
Response deleteComment(
@Context
UriInfo info,
@ApiParam(APIDOC_ITEMUUID)
@PathParam("uuid")
String uuid,
@ApiParam(APIDOC_ITEMVERSION)
@PathParam("version")
int version,
@ApiParam(APIDOC_ITEMVERSION)
@QueryParam("commentuuid")
String commentUuid
);
项目:microservices-transactions-tcc
文件:CompositeTransactionParticipantController.java
@DELETE
@Path("/tcc/{txid}")
@Consumes("application/tcc")
@ApiOperation(
code = 204,
response = String.class,
value = "Rollback a given composite transaction",
notes = "See https://www.atomikos.com/Blog/TransactionManagementAPIForRESTTCC",
consumes = "application/tcc"
)
public void cancel(
@ApiParam(value = "Id of the composite transaction to rollback", required = true) @PathParam("txid") String txid
){
LOG.info("Trying to rollback transaction [{}]", txid);
getCompositeTransactionParticipantService().cancel(txid);
LOG.info("Transaction [{}] rolled back", txid);
}
项目:hadoop
文件:NamenodeWebHdfsMethods.java
/** Handle HTTP DELETE request for the root. */
@DELETE
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteRoot(
@Context final UserGroupInformation ugi,
@QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
final DelegationParam delegation,
@QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
final UserParam username,
@QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
final DoAsParam doAsUser,
@QueryParam(DeleteOpParam.NAME) @DefaultValue(DeleteOpParam.DEFAULT)
final DeleteOpParam op,
@QueryParam(RecursiveParam.NAME) @DefaultValue(RecursiveParam.DEFAULT)
final RecursiveParam recursive,
@QueryParam(SnapshotNameParam.NAME) @DefaultValue(SnapshotNameParam.DEFAULT)
final SnapshotNameParam snapshotName
) throws IOException, InterruptedException {
return delete(ugi, delegation, username, doAsUser, ROOT, op, recursive,
snapshotName);
}
项目:comms-router
文件:RouterResource.java
@DELETE
@Path("{ref}")
@ApiOperation(value = "Deletes an existing router by ID", tags = "routers")
@ApiResponses({
@ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400, message = "Invalid ID supplied",
response = ExceptionPresentation.class),
@ApiResponse(code = 404, message = "Router not found",
response = ExceptionPresentation.class)})
public void delete(@ApiParam(value = "The id of the router to be deleted",
required = true) @PathParam("ref") String ref) throws CommsRouterException {
LOGGER.debug("Deleting router: {}", ref);
routerService.delete(ref);
}
项目:osc-core
文件:ManagerConnectorApis.java
@ApiOperation(value = "Deletes an Manager Connector",
notes = "Deletes an Appliance Manager Connector if not referenced by any Distributed Appliances",
response = BaseJobResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400,
message = "In case of any error or if the Manager connector is referenced by a Distributed Appliance",
response = ErrorCodeDto.class) })
@Path("/{applianceManagerConnectorId}")
@DELETE
public Response deleteApplianceManagerConnector(@Context HttpHeaders headers,
@ApiParam(value = "Id of the Appliance Manager Connector",
required = true) @PathParam("applianceManagerConnectorId") Long amcId) {
logger.info("Deleting Appliance Manager Connector " + amcId);
this.userContext.setUser(OscAuthFilter.getUsername(headers));
return this.apiUtil.getResponseForBaseRequest(this.deleteApplianceManagerConnectorService,
new BaseIdRequest(amcId));
}
项目:MaximoForgeViewerPlugin
文件:ForgeRS.java
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("bucket/{bucketKey}")
public Response bucketDelete(
@Context HttpServletRequest request,
@PathParam("bucketKey") String bucketKey
)
throws IOException,
URISyntaxException
{
APIImpl impl = getAPIImpl( request );
if( impl == null )
{
return Response.status( Response.Status.UNAUTHORIZED ).build();
}
Result result = impl.bucketDelete( bucketKey );
return formatReturn( result );
}
项目:MaximoForgeViewerPlugin
文件:ForgeRS.java
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("model/{bucketKey}/{objectKey}")
public Response modelDelete(
@Context HttpServletRequest request,
@PathParam("bucketKey") String bucketKey,
@PathParam("objectKey") String objectKey
)
throws IOException,
URISyntaxException,
GeneralSecurityException
{
APIImpl impl = getAPIImpl( request );
if( impl == null )
{
return Response.status( Response.Status.UNAUTHORIZED ).build();
}
Result result = impl.objectDelete( bucketKey, objectKey );
return formatReturn( result );
}
项目:security-mgr-sample-plugin
文件:DomainApis.java
/**
* Deletes the Domain for a given domain Id
*
* @return - deleted Domain
*/
@Path("/{domainId}")
@DELETE
public void deleteDomain(@PathParam("domainId") Long domainId) {
LOG.info("Deleting Domain Entity ID...:" + domainId);
this.txControl.required(new Callable<Void>() {
@Override
public Void call() throws Exception {
DomainEntity result = DomainApis.this.em.find(DomainEntity.class, domainId);
if (result == null) {
return null;
}
DomainApis.this.em.remove(result);
return null;
}
});
}
项目:athena
文件:RegionsWebResource.java
/**
* Removes the specified collection of devices from the region.
*
* @param regionId region identifier
* @param stream deviceIds JSON stream
* @return 204 NO CONTENT
* @onos.rsModel RegionDeviceIds
*/
@DELETE
@Path("{regionId}/devices")
@Consumes(MediaType.APPLICATION_JSON)
public Response removeDevices(@PathParam("regionId") String regionId,
InputStream stream) {
final RegionId rid = RegionId.regionId(regionId);
try {
regionAdminService.removeDevices(rid, extractDeviceIds(stream));
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
return Response.noContent().build();
}
项目:athena
文件:VirtualPortWebResource.java
@DELETE
@Path("{portUUID}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deletePorts(@PathParam("portUUID") String id) {
Set<VirtualPortId> vPortIds = new HashSet<>();
try {
if (id != null) {
vPortIds.add(VirtualPortId.portId(id));
}
Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
.removePorts(vPortIds), VPORT_NOT_FOUND);
if (!issuccess) {
return Response.status(INTERNAL_SERVER_ERROR)
.entity(VPORT_ID_NOT_EXIST).build();
}
return ok(issuccess.toString()).build();
} catch (Exception e) {
log.error("Deletes VirtualPort failed because of exception {}",
e.toString());
return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
.build();
}
}
项目:fuck_zookeeper
文件:ZNodeResource.java
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
@DefaultValue("-1") @QueryParam("version") String versionParam,
@Context UriInfo ui) throws InterruptedException, KeeperException {
ensurePathNotNull(path);
int version;
try {
version = Integer.parseInt(versionParam);
} catch (NumberFormatException e) {
throw new WebApplicationException(Response.status(
Response.Status.BAD_REQUEST).entity(
new ZError(ui.getRequestUri().toString(), path
+ " bad version " + versionParam)).build());
}
zk.delete(path, version);
}
项目:hadoop
文件:KMS.java
@DELETE
@Path(KMSRESTConstants.KEY_RESOURCE + "/{name:.*}")
public Response deleteKey(@PathParam("name") final String name)
throws Exception {
KMSWebApp.getAdminCallsMeter().mark();
UserGroupInformation user = HttpUserGroupInformation.get();
assertAccess(KMSACLs.Type.DELETE, user, KMSOp.DELETE_KEY, name);
KMSClientProvider.checkNotEmpty(name, "name");
user.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
provider.deleteKey(name);
provider.flush();
return null;
}
});
kmsAudit.ok(user, KMSOp.DELETE_KEY, name, "");
return Response.ok().build();
}
项目:athena
文件:VirtualNetworkWebResource.java
/**
* Removes the virtual network link from the JSON input stream.
*
* @param networkId network identifier
* @param stream virtual link JSON stream
* @return 204 NO CONTENT
* @onos.rsModel VirtualLink
*/
@DELETE
@Path("{networkId}/links")
@Consumes(MediaType.APPLICATION_JSON)
public Response removeVirtualLink(@PathParam("networkId") long networkId,
InputStream stream) {
try {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
JsonNode specifiedNetworkId = jsonTree.get("networkId");
if (specifiedNetworkId != null &&
specifiedNetworkId.asLong() != (networkId)) {
throw new IllegalArgumentException(INVALID_FIELD + "networkId");
}
final VirtualLink vlinkReq = codec(VirtualLink.class).decode(jsonTree, this);
vnetAdminService.removeVirtualLink(vlinkReq.networkId(),
vlinkReq.src(), vlinkReq.dst());
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
return Response.noContent().build();
}
项目:ditb
文件:ScannerInstanceResource.java
@DELETE
public Response delete(final @Context UriInfo uriInfo) {
if (LOG.isDebugEnabled()) {
LOG.debug("DELETE " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
if (servlet.isReadOnly()) {
return Response.status(Response.Status.FORBIDDEN)
.type(MIMETYPE_TEXT).entity("Forbidden" + CRLF)
.build();
}
if (ScannerResource.delete(id)) {
servlet.getMetrics().incrementSucessfulDeleteRequests(1);
} else {
servlet.getMetrics().incrementFailedDeleteRequests(1);
}
return Response.ok().build();
}
项目:app-ms
文件:SampleResource.java
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/delete")
public Response delete(final String hello) {
return null;
}
项目:opencps-v2
文件:NotificationTemplateManagement.java
@DELETE
@Path("/{type}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response delete(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
@Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
@DefaultValue("0") @PathParam("type") String type);
项目:Equella
文件:ItemRelationResourceImpl.java
@DELETE
@Path(PATH_RELATION_ID)
@ApiOperation(value = "Delete a relation for an item")
public Response delete(@PathParam("uuid") String uuid, @PathParam("version") int version,
@PathParam("relationId") long relationId)
{
ItemId itemId = new ItemId(uuid, version);
relationService.delete(itemId, relationId);
return Response.ok().build();
}
项目:osc-core
文件:DistributedApplianceApis.java
@ApiOperation(value = "Force Delete a Distributed Appliance",
notes = "This will not trigger a Job and will not attempt to clean up any artifacts.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/{distributedApplianceId}/force")
@DELETE
public Response forceDeleteDistributedAppliance(@Context HttpHeaders headers,
@ApiParam(value = "The Id of the Distributed Appliance",
required = true) @PathParam("distributedApplianceId") Long distributedApplianceId) {
logger.info("Deleting Distributed Appliance " + distributedApplianceId);
this.userContext.setUser(OscAuthFilter.getUsername(headers));
return this.apiUtil.getResponseForBaseRequest(this.deleteDistributedApplianceService,
new BaseDeleteRequest(distributedApplianceId, true));
}
项目:plugin-prov
文件:ImportCatalogResource.java
@Override
@DELETE
@Path("catalog/{node:service:prov:.+}")
@OnNullReturn404
public ImportCatalogStatus cancel(@PathParam("node") final String node) {
return LongTaskRunnerNode.super.cancel(nodeResource.checkWritableNode(node).getTool().getId());
}
项目:incubator-servicecomb-java-chassis
文件:ComputeImpl.java
@Path("/addstring")
@DELETE
@Produces(MediaType.TEXT_PLAIN)
public String addString(@QueryParam("s") String[] s) {
String result = "";
for (String x : s) {
result += x;
}
return result;
}
项目:opencps-v2
文件:ServiceInfoManagement.java
@DELETE
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Delete ServiceInfo by Id)")
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the detail of ServiceInfo"),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response deleteServiceInfo(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext,
@ApiParam(value = "id (or code) of ServiceInfo that need to be delete", required = true) @PathParam("id") String id);
项目:bootstrap
文件:ExceptionMapperResource.java
/**
* JPA validation exception with parameters.
*/
@DELETE
@Path("jsr-303-jpa")
public void throwJsr303FromJpa() {
final SystemRole entity = new SystemRole();
// Name over 200 char --> BVAL exception
entity.setName(org.apache.commons.lang3.StringUtils.repeat("-", 210));
repository.save(entity);
}
项目:demo-ang2
文件:PersonEndpoint.java
@DELETE
@Path("/{id:[0-9][0-9]*}")
public Response deleteById(@PathParam("id") Long id) {
Person entity = em.find(Person.class, id);
if (entity == null) {
return Response.status(Status.NOT_FOUND).build();
}
em.remove(entity);
return Response.noContent().build();
}
项目:opencps-v2
文件:DataManagement.java
@DELETE
@Path("/{code}/dictgroups/{groupCode}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response deleteDictgroups(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
@PathParam("groupCode") String groupCode);
项目:ThermalComfortBack
文件:SensorService.java
@DELETE
@Path("/{id}")
public Response delete(@PathParam("id") String id) {
try {
sensorLogic.delete(id);
return Response.status(200).header("Access-Control-Allow-Origin", "*").entity("Sucessful: Sensor was deleted").build();
} catch (Exception e) {
Logger.getLogger(SensorService.class.getName()).log(Level.WARNING, e.getMessage());
return Response.status(500).header("Access-Control-Allow-Origin", "*").entity("We found errors in your query, please contact the Web Admin.").build();
}
}
项目:dust-api
文件:UserResource.java
@DELETE
@Path("/{userId}/watches/{deviceId}")
public void unwatch(
@PathParam("userId") final long userId,
@PathParam("deviceId") final long deviceId
) {
userRepo.removeWatch(deviceId, userId);
}
项目:Equella
文件:FileResource.java
@DELETE
@Path("/{uuid}/content/{filepath:(.*)}")
@ApiOperation(value = "Delete a file")
public Response deleteFile(// @formatter:off
@PathParam("uuid") String stagingUuid,
@PathParam("filepath") String filepath
// @formatter:on
) throws IOException;
项目:holon-examples
文件:ProductEndpoint.java
@ApiOperation("Delete a product")
@ApiResponses({ @ApiResponse(code = 204, message = "Product deleted") })
@DELETE
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON)
public Response deleteProduct(@ApiParam("The product id to delete") @PathParam("id") Long id) {
getProductStore().remove(id);
return Response.noContent().build();
}
项目:athena
文件:AclWebResource.java
/**
* Remove ACL rule.
*
* @param id ACL rule id (in hex string format)
* @return 204 NO CONTENT
*/
@DELETE
@Path("{id}")
public Response removeAclRule(@PathParam("id") String id) {
RuleId ruleId = new RuleId(Long.parseLong(id.substring(2), 16));
get(AclService.class).removeAclRule(ruleId);
return Response.noContent().build();
}
项目:InComb
文件:FlyWithService.java
/**
* Deletes a FlyWith from a given user
* @param userId of the user to remove the flywith from
* @param flyWithId to remove
* @param con Connection to use - is injected automatically
* @return
*/
@DELETE
public Response deleteFlyWith(@PathParam ("userId") final long userId, @PathParam ("flyWithId") final long flyWithId, @Context final Connection con ) {
getAccessChecker().checkLoggedInUser(userId);
final FlyWithDao dao = new FlyWithDao(con);
dao.deleteFlyWith(userId, flyWithId);
return ok(null);
}
项目:opencps-v2
文件:DeliverableTypesManagement.java
@DELETE
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Remove a Deliverabletypes by its id", response = DeliverableTypesModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a Dossier was removed", response = DeliverableTypesModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response removeDeliverabletypes(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") String id);
项目:opencps-v2
文件:DossierManagement.java
@DELETE
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Remove a Dossier by its id", response = DossierDetailModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a Dossier was removed", response = DossierDetailModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response removeDossier(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") String id);
项目:opencps-v2
文件:DossierTemplateManagement.java
@DELETE
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get a DossierTemplate", response = DossierTemplateInputModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns detail of DossierTemplate", response = DossierTemplateInputModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })
public Response removeDossierTemplate(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") long id);
项目:plugin-bt
文件:BugTrackerResource.java
/**
* Update the business hours : only one range.
*
* @param id
* The business hours identifier.
*/
@DELETE
@Path("business-hours/{id:\\d+}")
public void deleteBusinessHours(@PathParam("id") final int id) {
final BusinessHours businessHours = findConfigured(businessHoursRepository, id);
// Check there is at least one business range
if (businessHours.getConfiguration().getBusinessHours().size() == 1) {
throw new BusinessException("service:bt:no-business-hours");
}
businessHoursRepository.delete(businessHours);
}
项目:trellis
文件:MultipartUploader.java
/**
* Abort an upload process.
*
* @param id the upload identifier
*/
@DELETE
@Timed
public void abortUpload(@PathParam("id") final String id) {
if (!binaryService.uploadSessionExists(id)) {
throw new NotFoundException();
}
binaryService.abortUpload(id);
}
项目:opencps-v2
文件:RegistrationTemplatesManagement.java
@DELETE
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Remove a registrationTemplate by its id", response = RegistrationTemplatesModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a Dossier was removed", response = RegistrationTemplatesModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response removeRegistrationTemplate(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") long id);
项目:flightmanager
文件:TemplateResource.java
@DELETE
@Path("{id}")
public void deleteFlightTemplate(@PathParam("id") long id) {
FlightTemplateInterface temp = DAOFactory.INSTANCE.getFlightTemplateDAO().findId(id);
temp.setIsActive(false);
DAOFactory.INSTANCE.getFlightTemplateDAO().update(temp);
}
项目:https-github.com-apache-zookeeper
文件:SessionsResource.java
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteSession(@PathParam("session") String session,
@Context UriInfo ui) {
ZooKeeperService.close(contextPath, session);
}
项目:nifi-registry
文件:AccessPolicyResource.java
/**
* Remove a specified access policy.
*
* @param httpServletRequest request
* @param identifier The id of the access policy to remove.
* @return The deleted access policy
*/
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
@ApiOperation(
value = "Deletes an access policy",
response = AccessPolicy.class
)
@ApiResponses({
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409 + " The NiFi Registry might not be configured to use a ConfigurableAccessPolicyProvider.") })
public Response removeAccessPolicy(
@Context final HttpServletRequest httpServletRequest,
@ApiParam(value = "The access policy id.", required = true)
@PathParam("id")
final String identifier) {
verifyAuthorizerSupportsConfigurablePolicies();
authorizeAccess(RequestAction.DELETE);
AccessPolicy deletedPolicy = authorizationService.deleteAccessPolicy(identifier);
if (deletedPolicy == null) {
throw new ResourceNotFoundException("No access policy found with ID + " + identifier);
}
return generateOkResponse(deletedPolicy).build();
}
项目:javaee8-jaxrs-sample
文件:CommentsResource.java
@Path("{commentId}")
@DELETE
public Response deleteComment(@PathParam("commentId") Long commentId) {
return comments.findOptionalById(commentId)
.map(c -> comments.delete(c))
.map(c -> Response.noContent().build())
.orElseThrow(() -> new CommentNotFoundException(commentId));
}