@ApiOperation(value="Get list of user profiles.",notes="The users' profiles function returns a list of all users of the XNAT system with brief information about each.",response=User.class,responseContainer="List")
@ApiResponses({@ApiResponse(code=200,message="An array of user profiles"),@ApiResponse(code=500,message="Unexpected error")})
@ApiOperation(value="Gets the user with the specified user ID.",notes="Returns the serialized user object with the specified user ID.",response=User.class)
@ApiOperation(value="Gets the user with the specified user ID.",notes="Returns the serialized user object with the specified user ID.",response=User.class)
@ApiResponses({@ApiResponse(code=200,message="User successfully retrieved."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to view this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
@ApiResponses({@ApiResponse(code=200,message="User successfully retrieved."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to view this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<User>usersIdGet(@ApiParam(value="ID of the user to fetch",required=true)@PathVariable("id")Stringid){
publicResponseEntity<User>usersIdGet(@ApiParam(value="ID of the user to fetch",required=true)@PathVariable("id")Stringid){
HttpStatusstatus=isPermitted(id);
HttpStatusstatus=isPermitted(id);
if(status!=null){
if(status!=null){
...
@@ -56,38 +86,49 @@ public class UsersApi extends AbstractXnatRestApi {
...
@@ -56,38 +86,49 @@ public class UsersApi extends AbstractXnatRestApi {
}
}
}
}
@ApiOperation(value="Creates or updates the user object with the specified user ID.",notes="Returns the updated serialized user object with the specified user ID.",response=User.class)
@ApiOperation(value="Creates or updates the user object with the specified username.",notes="Returns the updated serialized user object with the specified username.",response=User.class)
@ApiResponses({@ApiResponse(code=200,message="User successfully created or updated."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to create or update this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
@ApiResponses({@ApiResponse(code=200,message="User successfully created or updated."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to create or update this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<User>usersIdPut(@ApiParam(value="The ID of the user to create or update.",required=true)@PathVariable("id")Stringid,@RequestBodyUsermodel)throwsNotFoundException{
publicResponseEntity<User>usersIdPut(@ApiParam(value="The username of the user to create or update.",required=true)@PathVariable("id")Stringusername,@RequestBodyUsermodel)throwsNotFoundException{
HttpStatusstatus=isPermitted(id);
HttpStatusstatus=isPermitted(username);
if(status!=null){
if(status!=null){
returnnewResponseEntity<>(status);
returnnewResponseEntity<>(status);
}
}
finalUserIuser;
UserIuser=null;
try{
try{
user=Users.getUser(id);
user=Users.getUser(username);
}catch(UserInitExceptione){
}catch(Exceptione){
_log.error("An error occurred initializing the user "+id,e);
@@ -99,7 +140,7 @@ public class UsersApi extends AbstractXnatRestApi {
...
@@ -99,7 +140,7 @@ public class UsersApi extends AbstractXnatRestApi {
@ApiOperation(value="Returns whether the user with the specified user ID is enabled.",notes="Returns true or false based on whether the specified user is enabled or not.",response=Boolean.class)
@ApiOperation(value="Returns whether the user with the specified user ID is enabled.",notes="Returns true or false based on whether the specified user is enabled or not.",response=Boolean.class)
@ApiResponses({@ApiResponse(code=200,message="User enabled status successfully retrieved."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to view this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
@ApiResponses({@ApiResponse(code=200,message="User enabled status successfully retrieved."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to view this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<Boolean>usersIdEnabledGet(@ApiParam(value="The ID of the user to retrieve the enabled status for.",required=true)@PathVariable("id")Stringid){
publicResponseEntity<Boolean>usersIdEnabledGet(@ApiParam(value="The ID of the user to retrieve the enabled status for.",required=true)@PathVariable("id")Stringid){
HttpStatusstatus=isPermitted(id);
HttpStatusstatus=isPermitted(id);
if(status!=null){
if(status!=null){
...
@@ -121,7 +162,7 @@ public class UsersApi extends AbstractXnatRestApi {
...
@@ -121,7 +162,7 @@ public class UsersApi extends AbstractXnatRestApi {
@ApiOperation(value="Sets the user's enabled state.",notes="Sets the enabled state of the user with the specified user ID to the value of the flag parameter.",response=Boolean.class)
@ApiOperation(value="Sets the user's enabled state.",notes="Sets the enabled state of the user with the specified user ID to the value of the flag parameter.",response=Boolean.class)
@ApiResponses({@ApiResponse(code=200,message="User enabled status successfully set."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to enable or disable this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
@ApiResponses({@ApiResponse(code=200,message="User enabled status successfully set."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to enable or disable this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<Boolean>usersIdEnabledFlagPut(@ApiParam(value="ID of the user to fetch",required=true)@PathVariable("id")Stringid,@ApiParam(value="The value to set for the enabled status.",required=true)@PathVariable("flag")Booleanflag){
publicResponseEntity<Boolean>usersIdEnabledFlagPut(@ApiParam(value="ID of the user to fetch",required=true)@PathVariable("id")Stringid,@ApiParam(value="The value to set for the enabled status.",required=true)@PathVariable("flag")Booleanflag){
HttpStatusstatus=isPermitted(id);
HttpStatusstatus=isPermitted(id);
if(status!=null){
if(status!=null){
...
@@ -150,7 +191,7 @@ public class UsersApi extends AbstractXnatRestApi {
...
@@ -150,7 +191,7 @@ public class UsersApi extends AbstractXnatRestApi {
@ApiOperation(value="Returns whether the user with the specified user ID is verified.",notes="Returns true or false based on whether the specified user is verified or not.",response=Boolean.class)
@ApiOperation(value="Returns whether the user with the specified user ID is verified.",notes="Returns true or false based on whether the specified user is verified or not.",response=Boolean.class)
@ApiResponses({@ApiResponse(code=200,message="User verified status successfully retrieved."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to view this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
@ApiResponses({@ApiResponse(code=200,message="User verified status successfully retrieved."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to view this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<Boolean>usersIdVerifiedGet(@ApiParam(value="The ID of the user to retrieve the verified status for.",required=true)@PathVariable("id")Stringid){
publicResponseEntity<Boolean>usersIdVerifiedGet(@ApiParam(value="The ID of the user to retrieve the verified status for.",required=true)@PathVariable("id")Stringid){
HttpStatusstatus=isPermitted(id);
HttpStatusstatus=isPermitted(id);
if(status!=null){
if(status!=null){
...
@@ -172,7 +213,7 @@ public class UsersApi extends AbstractXnatRestApi {
...
@@ -172,7 +213,7 @@ public class UsersApi extends AbstractXnatRestApi {
@ApiOperation(value="Sets the user's verified state.",notes="Sets the verified state of the user with the specified user ID to the value of the flag parameter.",response=Boolean.class)
@ApiOperation(value="Sets the user's verified state.",notes="Sets the verified state of the user with the specified user ID to the value of the flag parameter.",response=Boolean.class)
@ApiResponses({@ApiResponse(code=200,message="User verified status successfully set."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to verify or un-verify this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
@ApiResponses({@ApiResponse(code=200,message="User verified status successfully set."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to verify or un-verify this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<Boolean>usersIdVerifiedFlagPut(@ApiParam(value="ID of the user to fetch",required=true)@PathVariable("id")Stringid,@ApiParam(value="The value to set for the verified status.",required=true)@PathVariable("flag")Booleanflag){
publicResponseEntity<Boolean>usersIdVerifiedFlagPut(@ApiParam(value="ID of the user to fetch",required=true)@PathVariable("id")Stringid,@ApiParam(value="The value to set for the verified status.",required=true)@PathVariable("flag")Booleanflag){
HttpStatusstatus=isPermitted(id);
HttpStatusstatus=isPermitted(id);
if(status!=null){
if(status!=null){
...
@@ -199,6 +240,167 @@ public class UsersApi extends AbstractXnatRestApi {
...
@@ -199,6 +240,167 @@ public class UsersApi extends AbstractXnatRestApi {
}
}
}
}
@ApiOperation(value="Returns the roles for the user with the specified user ID.",notes="Returns a collection of the user's roles.",response=Collection.class)
@ApiResponses({@ApiResponse(code=200,message="User roles successfully retrieved."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to view this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<Collection<String>>usersIdRolesGet(@ApiParam(value="The ID of the user to retrieve the roles for.",required=true)@PathVariable("id")Stringid){
HttpStatusstatus=isPermitted(id);
if(status!=null){
returnnewResponseEntity<>(status);
}
try{
finalUserIuser=Users.getUser(id);
if(user==null){
returnnewResponseEntity<>(HttpStatus.NOT_FOUND);
}
Collection<String>roles=Roles.getRoles(user);
returnnewResponseEntity<>(roles,HttpStatus.OK);
}catch(UserInitExceptione){
_log.error("An error occurred initializing the user "+id,e);
@ApiOperation(value="Adds a role to a user.",notes="Assigns a new role to a user.",response=Boolean.class)
@ApiResponses({@ApiResponse(code=200,message="User role successfully added."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to enable or disable this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<Boolean>usersIdAddRole(@ApiParam(value="ID of the user to add a role to",required=true)@PathVariable("id")Stringid,@ApiParam(value="The user's new role.",required=true)@PathVariable("role")Stringrole){
HttpStatusstatus=isPermitted(id);
if(status!=null){
returnnewResponseEntity<>(status);
}
try{
finalUserIuser=Users.getUser(id);
if(user==null){
returnnewResponseEntity<>(HttpStatus.NOT_FOUND);
}
try{
Roles.addRole(getSessionUser(),user,role);
returnnewResponseEntity<>(HttpStatus.OK);
}catch(Exceptione){
_log.error("Error occurred adding role "+role+" to user "+user.getLogin()+".");
@ApiOperation(value="Remove a user's role.",notes="Removes a user's role.",response=Boolean.class)
@ApiResponses({@ApiResponse(code=200,message="User role successfully removed."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to enable or disable this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<Boolean>usersIdRemoveRole(@ApiParam(value="ID of the user to delete a role from",required=true)@PathVariable("id")Stringid,@ApiParam(value="The user role to delete.",required=true)@PathVariable("role")Stringrole){
HttpStatusstatus=isPermitted(id);
if(status!=null){
returnnewResponseEntity<>(status);
}
try{
finalUserIuser=Users.getUser(id);
if(user==null){
returnnewResponseEntity<>(HttpStatus.NOT_FOUND);
}
try{
Roles.deleteRole(getSessionUser(),user,role);
returnnewResponseEntity<>(HttpStatus.OK);
}catch(Exceptione){
_log.error("Error occurred removing role "+role+" from user "+user.getLogin()+".");
@ApiOperation(value="Returns the groups for the user with the specified user ID.",notes="Returns a collection of the user's groups.",response=Set.class)
@ApiResponses({@ApiResponse(code=200,message="User groups successfully retrieved."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to view this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<Set<String>>usersIdGroupsGet(@ApiParam(value="The ID of the user to retrieve the groups for.",required=true)@PathVariable("id")Stringid){
@ApiOperation(value="Adds a user to a group.",notes="Assigns user to a group.",response=Boolean.class)
@ApiResponses({@ApiResponse(code=200,message="User successfully added to group."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to enable or disable this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<Boolean>usersIdAddGroup(@ApiParam(value="ID of the user to add to a group",required=true)@PathVariable("id")Stringid,@ApiParam(value="The user's new group.",required=true)@PathVariable("group")Stringgroup){
@ApiOperation(value="Removes a user from a group.",notes="Removes a user from a group.",response=Boolean.class)
@ApiResponses({@ApiResponse(code=200,message="User's group successfully removed."),@ApiResponse(code=401,message="Must be authenticated to access the XNAT REST API."),@ApiResponse(code=403,message="Not authorized to enable or disable this user."),@ApiResponse(code=404,message="User not found."),@ApiResponse(code=500,message="Unexpected error")})
publicResponseEntity<Boolean>usersIdRemoveGroup(@ApiParam(value="ID of the user to remove from group",required=true)@PathVariable("id")Stringid,@ApiParam(value="The group to remove the user from.",required=true)@PathVariable("group")Stringgroup){
HttpStatusstatus=isPermitted(id);
if(status!=null){
returnnewResponseEntity<>(status);
}
try{
finalUserIuser=Users.getUser(id);
if(user==null){
returnnewResponseEntity<>(HttpStatus.NOT_FOUND);
}
try{
Groups.removeUserFromGroup(user,group,null);
returnnewResponseEntity<>(HttpStatus.OK);
}catch(Exceptione){
_log.error("Error occurred removing user "+user.getLogin()+" from group "+group+".");