Package org.dspace.eperson

Examples of org.dspace.eperson.Group


    public static int getCommunityRole(Context context, int communityID, String roleName) throws SQLException, AuthorizeException, IOException
    {
        Community community = Community.find(context, communityID);
 
        // Determine the group based upon which role we are looking for.
        Group role = null;
        if (ROLE_ADMIN.equals(roleName))
        {
            role = community.getAdministrators();
            if (role == null)
                role = community.createAdministrators();
        }
 
        // In case we needed to create a group, save our changes
        community.update();
        context.commit();
       
        // If the role name was valid then role should be non null,
        if (role != null)
            return role.getID();
       
        return -1;
    }
View Full Code Here


    public static FlowResult processDeleteCommunityRole(Context context, int communityID, String roleName, int groupID) throws SQLException, UIException, IOException, AuthorizeException
    {
        FlowResult result = new FlowResult();
       
        Community community = Community.find(context, communityID);
        Group role = Group.find(context, groupID);
       
        // First, unregister the role
        if (ROLE_ADMIN.equals(roleName))
        {
            community.removeAdministrators();
        }
       
        // Second, remove all authorizations for this role by searching for all policies that this
        // group has on the collection and remove them otherwise the delete will fail because
        // there are dependencies.
        @SuppressWarnings("unchecked") // the cast is correct
        List<ResourcePolicy> policies = AuthorizeManager.getPolicies(context, community);
        for (ResourcePolicy policy : policies)
        {
            if (policy.getGroupID() == groupID)
                policy.delete();
        }
       
        // Finally, delete the role's actual group.
        community.update();
        role.delete();
        context.commit();
   
        result.setContinue(true);
        result.setOutcome(true);
        result.setMessage(new Message("default","The role was successfully deleted."));
View Full Code Here

 
  public void addBody(Body body) throws WingException, SQLException, AuthorizeException
  {
    String role = parameters.getParameter("role", null);
    int groupID = parameters.getParameterAsInteger("groupID", -1);
    Group toBeDeleted = Group.find(context, groupID);
   
    // DIVISION: main
      Division main = body.addInteractiveDivision("community-role-delete",contextPath+"/admin/community",Division.METHOD_POST,"primary administrative community");
      main.setHead(T_main_head.parameterize(role));
      main.addPara(T_main_para.parameterize(toBeDeleted.getName()));
     
      Para buttonList = main.addPara();
      buttonList.addButton("submit_confirm").setValue(T_submit_confirm);
      buttonList.addButton("submit_cancel").setValue(T_submit_cancel);
           
View Full Code Here

        int communityID = parameters.getParameterAsInteger("communityID", -1);
        Community thisCommunity = Community.find(context, communityID);
   
    String baseURL = contextPath + "/admin/community?administrative-continue=" + knot.getId();
   
    Group admins = thisCommunity.getAdministrators();

    // DIVISION: main
      Division main = body.addInteractiveDivision("community-assign-roles",contextPath+"/admin/community",Division.METHOD_POST,"primary administrative community");
        main.setHead(T_main_head.parameterize(thisCommunity.getName()));
     
      List options = main.addList("options", List.TYPE_SIMPLE, "horizontal");
      options.addItem().addXref(baseURL+"&submit_metadata",T_options_metadata);
      options.addItem().addHighlight("bold").addXref(baseURL+"&submit_roles",T_options_roles);

      // The table of admin roles
      Table rolesTable = main.addTable("roles-table", 6, 5);
      Row tableRow;
     
      // The header row
      Row tableHeader = rolesTable.addRow(Row.ROLE_HEADER);
      tableHeader.addCell().addContent(T_role_name);
      tableHeader.addCell().addContent(T_role_group);
      tableHeader.addCell().addContent(T_role_buttons);
      rolesTable.addRow();
           
      /*
       * The community admins
       */
      // data row
      tableRow = rolesTable.addRow(Row.ROLE_DATA);
      tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_admins);
      if (admins != null)
      {
          try
          {
              AuthorizeUtil.authorizeManageAdminGroup(context, thisCommunity);
              tableRow.addCell().addXref(baseURL + "&submit_edit_admin", admins.getName());
          }
          catch (AuthorizeException authex) {
              // add a notice, the user is not authorized to create/edit community's admin group
              tableRow.addCell().addContent(T_sysadmins_only);
          }
View Full Code Here

        return scope;
    }

    public RoleMembers getMembers(Context context, XmlWorkflowItem wfi) throws SQLException {
        if(scope == Scope.REPOSITORY){
            Group group = Group.findByName(context, name);
            if(group == null)
                return new RoleMembers();
            else{
                RoleMembers assignees =  new RoleMembers();
                assignees.addGroup(group);
                return assignees;
            }
        } else
        if(scope == Scope.COLLECTION){
            CollectionRole collectionRole = CollectionRole.find(context,wfi.getCollection().getID(),id);
            if(collectionRole != null){
                RoleMembers assignees =  new RoleMembers();
                assignees.addGroup(collectionRole.getGroup());
                return assignees;
            }
            return new RoleMembers();
        }else{
            WorkflowItemRole[] roles = WorkflowItemRole.find(context, wfi.getID(), id);
            RoleMembers assignees = new RoleMembers();
            for (WorkflowItemRole itemRole : roles){
                EPerson user = itemRole.getEPerson();
                if(user != null)
                    assignees.addEPerson(user);

                Group group = itemRole.getGroup();
                if(group != null)
                    assignees.addGroup(group);
            }

            return assignees;
View Full Code Here

      if (context.getCurrentUser().getPasswordHash() != null && !context.getCurrentUser().getPasswordHash().toString().equals(""))
      {
        String groupName = ConfigurationManager.getProperty("authentication-password", "login.specialgroup");
        if ((groupName != null) && (!groupName.trim().equals("")))
        {
            Group specialGroup = Group.findByName(context, groupName);
          if (specialGroup == null)
          {
            // Oops - the group isn't there.
            log.warn(LogManager.getHeader(context,
                "password_specialgroup",
                "Group defined in modules/authentication-password.cfg login.specialgroup does not exist"));
            return new int[0];
          } else
          {
            return new int[] { specialGroup.getID() };
          }
        }
      }
    }
    catch (Exception e) {
View Full Code Here

            {
                for (String groupName : groupNames)
                {
                    if (groupName != null)
                    {
                        Group group = Group.findByName(context, groupName);
                        if (group != null)
                        {
                            groupIDs.add(Integer.valueOf(group.getID()));
                        }
                        else
                        {
                            log.warn(LogManager.getHeader(context,
                                    "configuration_error", "unknown_group="
View Full Code Here

            if (!context.getCurrentUser().getNetid().equals(""))
            {
                String groupName = ConfigurationManager.getProperty("authentication-ldap", "login.specialgroup");
                if ((groupName != null) && (!groupName.trim().equals("")))
                {
                    Group ldapGroup = Group.findByName(context, groupName);
                    if (ldapGroup == null)
                    {
                        // Oops - the group isn't there.
                        log.warn(LogManager.getHeader(context,
                                "ldap_specialgroup",
                                "Group defined in login.specialgroup does not exist"));
                        return new int[0];
                    } else
                    {
                        return new int[] { ldapGroup.getID() };
                    }
                }
            }
        }
        catch (Exception npe) {
View Full Code Here

                if (cmp)
                {
                    // assign user to this group  
                    try
                    {
                        Group ldapGroup = Group.findByName(context, dspaceGroupName);
                        if (ldapGroup != null)
                        {
                            ldapGroup.addMember(context.getCurrentUser());
                            ldapGroup.update();
                            context.commit();
                        }
                        else
                        {
                            // The group does not exist
View Full Code Here

        // Now create the policies for the submitter and workflow
        // users to modify item and contents
        // contents = bitstreams, bundles
        // FIXME: icky hardcoded workflow steps
        Group step1group = coll.getWorkflowGroup(1);
        Group step2group = coll.getWorkflowGroup(2);
        Group step3group = coll.getWorkflowGroup(3);

        EPerson e = c.getCurrentUser();

        // read permission
        AuthorizeManager.addPolicy(c, i, Constants.READ, e, ResourcePolicy.TYPE_SUBMISSION);
View Full Code Here

TOP

Related Classes of org.dspace.eperson.Group

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.