@Test public void deleteModuleWithWrongCredentials() throws AuthenticationException, UnknownHostException { client().addFilter(new HTTPBasicAuthFilter(GrapesTestUtils.WRONG_USER_4TEST, GrapesTestUtils.WRONG_PASSWORD_4TEST)); final WebResource resource = client().resource("/" + ServerAPI.MODULE_RESOURCE + "/what/ever"); final ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).delete(ClientResponse.class); assertNotNull(response); assertEquals(HttpStatus.UNAUTHORIZED_401, response.getStatus()); }
@DELETE @Path("/{name}/{version}") public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name, @PathParam("version") final String version) { if (!credential.getRoles().contains(AvailableRoles.DATA_DELETER)) { throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } if (LOG.isInfoEnabled()) { LOG.info(String.format("Got a delete module request [%s %s]", name, version)); } final String moduleId = DbModule.generateID(name, version); getModuleHandler().deleteModule(moduleId); return Response.ok("done").build(); }
ModuleResource extends AbstractResource { @DELETE @Path("/{name}/{version}") public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name, @PathParam("version") final String version) { if (!credential.getRoles().contains(AvailableRoles.DATA_DELETER)) { throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } if (LOG.isInfoEnabled()) { LOG.info(String.format("Got a delete module request [%s %s]", name, version)); } final String moduleId = DbModule.generateID(name, version); getModuleHandler().deleteModule(moduleId); return Response.ok("done").build(); } }
ModuleResource extends AbstractResource { @DELETE @Path("/{name}/{version}") public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name, @PathParam("version") final String version) { if (!credential.getRoles().contains(AvailableRoles.DATA_DELETER)) { throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } if (LOG.isInfoEnabled()) { LOG.info(String.format("Got a delete module request [%s %s]", name, version)); } final String moduleId = DbModule.generateID(name, version); getModuleHandler().deleteModule(moduleId); return Response.ok("done").build(); } ModuleResource(final RepositoryHandler repoHandler, final GrapesServerConfig dmConfig); }
ModuleResource extends AbstractResource { @DELETE @Path("/{name}/{version}") public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name, @PathParam("version") final String version) { if (!credential.getRoles().contains(AvailableRoles.DATA_DELETER)) { throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } if (LOG.isInfoEnabled()) { LOG.info(String.format("Got a delete module request [%s %s]", name, version)); } final String moduleId = DbModule.generateID(name, version); getModuleHandler().deleteModule(moduleId); return Response.ok("done").build(); } ModuleResource(final RepositoryHandler repoHandler, final GrapesServerConfig dmConfig); @POST @Produces(MediaType.TEXT_HTML) Response postModule(@Auth final DbCredential credential, final Module module); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path(ServerAPI.GET_NAMES) Response getNames(@Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}") Response getVersionsRedirection(@PathParam("name") final String name, @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}" + ServerAPI.GET_VERSIONS) Response getVersions(@PathParam("name") final String name, @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}") Response get(@PathParam("name") final String name, @PathParam("version") final String version); @DELETE @Path("/{name}/{version}") Response delete(@Auth final DbCredential credential, @PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_ORGANIZATION) Response getOrganization(@PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_ANCESTORS) Response getAncestors(@PathParam("name") final String name,
                                 @PathParam("version") final String version,
                                 @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_DEPENDENCIES) Response getDependencies(@PathParam("name") final String name,
                                    @PathParam("version") final String version,
                                    @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_DEPENDENCIES + ServerAPI.GET_REPORT) Response getDependencyReport(@PathParam("name") final String name,
                                        @PathParam("version") final String version,
                                        @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_LICENSES) Response getLicenses(@PathParam("name") final String name, @PathParam("version") final String version); @POST @Path("/{name}/{version}" + ServerAPI.PROMOTION) Response promote(@Auth final DbCredential credential, @PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}/{version}" + ServerAPI.PROMOTION + ServerAPI.GET_FEASIBLE) Response canBePromoted(@PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces({MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.PROMOTION + ServerAPI.GET_REPORT) Response getPromotionStatusReport(@PathParam("name") final String name,
                                             @PathParam("version") final String version,
                                             @QueryParam(ServerAPI.EXCLUDE_SNAPSHOT_PARAM) boolean excludeSnapshot); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}/{version}" + ServerAPI.PROMOTION) Response isPromoted(@PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}/{version}" + ServerAPI.GET_BUILD_INFO) Response getBuildInfo(@PathParam("name") final String name, @PathParam("version") final String version); @POST @Path("/{name}/{version}" + ServerAPI.GET_BUILD_INFO) Response updateBuildInfo(@PathParam("name") final String name, @PathParam("version") final String version, final Map<String, String> buildInfo); @GET @Produces(MediaType.APPLICATION_JSON) @Path(ServerAPI.GET_ALL) Response getAllModules(@Context final UriInfo uriInfo); }
ModuleResource extends AbstractResource { @DELETE @Path("/{name}/{version}") public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name, @PathParam("version") final String version) { if (!credential.getRoles().contains(AvailableRoles.DATA_DELETER)) { throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } if (LOG.isInfoEnabled()) { LOG.info(String.format("Got a delete module request [%s %s]", name, version)); } final String moduleId = DbModule.generateID(name, version); getModuleHandler().deleteModule(moduleId); return Response.ok("done").build(); } ModuleResource(final RepositoryHandler repoHandler, final GrapesServerConfig dmConfig); @POST @Produces(MediaType.TEXT_HTML) Response postModule(@Auth final DbCredential credential, final Module module); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path(ServerAPI.GET_NAMES) Response getNames(@Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}") Response getVersionsRedirection(@PathParam("name") final String name, @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}" + ServerAPI.GET_VERSIONS) Response getVersions(@PathParam("name") final String name, @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}") Response get(@PathParam("name") final String name, @PathParam("version") final String version); @DELETE @Path("/{name}/{version}") Response delete(@Auth final DbCredential credential, @PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_ORGANIZATION) Response getOrganization(@PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_ANCESTORS) Response getAncestors(@PathParam("name") final String name,
                                 @PathParam("version") final String version,
                                 @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_DEPENDENCIES) Response getDependencies(@PathParam("name") final String name,
                                    @PathParam("version") final String version,
                                    @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_DEPENDENCIES + ServerAPI.GET_REPORT) Response getDependencyReport(@PathParam("name") final String name,
                                        @PathParam("version") final String version,
                                        @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_LICENSES) Response getLicenses(@PathParam("name") final String name, @PathParam("version") final String version); @POST @Path("/{name}/{version}" + ServerAPI.PROMOTION) Response promote(@Auth final DbCredential credential, @PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}/{version}" + ServerAPI.PROMOTION + ServerAPI.GET_FEASIBLE) Response canBePromoted(@PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces({MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.PROMOTION + ServerAPI.GET_REPORT) Response getPromotionStatusReport(@PathParam("name") final String name,
                                             @PathParam("version") final String version,
                                             @QueryParam(ServerAPI.EXCLUDE_SNAPSHOT_PARAM) boolean excludeSnapshot); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}/{version}" + ServerAPI.PROMOTION) Response isPromoted(@PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}/{version}" + ServerAPI.GET_BUILD_INFO) Response getBuildInfo(@PathParam("name") final String name, @PathParam("version") final String version); @POST @Path("/{name}/{version}" + ServerAPI.GET_BUILD_INFO) Response updateBuildInfo(@PathParam("name") final String name, @PathParam("version") final String version, final Map<String, String> buildInfo); @GET @Produces(MediaType.APPLICATION_JSON) @Path(ServerAPI.GET_ALL) Response getAllModules(@Context final UriInfo uriInfo);  }