if (permissionId!=null) {
getContext().getLogger().info("Getting permission "+permissionId+" for role {"+role.getUUID()+"}"+role.getName());
// check for permission by id
try {
UUID id = UUID.fromString(permissionId);
Permission p = db.getPermission(id);
if (p==null) {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation("Permission does not exist.");
} else if (!role.hasPermission(p)) {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation("Role does not have the permission.");
} else {
getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
return null;
}
} catch (SQLException ex) {
getContext().getLogger().log(Level.SEVERE,"Error retrieving permission "+permissionId,ex);
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
return new StringRepresentation("Exception during processing, see logs.");
} catch (IllegalArgumentException ex) {
getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
return new StringRepresentation("Bad UUID value "+permissionId);
}
} else if (permissionName!=null) {
// check for permission by name
try {
Permission p = db.getPermission(permissionName);
if (p==null) {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation("Permission does not exist.");
} else if (!role.hasPermission(p)) {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);