Roles REST API returns the correct media type header
@@ -31,15 +31,22 @@ import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
import org.springframework.stereotype.Component;
import com.thinkbiganalytics.metadata.api.MetadataAccess;
+import com.thinkbiganalytics.rest.model.RestResponseStatus;
+import com.thinkbiganalytics.security.rest.model.GroupPrincipal;
import com.thinkbiganalytics.security.rest.model.Role;
import com.thinkbiganalytics.security.role.SecurityRole;
import com.thinkbiganalytics.security.role.SecurityRoleProvider;
import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag;
@@ -62,6 +69,12 @@ public class RolesController {
private SecurityModelTransform securityTransform;
@GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation("Returns all the roles defined for each kind of entity.")
+ @ApiResponses({
+ @ApiResponse(code = 200, message = "The list of entity/roles mappings.", response = GroupPrincipal.class),
+ @ApiResponse(code = 500, message = "There was a problem accessing the roles.", response = RestResponseStatus.class)
+ })
public Map<String, List<Role>> getRoles() {
return metadata.read(() -> {
Map<String, List<SecurityRole>> roleMap = this.roleProvider.getRoles();
@@ -73,6 +86,12 @@ public class RolesController {
@GET
@Path("/{entity}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation("Returns all the roles defined for the a particular kind of entity.")
+ @ApiResponses({
+ @ApiResponse(code = 200, message = "The list of roles defined for the entity.", response = GroupPrincipal.class),
+ @ApiResponse(code = 500, message = "There was a problem accessing the roles.", response = RestResponseStatus.class)
+ })
public List<Role> getEntityRoles(@PathParam("entity") String entityName) {
return metadata.read(() -> {
return this.roleProvider.getEntityRoles(entityName).stream()
