Class UserControl
java.lang.Object
uk.ac.manchester.spinnaker.alloc.db.SQLQueries
uk.ac.manchester.spinnaker.alloc.db.DatabaseAwareBean
uk.ac.manchester.spinnaker.alloc.admin.UserControl
User and group administration DAO.
- Author:
- Donal Fellows
- 
Nested Class SummaryNested classes/interfaces inherited from class uk.ac.manchester.spinnaker.alloc.db.DatabaseAwareBeanDatabaseAwareBean.AbstractSQL
- 
Field SummaryFields inherited from class uk.ac.manchester.spinnaker.alloc.db.SQLQueriesADD_BLACKLISTED_CHIP, ADD_BLACKLISTED_CORE, ADD_BLACKLISTED_LINK, ADD_USER_TO_GROUP, ADJUST_QUOTA, ALLOCATE_BOARDS_BOARD, ALLOCATE_BOARDS_JOB, BUMP_IMPORTANCE, CHECK_LOCATION, checkRectangle, checkRectangleAt, CLEAR_BLACKLISTED_CHIPS, CLEAR_BLACKLISTED_CORES, CLEAR_BLACKLISTED_LINKS, COMPLETED_BLACKLIST_WRITE, COMPLETED_BOARD_INFO_READ, COMPLETED_GET_SERIAL_REQ, COUNT_CHANGES_FOR_JOB, COUNT_FUNCTIONING_BOARDS, COUNT_MACHINE_THINGS, COUNT_POWERED_BOARDS, countConnected, CREATE_BLACKLIST_READ, CREATE_BLACKLIST_WRITE, CREATE_GROUP, CREATE_GROUP_IF_NOT_EXISTS, CREATE_SERIAL_READ_REQ, CREATE_TEMP_READ_REQ, CREATE_USER, DEALLOCATE_BMP_BOARDS_JOB, DECREMENT_QUOTA, DELETE_ALLOC_RECORD, DELETE_BLACKLIST_OP, DELETE_GROUP, DELETE_JOB_RECORD, DELETE_MACHINE_TAGS, DELETE_NMPI_JOB, DELETE_NMPI_SESSION, DELETE_PENDING, DELETE_TASK, DELETE_USER, DESTROY_ALL_LIVE_JOBS, DESTROY_JOB, ERROR_PENDING, FAILED_BLACKLIST_OP, FIND_BOARD_BY_ID, FIND_BOARD_BY_NAME_AND_CFB, FIND_BOARD_BY_NAME_AND_IP_ADDRESS, FIND_BOARD_BY_NAME_AND_XYZ, FIND_EXPIRED_JOBS, FIND_FREE_BOARD, FIND_LOCATION, findBoardByGlobalChip, findBoardByIPAddress, findBoardByJobChip, findBoardByLogicalCoords, findBoardByPhysicalCoords, findRectangle, findRectangleAt, FINISHED_PENDING, GET_ALL_BMP_BOARDS, GET_ALL_BMPS, GET_ALL_BOARDS, GET_ALL_BOARDS_OF_ALL_MACHINES, GET_ALL_LIVE_JOBS, GET_ALL_MACHINES, GET_AVAILABLE_BOARD_NUMBERS, GET_BLACKLIST_READS, GET_BLACKLIST_WRITES, GET_BLACKLISTED_CHIPS, GET_BLACKLISTED_CORES, GET_BLACKLISTED_LINKS, GET_BMP_ADDRESS, GET_BMP_BOARD_NUMBERS, GET_BOARD_ADDRESS, GET_BOARD_BY_COORDS, GET_BOARD_CONNECT_INFO, GET_BOARD_JOB, GET_BOARD_NUMBERS, GET_BOARD_POWER_INFO, GET_BOARD_REPORTS, GET_CHANGES, GET_COMPLETED_BLACKLIST_OP, GET_CONSOLIDATION_TARGETS, GET_CURRENT_USAGE, GET_DEAD_BOARDS, GET_FUNCTIONING_FIELD, GET_GROUP_BY_ID, GET_GROUP_BY_NAME, GET_GROUP_BY_NAME_AND_MEMBER, GET_GROUP_NAMES_OF_USER, GET_GROUP_QUOTA, GET_JOB, GET_JOB_BOARD_COORDS, GET_JOB_BOARDS, GET_JOB_CHIP_DIMENSIONS, GET_JOB_IDS, GET_JOB_NMPI_JOB, GET_JOB_SESSION, GET_JOB_USAGE_AND_QUOTA, GET_LIVE_BOARDS, GET_LIVE_JOB_IDS, GET_LOCAL_USER_DETAILS, GET_MACHINE_BY_ID, GET_MACHINE_JOBS, GET_MACHINE_REPORTS, GET_MACHINE_WRAPS, GET_MEMBERSHIP, GET_MEMBERSHIPS_OF_USER, GET_NAMED_MACHINE, GET_ROOT_BMP_ADDRESS, GET_ROOT_COORDS, GET_ROOT_OF_BOARD, GET_SERIAL_INFO_REQS, GET_SUM_BOARDS_POWERED, GET_TAGS, GET_TEMP_INFO_REQS, GET_USER_AUTHORITIES, GET_USER_DETAILS, GET_USER_DETAILS_BY_NAME, GET_USER_DETAILS_BY_SUBJECT, GET_USER_ID, GET_USER_QUOTA, GET_USERS_OF_GROUP, getAllocationTasks, getConnectedBoards, getDeadLinks, getJobsWithChanges, getPerimeterLinks, getReportedBoards, GROUP_SYNC_ADD_GROUPS, GROUP_SYNC_DROP_TEMP_TABLE, GROUP_SYNC_INSERT_TEMP_ROW, GROUP_SYNC_MAKE_TEMP_TABLE, GROUP_SYNC_REMOVE_GROUPS, INSERT_BMP, INSERT_BOARD, INSERT_BOARD_REPORT, INSERT_JOB, INSERT_LINK, INSERT_MACHINE_SPINN_5, INSERT_REQ_BOARD, INSERT_REQ_N_BOARDS, INSERT_REQ_SIZE, INSERT_REQ_SIZE_BOARD, INSERT_TAG, IS_BOARD_BLACKLIST_CURRENT, IS_USER_LOCKED, issueChangeForJob, KILL_ALL_JOB_ALLOC_TASK, KILL_JOB_ALLOC_TASK, LIST_ALL_GROUPS, LIST_ALL_GROUPS_OF_TYPE, LIST_ALL_USERS, LIST_ALL_USERS_OF_TYPE, LIST_LIVE_JOBS, LIST_MACHINE_NAMES, LOAD_DIR_INFO, MARK_BOARD_BLACKLIST_CHANGED, MARK_BOARD_BLACKLIST_SYNCHED, MARK_CONSOLIDATED, MARK_LOGIN_FAILURE, MARK_LOGIN_SUCCESS, NOTE_DESTROY_REASON, READ_HISTORICAL_ALLOCS, READ_HISTORICAL_JOBS, REMOVE_USER_FROM_GROUP, SET_ALL_BOARDS_OFF, SET_BOARD_POWER_OFF, SET_BOARD_POWER_ON, SET_BOARD_SERIAL_IDS, SET_COLLAB_QUOTA, SET_FUNCTIONING_FIELD, SET_JOB_NMPI_JOB, SET_JOB_SESSION, SET_MACHINE_STATE, SET_MAX_COORDS, SET_STATE_DESTROYED, SET_STATE_PENDING, SET_USER_DISABLED, SET_USER_LOCKED, SET_USER_NAME, SET_USER_PASS, SET_USER_TRUST, UNLOCK_LOCKED_USERS, UPDATE_GROUP, UPDATE_KEEPALIVE, WRITE_HISTORICAL_ALLOCS, WRITE_HISTORICAL_JOBS
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddUserToGroup(UserRecord user, GroupRecord group) Adds a user to a group.createGroup(GroupRecord groupTemplate, GroupRecord.GroupType type) Create a group from a supplied group.createUser(UserRecord user, Function<MemberRecord, URI> urlGen) Create a user.deleteGroup(int groupId) Delete a group.deleteUser(int id, String adminUser) Deletes a user.describeMembership(int memberId, Function<MemberRecord, URI> groupUriGen, Function<MemberRecord, URI> userUriGen) Describe the details of a particular group membership.getGroup(int id, Function<MemberRecord, URI> urlGen) Get a description of a group.getGroup(String name, Function<MemberRecord, URI> urlGen) Get a description of a group.getUser(int id, Function<MemberRecord, URI> urlGen) Get a description of a user.getUser(String user, Function<MemberRecord, URI> urlGen) Get a description of a user.Get a model for updating the local password of the current user.List the groups in the database.listGroups(Function<GroupRecord, URI> uriMapper) List the groups in the database.List the groups of a type in the database.listGroups(GroupRecord.GroupType type, Function<GroupRecord, URI> uriMapper) List the groups of a type in the database.List the users in the database.listUsers(boolean internal) List the users of a type in the database.listUsers(boolean internal, Function<UserRecord, URI> uriMapper) List the users of a type in the database.listUsers(Function<UserRecord, URI> uriMapper) List the users in the database.booleanremoveMembershipOfGroup(MemberRecord member, GroupRecord group) Removes a user from a group.booleanremoveUserFromGroup(UserRecord user, GroupRecord group) Removes a user from a group.updateGroup(int id, GroupRecord group, Function<MemberRecord, URI> urlGen) Update a group from a supplied description.updateUser(int id, UserRecord user, String adminUser, Function<MemberRecord, URI> urlGen) Updates a user.updateUser(Principal principal, PasswordChangeRecord user) Update the local password of the current user based on a filled out model previously provided.Methods inherited from class uk.ac.manchester.spinnaker.alloc.db.DatabaseAwareBeanexecute, executeRead, getConnection, getHistoricalConnection, isHistoricalDBAvailable
- 
Constructor Details- 
UserControlpublic UserControl()
 
- 
- 
Method Details- 
listUsersList the users in the database.- Returns:
- List of users. Only UserRecord.userIdandUserRecord.userNamefields are inflated.
 
- 
listUsersList the users of a type in the database.- Parameters:
- internal- Whether to get the internal users. If not, get the OpenID users.
- Returns:
- List of users. Only UserRecord.userIdandUserRecord.userNamefields are inflated.
 
- 
listUsersList the users in the database.- Parameters:
- uriMapper- How to construct a URL for the user.
- Returns:
- Map of users to URLs.
 
- 
listUsersList the users of a type in the database.- Parameters:
- internal- Whether to get the internal users. If not, get the OpenID users.
- uriMapper- How to construct a URL for the user.
- Returns:
- Map of users to URLs.
 
- 
createUserCreate a user.- Parameters:
- user- The description of the user to create.
- urlGen- How to construct the URL for a group membership in the response. If- null, the memberships will be omitted.
- Returns:
- A description of the created user, or Optional.empty()if the user exists already.
 
- 
getUserGet a description of a user.- Parameters:
- id- The ID of the user.
- urlGen- How to construct the URL for a group membership in the response. If- null, the memberships will be omitted.
- Returns:
- A description of the user, or Optional.empty()if the user doesn't exist.
 
- 
getUserGet a description of a user.- Parameters:
- user- The name of the user.
- urlGen- How to construct the URL for a group membership in the response. If- null, the memberships will be omitted.
- Returns:
- A description of the user, or Optional.empty()if the user doesn't exist.
 
- 
updateUserpublic Optional<UserRecord> updateUser(int id, UserRecord user, String adminUser, Function<MemberRecord, URI> urlGen) Updates a user.- Parameters:
- id- The ID of the user
- user- The description of what to update.
- adminUser- The name of the current user doing this call. Used to prohibit any admin from doing major damage to themselves.
- urlGen- How to construct the URL for a group membership in the response. If- null, the memberships will be omitted.
- Returns:
- The updated user
 
- 
deleteUserDeletes a user.- Parameters:
- id- The ID of the user to delete.
- adminUser- The name of the current user doing this call. Used to prohibit anyone from deleting themselves.
- Returns:
- The name of the deleted user if things succeeded, or
         Optional.empty()on failure.
 
- 
getUserGet a model for updating the local password of the current user.- Parameters:
- principal- The current user
- Returns:
- User model object. Password fields are unfilled.
- Throws:
- AuthenticationException- If the user cannot change their password here for some reason.
 
- 
updateUserpublic PasswordChangeRecord updateUser(Principal principal, PasswordChangeRecord user) throws AuthenticationException Update the local password of the current user based on a filled out model previously provided.- Parameters:
- principal- The current user
- user- Valid user model object with password fields filled.
- Returns:
- Replacement user model object. Password fields are unfilled.
- Throws:
- AuthenticationException- If the user cannot change their password here for some reason.
 
- 
listGroupsList the groups in the database. Does not include membership data.- Returns:
- List of groups.
 
- 
listGroupsList the groups of a type in the database. Does not include membership data.- Parameters:
- type- The type of groups to get.
- Returns:
- List of groups.
 
- 
listGroupsList the groups in the database.- Parameters:
- uriMapper- How to construct a URL for the group.
- Returns:
- Map of group names to URLs.
 
- 
listGroupsList the groups of a type in the database.- Parameters:
- type- The type of groups to get.
- uriMapper- How to construct a URL for the group.
- Returns:
- Map of group names to URLs.
 
- 
getGroupGet a description of a group. Includes group membership data.- Parameters:
- id- The ID of the group.
- urlGen- How to construct the URL for a group membership. If- null, the memberships will be omitted.
- Returns:
- A description of the group, or Optional.empty()if the group doesn't exist.
 
- 
getGroupGet a description of a group. Includes group membership data.- Parameters:
- name- The name of the group.
- urlGen- How to construct the URL for a group membership. If- null, the memberships will be omitted.
- Returns:
- A description of the group, or Optional.empty()if the group doesn't exist.
 
- 
createGroupCreate a group from a supplied group.- Parameters:
- groupTemplate- Description of what the group should look like. Only the- groupNameand the- quotaproperties are used.
- type- What type of group is this; internal groups hold internal users, external groups hold external users and come in two kinds.
- Returns:
- The full group description, assuming all went well.
 
- 
updateGrouppublic Optional<GroupRecord> updateGroup(int id, GroupRecord group, Function<MemberRecord, URI> urlGen) Update a group from a supplied description.- Parameters:
- id- The ID of the group to update
- group- The template of what the group is to be updated to.
- urlGen- How to construct the URL for a group membership in the response. If- null, the memberships will be omitted.
- Returns:
- A description of the updated group, or Optional.empty()if the group doesn't exist.
 
- 
deleteGroupDelete a group. This removes all users from that group automatically.- Parameters:
- groupId- The ID of the group to delete.
- Returns:
- The deleted group name on success; Optional.empty()on failure.
 
- 
addUserToGroupAdds a user to a group.- Parameters:
- user- What user to add.
- group- What group to add to.
- Returns:
- Description of the created membership, or empty if adding failed. Note that this doesn't set the URLs.
 
- 
removeUserFromGroupRemoves a user from a group.- Parameters:
- user- What user to remove.
- group- What group to remove from.
- Returns:
- Whether the removing succeeded.
 
- 
removeMembershipOfGroupRemoves a user from a group.- Parameters:
- member- What membership to remove.
- group- What group to remove from.
- Returns:
- Whether the removing succeeded.
 
- 
describeMembershippublic Optional<MemberRecord> describeMembership(int memberId, Function<MemberRecord, URI> groupUriGen, Function<MemberRecord, URI> userUriGen) Describe the details of a particular group membership.- Parameters:
- memberId- The ID of the membership record.
- groupUriGen- How to generate the URL for the group. Ignored if- null.
- userUriGen- How to generate the URL for the user. Ignored if- null.
- Returns:
- The membership description
 
 
-