use of javax.ws.rs.DELETE in project ddf by codice.
the class MetacardEditEndpoint method deleteAttribute.
@DELETE
@Path("/{id}/{attribute}")
public Response deleteAttribute(@Context HttpServletResponse response, @PathParam("id") String id, @PathParam("attribute") String attribute, String value) throws Exception {
Metacard metacard = endpointUtil.getMetacard(id);
Attribute metacardAttribute = metacard.getAttribute(attribute);
if (metacardAttribute == null) {
return Response.ok().build();
}
metacard.setAttribute(new AttributeImpl(attribute, (Serializable) null));
catalogFramework.update(new UpdateRequestImpl(id, metacard));
return Response.ok().build();
}
use of javax.ws.rs.DELETE in project oxTrust by GluuFederation.
the class UserWebService method deleteUser.
@Path("{id}")
@DELETE
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response deleteUser(@HeaderParam("Authorization") String authorization, @PathParam("id") String id) throws Exception {
Response authorizationResponse = processAuthorization(authorization);
if (authorizationResponse != null) {
return authorizationResponse;
}
try {
GluuCustomPerson gluuPerson = personService.getPersonByInum(id);
if (gluuPerson == null) {
return getErrorResponse("Resource " + id + " not found", Response.Status.NOT_FOUND.getStatusCode());
} else {
// For custom script: delete user
if (externalScimService.isEnabled()) {
externalScimService.executeScimDeleteUserMethods(gluuPerson);
}
log.info("person.getMemberOf().size() : " + gluuPerson.getMemberOf().size());
if (gluuPerson.getMemberOf() != null) {
if (gluuPerson.getMemberOf().size() > 0) {
String dn = personService.getDnForPerson(id);
log.info("DN : " + dn);
serviceUtil.deleteUserFromGroup(gluuPerson, dn);
}
}
memberService.removePerson(gluuPerson);
}
return Response.ok().build();
} catch (EntryPersistenceException ex) {
ex.printStackTrace();
return getErrorResponse("Resource " + id + " not found", Response.Status.NOT_FOUND.getStatusCode());
} catch (Exception ex) {
ex.printStackTrace();
return getErrorResponse(INTERNAL_SERVER_ERROR_MESSAGE, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
}
use of javax.ws.rs.DELETE in project oxTrust by GluuFederation.
the class GroupWebService method deleteGroup.
@Path("{id}")
@DELETE
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response deleteGroup(@HeaderParam("Authorization") String authorization, @PathParam("id") String id) throws Exception {
Response authorizationResponse = processAuthorization(authorization);
if (authorizationResponse != null) {
return authorizationResponse;
}
try {
log.info(" Checking if the group exists ");
log.info(" id : " + id);
GluuGroup gluuGroup = groupService.getGroupByInum(id);
if (gluuGroup == null) {
log.info(" the group is null ");
return getErrorResponse("Resource " + id + " not found", Response.Status.NOT_FOUND.getStatusCode());
} else {
// For custom script: delete group
if (externalScimService.isEnabled()) {
externalScimService.executeScimDeleteGroupMethods(gluuGroup);
}
log.info(" getting started to delete members from groups ");
if (gluuGroup.getMembers() != null) {
if (gluuGroup.getMembers().size() > 0) {
log.info(" getting dn for group ");
String dn = groupService.getDnForGroup(id);
log.info(" DN : " + dn);
serviceUtil.deleteGroupFromPerson(gluuGroup, dn);
}
}
log.info(" removing the group ");
groupService.removeGroup(gluuGroup);
}
return Response.ok().build();
} catch (EntryPersistenceException ex) {
ex.printStackTrace();
return getErrorResponse("Resource " + id + " not found", Response.Status.NOT_FOUND.getStatusCode());
} catch (Exception ex) {
ex.printStackTrace();
return getErrorResponse(INTERNAL_SERVER_ERROR_MESSAGE, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
}
use of javax.ws.rs.DELETE in project oxTrust by GluuFederation.
the class FidoDeviceWebService method deleteDevice.
@Path("{id}")
@DELETE
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "Delete device", notes = "Delete device (https://tools.ietf.org/html/rfc7644#section-3.6)")
public Response deleteDevice(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @PathParam("id") String id) throws Exception {
Response authorizationResponse;
if (jsonConfigurationService.getOxTrustappConfiguration().isScimTestMode()) {
log.info(" ##### SCIM Test Mode is ACTIVE");
authorizationResponse = processTestModeAuthorization(token);
} else {
authorizationResponse = processAuthorization(authorization);
}
if (authorizationResponse != null) {
return authorizationResponse;
}
try {
scim2FidoDeviceService.deleteFidoDevice(id);
return Response.noContent().build();
} catch (EntryPersistenceException epe) {
log.error("Failed to delete device", epe);
epe.printStackTrace();
return getErrorResponse(Response.Status.NOT_FOUND, ErrorScimType.INVALID_VALUE, "Resource " + id + " not found");
} catch (Exception e) {
log.error("Failed to delete device", e);
e.printStackTrace();
return getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, INTERNAL_SERVER_ERROR_MESSAGE);
}
}
use of javax.ws.rs.DELETE in project indy by Commonjava.
the class SetBackSettingsResource method delete.
@ApiOperation("DELETE the settings.xml simulation corresponding to the specified Indy group/repository")
@ApiResponses({ @ApiResponse(code = 400, message = "Requested repository is hosted on Indy and cannot be simulated via settings.xml"), @ApiResponse(code = 404, message = "No such repository or group, or the settings.xml has not been generated."), @ApiResponse(code = 204, message = "Deletion succeeded") })
@Path("/{type: (remote|group)}/{name}")
@DELETE
public Response delete(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String t, @PathParam("name") final String n) {
final StoreType type = StoreType.get(t);
if (StoreType.hosted == type) {
return Response.status(Status.BAD_REQUEST).build();
}
Response response;
final StoreKey key = new StoreKey(type, n);
try {
final boolean found = controller.deleteSetBackSettings(key);
if (found) {
response = Response.status(Status.NO_CONTENT).build();
} else {
response = Response.status(Status.NOT_FOUND).build();
}
} catch (final IndyWorkflowException e) {
response = ResponseUtils.formatResponse(e);
}
return response;
}
Aggregations