Class UserRestController
- java.lang.Object
-
- org.neotropic.kuwaiba.northbound.rest.aem.UserRestController
-
- All Implemented Interfaces:
UserRestOpenApi
@RestController @RequestMapping("/v2.1.1/user-manager/") public class UserRestController extends Object implements UserRestOpenApi
User Manager Rest Controller.- Author:
- Mauricio Ruiz Beltrán <mauricio.ruiz@kuwaiba.org>
-
-
Constructor Summary
Constructors Constructor Description UserRestController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addUserToGroup(long userId, long groupId, String sessionId)
Adds a user to a group.long
createGroup(String name, String description, Long[] users, String sessionId)
Creates a group.long
createUser(String userName, String password, String firstName, String lastName, boolean enabled, int type, String email, List<Privilege> privileges, long groupId, String sessionId)
Creates a user.void
deleteGroups(Long[] ids, String sessionId)
Removes a list of groups.void
deleteUsers(Long[] ids, String sessionId)
Removes a list of users.List<GroupProfile>
getGroups(String sessionId)
Retrieves the list of all groups.List<GroupProfileLight>
getGroupsForUser(long userId, String sessionId)
Retrieves the list of groups a user belongs to.UserProfile
getUserInSession(String sessionId)
Retrieves a user from the session ring given a session id.List<UserProfile>
getUsers(String sessionId)
Retrieves the list of all users.List<UserProfile>
getUsersInGroup(long groupId, String sessionId)
Gets all the users in a group.void
removePrivilegeFromGroup(long groupId, String featureToken, String sessionId)
Removes a privilege from a group.void
removePrivilegeFromUser(long userId, String featureToken, String sessionId)
Removes a privilege from a user.void
removeUserFromGroup(long userId, long groupId, String sessionId)
Removes a user from a group.void
setGroupProperties(long id, String name, String description, String sessionId)
Set the attributes of a group.void
setPrivilegeToGroup(long groupId, String featureToken, int accessLevel, String sessionId)
Sets a privilege to a group.void
setPrivilegeToUser(long userId, String featureToken, int accessLevel, String sessionId)
Sets a privilege to a user.void
setUserProperties(long id, String userName, String password, String firstName, String lastName, int enabled, int type, String email, String sessionId)
Set the properties of a given user using the id to search for it.
-
-
-
Field Detail
-
PATH
public static final String PATH
Path that includes the Kuwaiba version and the module id- See Also:
- Constant Field Values
-
-
Method Detail
-
getUsers
@RequestMapping(method=GET, value="getUsers/{sessionId}", produces="application/json") public List<UserProfile> getUsers(@PathVariable("sessionId") String sessionId)
Retrieves the list of all users.- Specified by:
getUsers
in interfaceUserRestOpenApi
- Parameters:
sessionId
- The session token id.- Returns:
- The list of users.
-
getGroups
@RequestMapping(method=GET, value="getGroups/{sessionId}", produces="application/json") public List<GroupProfile> getGroups(@PathVariable("sessionId") String sessionId)
Retrieves the list of all groups.- Specified by:
getGroups
in interfaceUserRestOpenApi
- Parameters:
sessionId
- The session token id.- Returns:
- An array of GroupProfile.
-
getUserInSession
@RequestMapping(method=GET, value="getUserInSession/{sessionId}", produces="application/json") public UserProfile getUserInSession(@PathVariable("sessionId") String sessionId)
Retrieves a user from the session ring given a session id.- Specified by:
getUserInSession
in interfaceUserRestOpenApi
- Parameters:
sessionId
- The session token id.- Returns:
- The user associated to a given session.
-
getUsersInGroup
@RequestMapping(method=GET, value="getUsersInGroup/{groupId}/{sessionId}", produces="application/json") public List<UserProfile> getUsersInGroup(@PathVariable("groupId") long groupId, @PathVariable("sessionId") String sessionId)
Gets all the users in a group.- Specified by:
getUsersInGroup
in interfaceUserRestOpenApi
- Parameters:
groupId
- The id of the group.sessionId
- The session token id.- Returns:
- The list of users in that group.
-
getGroupsForUser
@RequestMapping(method=GET, value="getGroupsForUser/{userId}/{sessionId}", produces="application/json") public List<GroupProfileLight> getGroupsForUser(@PathVariable("userId") long userId, @PathVariable("sessionId") String sessionId)
Retrieves the list of groups a user belongs to.- Specified by:
getGroupsForUser
in interfaceUserRestOpenApi
- Parameters:
userId
- The id of the user.sessionId
- The session token id.- Returns:
- The list of groups for this user.
-
setUserProperties
@RequestMapping(method=PUT, value="setUserProperties/{id}/{userName}/{password}/{firstName}/{lastName}/{enabled}/{type}/{email}/{sessionId}", produces="application/json") public void setUserProperties(@PathVariable("id") long id, @PathVariable("userName") String userName, @PathVariable("password") String password, @PathVariable("firstName") String firstName, @PathVariable("lastName") String lastName, @PathVariable("enabled") int enabled, @PathVariable("type") int type, @PathVariable("email") String email, @PathVariable("sessionId") String sessionId)
Set the properties of a given user using the id to search for it.- Specified by:
setUserProperties
in interfaceUserRestOpenApi
- Parameters:
id
- User id.userName
- New user's name. Use null to leave it unchanged.password
- New user's password. Use null to leave it unchanged.firstName
- New user's first name. Use null to leave it unchanged.lastName
- New user's last name. Use null to leave it unchanged.enabled
- 0 for false, 1 for true, -1 to leave it unchanged.type
- User type. See UserProfile.USER_TYPE* for possible values. Use -1 to leave it unchanged.email
- New user's email. Use null to leave it unchanged.sessionId
- The session token id.
-
setPrivilegeToUser
@RequestMapping(method=PUT, value="setPrivilegeToUser/{userId}/{featureToken}/{accessLevel}/{sessionId}", produces="application/json") public void setPrivilegeToUser(@PathVariable("userId") long userId, @PathVariable("featureToken") String featureToken, @PathVariable("accessLevel") int accessLevel, @PathVariable("sessionId") String sessionId)
Sets a privilege to a user. If the feature token provided already has been assigned to the user, the access level will be changed, otherwise, a privilege will be created.- Specified by:
setPrivilegeToUser
in interfaceUserRestOpenApi
- Parameters:
userId
- The user Id.featureToken
- The feature token. See class Privilege for details. Note that this token must match to the one expected by the client application. That's the only way the correct features will be enabled.accessLevel
- The feature token. See class Privilege.ACCESS_LEVEL* for details.sessionId
- The session token id.
-
setPrivilegeToGroup
@RequestMapping(method=PUT, value="setPrivilegeToGroup/{groupId}/{featureToken}/{accessLevel}/{sessionId}", produces="application/json") public void setPrivilegeToGroup(@PathVariable("groupId") long groupId, @PathVariable("featureToken") String featureToken, @PathVariable("accessLevel") int accessLevel, @PathVariable("sessionId") String sessionId)
Sets a privilege to a group. If the feature token provided already has been assigned to the group, the access level will be changed, otherwise, a privilege will be created.- Specified by:
setPrivilegeToGroup
in interfaceUserRestOpenApi
- Parameters:
groupId
- The group Id.featureToken
- The feature token. See class Privilege for details. Note that this token must match to the one expected by the client application. That's the only way the correct features will be enabled.accessLevel
- The feature token. See class Privilege.ACCESS_LEVEL* for details.sessionId
- The session token id.
-
setGroupProperties
@RequestMapping(method=PUT, value="setGroupProperties/{id}/{name}/{description}/{sessionId}", produces="application/json") public void setGroupProperties(@PathVariable("id") long id, @PathVariable("name") String name, @PathVariable("description") String description, @PathVariable("sessionId") String sessionId)
Set the attributes of a group.- Specified by:
setGroupProperties
in interfaceUserRestOpenApi
- Parameters:
id
- The id of the group.name
- The name of the group. Use null to leave the old value.description
- The description of the group. Use null to leave the old value.sessionId
- The session token id.
-
createUser
@RequestMapping(method=POST, value="createUser/{userName}/{password}/{firstName}/{lastName}/{enabled}/{type}/{email}/{groupId}/{sessionId}", produces="application/json") public long createUser(@PathVariable("userName") String userName, @PathVariable("password") String password, @PathVariable("firstName") String firstName, @PathVariable("lastName") String lastName, @PathVariable("enabled") boolean enabled, @PathVariable("type") int type, @PathVariable("email") String email, @RequestBody List<Privilege> privileges, @PathVariable("groupId") long groupId, @PathVariable("sessionId") String sessionId)
Creates a user. System users ("hard-coded" kind of users used for internal tasks that can not be deleted nor modified byu the end users) can only be manipulated (that is, anything but created) by accessing directly to the database.- Specified by:
createUser
in interfaceUserRestOpenApi
- Parameters:
userName
- New user's name. Mandatory.password
- New user's password.firstName
- New user's first name.lastName
- New user's last name.enabled
- Shall the new user be enabled by default.type
- User type. See UserProfileLight.USER_TYPE_* for possible values.email
- New user's email.privileges
- New user's privileges.groupId
- Default group this user will be associated to.sessionId
- The session token id.- Returns:
- The id of the newly created user.
-
createGroup
@RequestMapping(method=POST, value="createGroup/{name}/{description}/{users}/{sessionId}", produces="application/json") public long createGroup(@PathVariable("name") String name, @PathVariable("description") String description, @PathVariable("users") Long[] users, @PathVariable("sessionId") String sessionId)
Creates a group.- Specified by:
createGroup
in interfaceUserRestOpenApi
- Parameters:
name
- The group name.description
- The group description.users
- Users who belong the group.sessionId
- The session token id.- Returns:
- The new group id.
-
addUserToGroup
@RequestMapping(method=POST, value="addUserToGroup/{userId}/{groupId}/{sessionId}", produces="application/json") public void addUserToGroup(@PathVariable("userId") long userId, @PathVariable("groupId") long groupId, @PathVariable("sessionId") String sessionId)
Adds a user to a group.- Specified by:
addUserToGroup
in interfaceUserRestOpenApi
- Parameters:
userId
- The id of the user to be added to the group.groupId
- Id of the group which the user will be added to.sessionId
- The session token id.
-
removeUserFromGroup
@RequestMapping(method=DELETE, value="removeUserFromGroup/{userId}/{groupId}/{sessionId}", produces="application/json") public void removeUserFromGroup(@PathVariable("userId") long userId, @PathVariable("groupId") long groupId, @PathVariable("sessionId") String sessionId)
Removes a user from a group.- Specified by:
removeUserFromGroup
in interfaceUserRestOpenApi
- Parameters:
userId
- The id of the user to be removed from the group.groupId
- Id of the group which the user will be removed from.sessionId
- The session token id.
-
removePrivilegeFromUser
@RequestMapping(method=DELETE, value="removePrivilegeFromUser/{userId}/{featureToken}/{sessionId}", produces="application/json") public void removePrivilegeFromUser(@PathVariable("userId") long userId, @PathVariable("featureToken") String featureToken, @PathVariable("sessionId") String sessionId)
Removes a privilege from a user.- Specified by:
removePrivilegeFromUser
in interfaceUserRestOpenApi
- Parameters:
userId
- Id of the user.featureToken
- The feature token. See class Privilege for details.sessionId
- The session token id.
-
removePrivilegeFromGroup
@RequestMapping(method=DELETE, value="removePrivilegeFromGroup/{groupId}/{featureToken}/{sessionId}", produces="application/json") public void removePrivilegeFromGroup(@PathVariable("groupId") long groupId, @PathVariable("featureToken") String featureToken, @PathVariable("sessionId") String sessionId)
Removes a privilege from a group.- Specified by:
removePrivilegeFromGroup
in interfaceUserRestOpenApi
- Parameters:
groupId
- Id of the group.featureToken
- The feature token. See class Privilege for details.sessionId
- The session token id.
-
deleteUsers
@RequestMapping(method=DELETE, value="deleteUsers/{ids}/{sessionId}", produces="application/json") public void deleteUsers(@PathVariable("ids") Long[] ids, @PathVariable("sessionId") String sessionId)
Removes a list of users.- Specified by:
deleteUsers
in interfaceUserRestOpenApi
- Parameters:
ids
- The ids of the users to be deleted.sessionId
- The session token id.
-
deleteGroups
@RequestMapping(method=DELETE, value="deleteGroups/{ids}/{sessionId}", produces="application/json") public void deleteGroups(@PathVariable("ids") Long[] ids, @PathVariable("sessionId") String sessionId)
Removes a list of groups.- Specified by:
deleteGroups
in interfaceUserRestOpenApi
- Parameters:
ids
- The id of the groups to delete.sessionId
- The session token id.
-
-