@Override public void initDefaultGroupNames(Context context) throws SQLException, AuthorizeException { GroupService groupService = EPersonServiceFactory.getInstance().getGroupService(); // Check for Anonymous group. If not found, create it Group anonymousGroup = groupService.findByName(context, Group.ANONYMOUS); if (anonymousGroup == null) { anonymousGroup = groupService.create(context); anonymousGroup.setName(Group.ANONYMOUS); anonymousGroup.setPermanent(true); groupService.update(context, anonymousGroup); } // Check for Administrator group. If not found, create it Group adminGroup = groupService.findByName(context, Group.ADMIN); if (adminGroup == null) { adminGroup = groupService.create(context); adminGroup.setName(Group.ADMIN); adminGroup.setPermanent(true); groupService.update(context, adminGroup); } }
groupObj = groupService.create(context);
@Override public Group createWorkflowGroup(Context context, Collection collection, int step) throws SQLException, AuthorizeException { // Check authorisation - Must be an Admin to create Workflow Group AuthorizeUtil.authorizeManageWorkflowsGroup(context, collection); if (getWorkflowGroup(collection, step) == null) { //turn off authorization so that Collection Admins can create Collection Workflow Groups context.turnOffAuthorisationSystem(); Group g = groupService.create(context); context.restoreAuthSystemState(); groupService.setName(g, "COLLECTION_" + collection.getID() + "_WORKFLOW_STEP_" + step); groupService.update(context, g); setWorkflowGroup(context, collection, step, g); } return getWorkflowGroup(collection, step); }
@Override public Group createAdministrators(Context context, Community community) throws SQLException, AuthorizeException { // Check authorisation - Must be an Admin to create more Admins AuthorizeUtil.authorizeManageAdminGroup(context, community); Group admins = community.getAdministrators(); if (admins == null) { //turn off authorization so that Community Admins can create Sub-Community Admins context.turnOffAuthorisationSystem(); admins = groupService.create(context); context.restoreAuthSystemState(); groupService.setName(admins, "COMMUNITY_" + community.getID() + "_ADMIN"); groupService.update(context, admins); } authorizeService.addPolicy(context, community, Constants.ADMIN, admins); // register this as the admin group community.setAdmins(admins); return admins; }
@Override public Group createSubmitters(Context context, Collection collection) throws SQLException, AuthorizeException { // Check authorisation - Must be an Admin to create Submitters Group AuthorizeUtil.authorizeManageSubmittersGroup(context, collection); Group submitters = collection.getSubmitters(); if (submitters == null) { //turn off authorization so that Collection Admins can create Collection Submitters context.turnOffAuthorisationSystem(); submitters = groupService.create(context); context.restoreAuthSystemState(); groupService.setName(submitters, "COLLECTION_" + collection.getID() + "_SUBMIT"); groupService.update(context, submitters); } // register this as the submitter group collection.setSubmitters(submitters); authorizeService.addPolicy(context, collection, Constants.ADD, submitters); return submitters; }
@Override public Group createAdministrators(Context context, Collection collection) throws SQLException, AuthorizeException { // Check authorisation - Must be an Admin to create more Admins AuthorizeUtil.authorizeManageAdminGroup(context, collection); Group admins = collection.getAdministrators(); if (admins == null) { //turn off authorization so that Community Admins can create Collection Admins context.turnOffAuthorisationSystem(); admins = groupService.create(context); context.restoreAuthSystemState(); groupService.setName(admins, "COLLECTION_" + collection.getID() + "_ADMIN"); groupService.update(context, admins); } authorizeService.addPolicy(context, collection, Constants.ADMIN, admins); // register this as the admin group collection.setAdmins(admins); return admins; }
@Override public Group getWorkflowRoleGroup(Context context, Collection collection, String roleName, Group roleGroup) throws SQLException, IOException, WorkflowException, AuthorizeException { try { Role role = WorkflowUtils.getCollectionAndRepositoryRoles(collection).get(roleName); if (role.getScope() == Role.Scope.COLLECTION || role.getScope() == Role.Scope.REPOSITORY) { roleGroup = WorkflowUtils.getRoleGroup(context, collection, role); if (roleGroup == null) { authorizeService.authorizeAction(context, collection, Constants.WRITE); roleGroup = groupService.create(context); if (role.getScope() == Role.Scope.COLLECTION) { groupService.setName(roleGroup, "COLLECTION_" + collection.getID().toString() + "_WORKFLOW_ROLE_" + roleName); } else { groupService.setName(roleGroup, role.getName()); } groupService.update(context, roleGroup); authorizeService.addPolicy(context, collection, Constants.ADD, roleGroup); if (role.getScope() == Role.Scope.COLLECTION) { WorkflowUtils.createCollectionWorkflowRole(context, collection, roleName, roleGroup); } } } return roleGroup; } catch (WorkflowConfigurationException e) { throw new WorkflowException(e); } }