use of javax.ws.rs.DELETE in project pulsar by yahoo.
the class Clusters method deleteNamespaceIsolationPolicy.
@DELETE
@Path("/{cluster}/namespaceIsolationPolicies/{policyName}")
@ApiOperation(value = "Delete namespace isolation policy")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission or plicy is read only"), @ApiResponse(code = 412, message = "Cluster doesn't exist") })
public void deleteNamespaceIsolationPolicy(@PathParam("cluster") String cluster, @PathParam("policyName") String policyName) throws Exception {
validateSuperUserAccess();
validateClusterExists(cluster);
validatePoliciesReadOnlyAccess();
try {
String nsIsolationPolicyPath = path("clusters", cluster, "namespaceIsolationPolicies");
NamespaceIsolationPolicies nsIsolationPolicies = namespaceIsolationPoliciesCache().get(nsIsolationPolicyPath).orElseGet(() -> {
try {
this.createNamespaceIsolationPolicyNode(nsIsolationPolicyPath);
return new NamespaceIsolationPolicies();
} catch (KeeperException | InterruptedException e) {
throw new RestException(e);
}
});
nsIsolationPolicies.deletePolicy(policyName);
globalZk().setData(nsIsolationPolicyPath, jsonMapper().writeValueAsBytes(nsIsolationPolicies.getPolicies()), -1);
// make sure that the cache content will be refreshed for the next read access
namespaceIsolationPoliciesCache().invalidate(nsIsolationPolicyPath);
} catch (KeeperException.NoNodeException nne) {
log.warn("[{}] Failed to update brokers/{}/namespaceIsolationPolicies: Does not exist", clientAppId(), cluster);
throw new RestException(Status.NOT_FOUND, "NamespaceIsolationPolicies for cluster " + cluster + " does not exist");
} catch (Exception e) {
log.error("[{}] Failed to update brokers/{}/namespaceIsolationPolicies/{}", clientAppId(), cluster, policyName, e);
throw new RestException(e);
}
}
use of javax.ws.rs.DELETE in project pulsar by yahoo.
the class Namespaces method removeBacklogQuota.
@DELETE
@Path("/{property}/{cluster}/{namespace}/backlogQuota")
@ApiOperation(value = "Remove a backlog quota policy from a namespace.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"), @ApiResponse(code = 404, message = "Namespace does not exist"), @ApiResponse(code = 409, message = "Concurrent modification") })
public void removeBacklogQuota(@PathParam("property") String property, @PathParam("cluster") String cluster, @PathParam("namespace") String namespace, @QueryParam("backlogQuotaType") BacklogQuotaType backlogQuotaType) {
validateAdminAccessOnProperty(property);
validatePoliciesReadOnlyAccess();
if (backlogQuotaType == null) {
backlogQuotaType = BacklogQuotaType.destination_storage;
}
try {
Stat nodeStat = new Stat();
final String path = path("policies", property, cluster, namespace);
byte[] content = globalZk().getData(path, null, nodeStat);
Policies policies = jsonMapper().readValue(content, Policies.class);
policies.backlog_quota_map.remove(backlogQuotaType);
globalZk().setData(path, jsonMapper().writeValueAsBytes(policies), nodeStat.getVersion());
policiesCache().invalidate(path("policies", property, cluster, namespace));
log.info("[{}] Successfully removed backlog namespace={}/{}/{}, quota={}", clientAppId(), property, cluster, namespace, backlogQuotaType);
} catch (KeeperException.NoNodeException e) {
log.warn("[{}] Failed to update backlog quota map for namespace {}/{}/{}: does not exist", clientAppId(), property, cluster, namespace);
throw new RestException(Status.NOT_FOUND, "Namespace does not exist");
} catch (KeeperException.BadVersionException e) {
log.warn("[{}] Failed to update backlog quota map for namespace {}/{}/{}: concurrent modification", clientAppId(), property, cluster, namespace);
throw new RestException(Status.CONFLICT, "Concurrent modification");
} catch (Exception e) {
log.error("[{}] Failed to update backlog quota map for namespace {}/{}/{}", clientAppId(), property, cluster, namespace, e);
throw new RestException(e);
}
}
use of javax.ws.rs.DELETE in project OpenClinica by OpenClinica.
the class OpenRosaServices method doFieldDeletion.
@DELETE
@Path("/{studyOID}/fieldsubmission")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_XML)
public Response doFieldDeletion(@Context HttpServletRequest request, @Context HttpServletResponse response, @Context ServletContext servletContext, @PathParam("studyOID") String studyOID, @QueryParam(FORM_CONTEXT) String context) {
ResponseBuilder builder = Response.noContent();
ResponseEntity<String> responseEntity = openRosaSubmissionController.doFieldDeletion(request, response, studyOID, context);
if (responseEntity == null) {
LOGGER.debug("Null response from OpenRosaSubmissionController.");
return builder.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} else if (responseEntity.getStatusCode().equals(org.springframework.http.HttpStatus.CREATED)) {
LOGGER.debug("Successful OpenRosa submission");
builder.entity("<OpenRosaResponse xmlns=\"http://openrosa.org/http/response\">" + "<message>success</message>" + "</OpenRosaResponse>");
return builder.status(Response.Status.CREATED).build();
} else if (responseEntity.getStatusCode().equals(org.springframework.http.HttpStatus.NOT_ACCEPTABLE)) {
LOGGER.debug("Failed OpenRosa submission");
return builder.status(Response.Status.NOT_ACCEPTABLE).build();
} else {
LOGGER.debug("Failed OpenRosa submission with unhandled error");
return builder.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of javax.ws.rs.DELETE in project opennms by OpenNMS.
the class BusinessServiceRestService method removeEdge.
@DELETE
@Path("{id}/edges/{edgeId}")
public Response removeEdge(@PathParam("id") final Long serviceId, @PathParam("edgeId") final Long edgeId) {
final BusinessService service = getManager().getBusinessServiceById(serviceId);
final Edge edge = getManager().getEdgeById(edgeId);
boolean changed = getManager().deleteEdge(service, edge);
if (!changed) {
return Response.notModified().build();
}
service.save();
return Response.ok().build();
}
use of javax.ws.rs.DELETE in project opennms by OpenNMS.
the class BusinessServiceRestService method delete.
@DELETE
@Path("{id}")
public Response delete(@PathParam("id") Long id) {
final BusinessService service = getManager().getBusinessServiceById(id);
getManager().deleteBusinessService(service);
return Response.ok().build();
}
Aggregations