@Test public void removeCorporateGroupId(){ final DbOrganization dbOrganization= new DbOrganization(); dbOrganization.setName("organization1"); dbOrganization.getCorporateGroupIdPrefixes().add("org.test"); ArgumentCaptor<DbOrganization> captor = ArgumentCaptor.forClass(DbOrganization.class); when(repositoryHandler.getOrganization(dbOrganization.getName())).thenReturn(dbOrganization); client().addFilter(new HTTPBasicAuthFilter(GrapesTestUtils.USER_4TEST, GrapesTestUtils.PASSWORD_4TEST)); WebResource resource = client().resource("/" + ServerAPI.ORGANIZATION_RESOURCE + "/" + dbOrganization.getName() + ServerAPI.GET_CORPORATE_GROUPIDS); ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).delete(ClientResponse.class, "org.test"); assertNotNull(response); assertEquals(HttpStatus.OK_200, response.getStatus()); verify(repositoryHandler).store((DbOrganization)captor.capture()); assertFalse(captor.getValue().getCorporateGroupIdPrefixes().contains("org.test")); }
@DELETE @Path("/{name}") public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name){ if(!credential.getRoles().contains(DbCredential.AvailableRoles.DATA_DELETER)){ throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } LOG.info("Got a delete organization request."); getOrganizationHandler().deleteOrganization(name); return Response.ok("done").build(); }
OrganizationResource extends AbstractResource { @DELETE @Path("/{name}") public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name){ if(!credential.getRoles().contains(DbCredential.AvailableRoles.DATA_DELETER)){ throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } LOG.info("Got a delete organization request."); getOrganizationHandler().deleteOrganization(name); return Response.ok("done").build(); } }
OrganizationResource extends AbstractResource { @DELETE @Path("/{name}") public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name){ if(!credential.getRoles().contains(DbCredential.AvailableRoles.DATA_DELETER)){ throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } LOG.info("Got a delete organization request."); getOrganizationHandler().deleteOrganization(name); return Response.ok("done").build(); } OrganizationResource(final RepositoryHandler repositoryHandler, final GrapesServerConfig configuration); }
OrganizationResource extends AbstractResource { @DELETE @Path("/{name}") public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name){ if(!credential.getRoles().contains(DbCredential.AvailableRoles.DATA_DELETER)){ throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } LOG.info("Got a delete organization request."); getOrganizationHandler().deleteOrganization(name); return Response.ok("done").build(); } OrganizationResource(final RepositoryHandler repositoryHandler, final GrapesServerConfig configuration); @POST Response postOrganization(@Auth final DbCredential credential, final Organization organization); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path(ServerAPI.GET_NAMES) Response getNames(); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}") Response get(@PathParam("name") final String name); @DELETE @Path("/{name}") Response delete(@Auth final DbCredential credential, @PathParam("name") final String name); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}" + ServerAPI.GET_CORPORATE_GROUPIDS) Response getCorporateGroupIdPrefix(@PathParam("name") final String organizationId); @POST @Path("/{name}" + ServerAPI.GET_CORPORATE_GROUPIDS) Response addCorporateGroupIdPrefix(@Auth final DbCredential credential, @PathParam("name") final String organizationId, final String corporateGroupId); @DELETE @Path("/{name}" + ServerAPI.GET_CORPORATE_GROUPIDS) Response removeCorporateGroupIdPrefix(@Auth final DbCredential credential, @PathParam("name") final String organizationId, final String corporateGroupId); }
OrganizationResource extends AbstractResource { @DELETE @Path("/{name}") public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name){ if(!credential.getRoles().contains(DbCredential.AvailableRoles.DATA_DELETER)){ throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } LOG.info("Got a delete organization request."); getOrganizationHandler().deleteOrganization(name); return Response.ok("done").build(); } OrganizationResource(final RepositoryHandler repositoryHandler, final GrapesServerConfig configuration); @POST Response postOrganization(@Auth final DbCredential credential, final Organization organization); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path(ServerAPI.GET_NAMES) Response getNames(); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}") Response get(@PathParam("name") final String name); @DELETE @Path("/{name}") Response delete(@Auth final DbCredential credential, @PathParam("name") final String name); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}" + ServerAPI.GET_CORPORATE_GROUPIDS) Response getCorporateGroupIdPrefix(@PathParam("name") final String organizationId); @POST @Path("/{name}" + ServerAPI.GET_CORPORATE_GROUPIDS) Response addCorporateGroupIdPrefix(@Auth final DbCredential credential, @PathParam("name") final String organizationId, final String corporateGroupId); @DELETE @Path("/{name}" + ServerAPI.GET_CORPORATE_GROUPIDS) Response removeCorporateGroupIdPrefix(@Auth final DbCredential credential, @PathParam("name") final String organizationId, final String corporateGroupId);  }