Search in sources :

Example 61 with DELETE

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();
}
Also used : Metacard(ddf.catalog.data.Metacard) Serializable(java.io.Serializable) Attribute(ddf.catalog.data.Attribute) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) UpdateRequestImpl(ddf.catalog.operation.impl.UpdateRequestImpl) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 62 with DELETE

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());
    }
}
Also used : VirtualListViewResponse(org.xdi.ldap.model.VirtualListViewResponse) Response(javax.ws.rs.core.Response) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) PersonRequiredFieldsException(org.gluu.oxtrust.exception.PersonRequiredFieldsException) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) DuplicateEntryException(org.gluu.site.ldap.exception.DuplicateEntryException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Example 63 with DELETE

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());
    }
}
Also used : VirtualListViewResponse(org.xdi.ldap.model.VirtualListViewResponse) Response(javax.ws.rs.core.Response) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) GluuGroup(org.gluu.oxtrust.model.GluuGroup) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) DuplicateEntryException(org.gluu.site.ldap.exception.DuplicateEntryException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Example 64 with DELETE

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);
    }
}
Also used : VirtualListViewResponse(org.xdi.ldap.model.VirtualListViewResponse) ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) DuplicateEntryException(org.gluu.site.ldap.exception.DuplicateEntryException) Path(javax.ws.rs.Path) DefaultValue(javax.ws.rs.DefaultValue) DELETE(javax.ws.rs.DELETE) HeaderParam(javax.ws.rs.HeaderParam) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation)

Example 65 with DELETE

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;
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) StoreKey(org.commonjava.indy.model.core.StoreKey) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

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