use of io.gravitee.management.model.permissions.ApplicationPermission in project gravitee-management-rest-api by gravitee-io.
the class ApplicationMembersResource method getPermissions.
@GET
@Path("/permissions")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get application members", notes = "User must have the APPLICATION_MEMBER permission to use this service")
@ApiResponses({ @ApiResponse(code = 200, message = "Application member's permissions", response = MemberEntity.class, responseContainer = "List"), @ApiResponse(code = 500, message = "Internal server error") })
@Permissions({ @Permission(value = RolePermission.APPLICATION_MEMBER, acls = RolePermissionAction.READ) })
public Response getPermissions(@PathParam("application") String application) {
Map<String, char[]> permissions = new HashMap<>();
if (isAuthenticated()) {
final String username = getAuthenticatedUser();
final ApplicationEntity applicationEntity = applicationService.findById(application);
if (isAdmin()) {
final char[] rights = new char[] { CREATE.getId(), READ.getId(), UPDATE.getId(), DELETE.getId() };
for (ApplicationPermission perm : ApplicationPermission.values()) {
permissions.put(perm.getName(), rights);
}
} else {
permissions = membershipService.getMemberPermissions(applicationEntity, username);
}
}
return Response.ok(permissions).build();
}
Aggregations