@Test public void testDeleteRole_readOnly() { doThrow(ReadonlyRoleException.class).when(authorizationManager).deleteRole("roleId"); try { underTest.delete("roleId"); fail("exception should have been thrown for internal role"); } catch (WebApplicationMessageException e) { assertThat(e.getResponse().getStatus(), is(400)); assertThat(e.getResponse().getMediaType(), is(MediaType.APPLICATION_JSON_TYPE)); assertThat(e.getResponse().getEntity().toString(), is("\"Role 'roleId' is internal and cannot be modified or deleted.\"")); } }
@Override @DELETE @Path("/{id}") @RequiresAuthentication @RequiresPermissions("nexus:roles:delete") public void delete(@PathParam("id") @NotEmpty final String id) { AuthorizationManager authorizationManager = getDefaultAuthorizationManager(); try { authorizationManager.deleteRole(id); } catch (NoSuchRoleException e) { throw buildRoleNotFoundException(id); } catch (ReadonlyRoleException e) { throw buildReadonlyRoleException(id); } }
RoleApiResource extends ComponentSupport implements Resource, RoleApiResourceDoc { @Override @DELETE @Path("/{id}") @RequiresAuthentication @RequiresPermissions("nexus:roles:delete") public void delete(@PathParam("id") @NotEmpty final String id) { AuthorizationManager authorizationManager = getDefaultAuthorizationManager(); try { authorizationManager.deleteRole(id); } catch (NoSuchRoleException e) { throw buildRoleNotFoundException(id); } catch (ReadonlyRoleException e) { throw buildReadonlyRoleException(id); } } }
RoleApiResource extends ComponentSupport implements Resource, RoleApiResourceDoc { @Override @DELETE @Path("/{id}") @RequiresAuthentication @RequiresPermissions("nexus:roles:delete") public void delete(@PathParam("id") @NotEmpty final String id) { AuthorizationManager authorizationManager = getDefaultAuthorizationManager(); try { authorizationManager.deleteRole(id); } catch (NoSuchRoleException e) { throw buildRoleNotFoundException(id); } catch (ReadonlyRoleException e) { throw buildReadonlyRoleException(id); } } @Inject  RoleApiResource(final SecuritySystem securitySystem); }
RoleApiResource extends ComponentSupport implements Resource, RoleApiResourceDoc { @Override @DELETE @Path("/{id}") @RequiresAuthentication @RequiresPermissions("nexus:roles:delete") public void delete(@PathParam("id") @NotEmpty final String id) { AuthorizationManager authorizationManager = getDefaultAuthorizationManager(); try { authorizationManager.deleteRole(id); } catch (NoSuchRoleException e) { throw buildRoleNotFoundException(id); } catch (ReadonlyRoleException e) { throw buildReadonlyRoleException(id); } } @Inject  RoleApiResource(final SecuritySystem securitySystem); @Override @GET @RequiresAuthentication @RequiresPermissions("nexus:roles:read") List<RoleXOResponse> getRoles(@QueryParam("source") final String source); @Override @POST @RequiresAuthentication @RequiresPermissions("nexus:roles:create") RoleXOResponse create(@NotNull @Valid final RoleXORequest roleXO); @Override @GET @Path("/{id}") @RequiresAuthentication @RequiresPermissions("nexus:roles:read") RoleXOResponse getRole(@DefaultValue(DEFAULT_SOURCE) @QueryParam("source") final String source,
                               @PathParam("id") @NotEmpty final String id); @Override @PUT @Path("/{id}") @RequiresAuthentication @RequiresPermissions("nexus:roles:update") void update(@PathParam("id") @NotEmpty final String id, @NotNull @Valid final RoleXORequest roleXO); @Override @DELETE @Path("/{id}") @RequiresAuthentication @RequiresPermissions("nexus:roles:delete") void delete(@PathParam("id") @NotEmpty final String id); }
RoleApiResource extends ComponentSupport implements Resource, RoleApiResourceDoc { @Override @DELETE @Path("/{id}") @RequiresAuthentication @RequiresPermissions("nexus:roles:delete") public void delete(@PathParam("id") @NotEmpty final String id) { AuthorizationManager authorizationManager = getDefaultAuthorizationManager(); try { authorizationManager.deleteRole(id); } catch (NoSuchRoleException e) { throw buildRoleNotFoundException(id); } catch (ReadonlyRoleException e) { throw buildReadonlyRoleException(id); } } @Inject  RoleApiResource(final SecuritySystem securitySystem); @Override @GET @RequiresAuthentication @RequiresPermissions("nexus:roles:read") List<RoleXOResponse> getRoles(@QueryParam("source") final String source); @Override @POST @RequiresAuthentication @RequiresPermissions("nexus:roles:create") RoleXOResponse create(@NotNull @Valid final RoleXORequest roleXO); @Override @GET @Path("/{id}") @RequiresAuthentication @RequiresPermissions("nexus:roles:read") RoleXOResponse getRole(@DefaultValue(DEFAULT_SOURCE) @QueryParam("source") final String source,
                               @PathParam("id") @NotEmpty final String id); @Override @PUT @Path("/{id}") @RequiresAuthentication @RequiresPermissions("nexus:roles:update") void update(@PathParam("id") @NotEmpty final String id, @NotNull @Valid final RoleXORequest roleXO); @Override @DELETE @Path("/{id}") @RequiresAuthentication @RequiresPermissions("nexus:roles:delete") void delete(@PathParam("id") @NotEmpty final String id); static final String SOURCE_NOT_FOUND; static final String ROLE_NOT_FOUND; static final String ROLE_INTERNAL; static final String ROLE_UNIQUE; static final String ROLE_CONFLICT; static final String CONTAINED_ROLE_NOT_FOUND; static final String CONTAINED_PRIV_NOT_FOUND; static final String ROLE_CONTAINS_ITSELF; }