Package org.dspace.eperson

Examples of org.dspace.eperson.Group


      if (!context.getCurrentUser().getMetadata("password").equals(""))
      {
        String groupName = ConfigurationManager.getProperty("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 password.login.specialgroup does not exist"));
            return new int[0];
          } else
          {
            return new int[] { specialGroup.getID() };
          }
        }
      }
    }
    catch (Exception e) {
View Full Code Here


        int wsItemID = UIUtil.getIntParameter(request,"siID");
        int groupID = UIUtil.getIntParameter(request,"gID");
       
        // get the workspace item and the group from the request values
        WorkspaceItem wsItem = WorkspaceItem.find(context, wsItemID);
        Group group = Group.find(context, groupID);
       
        // set the attributes for the JSP
        request.setAttribute("wsItem",wsItem);
        request.setAttribute("group", group);
       
View Full Code Here

  public static String getName(Context context, int groupID) throws SQLException
  {
    if (groupID < 0)
      return "New Group"
   
    Group group = Group.find(context,groupID);
   
    if (group == null)
      return "New Group";
   
    return group.getName();
  }
View Full Code Here

        // The current policy, if it exists (i.e. we are not creating a new one)
        ResourcePolicy policy = ResourcePolicy.find(context, policyID);
       
        // The currently set group; it's value depends on wether previously clicked the "Set" button to change
        // the associated group, came here to edit an existing group, or create a new one.
        Group currentGroup;
        if (groupID != -1) {
          currentGroup = Group.find(context, groupID);
        }
        else if (policy != null) {
          currentGroup = policy.getGroup();
View Full Code Here

  {
    // New group, just return an empty list
    if (groupID < 0)
      return new String[0];
   
    Group group = Group.find(context,groupID);
   
    if (group == null)
      return new String[0];
   
    EPerson[] epeople = group.getMembers();
   
    String[] epeopleIDs = new String[epeople.length];
    for (int i=0; i < epeople.length; i++)
      epeopleIDs[i] = String.valueOf(epeople[i].getID());
   
View Full Code Here

  public static String[] getGroupMembers(Context context, int groupID) throws SQLException
  {
    if (groupID < 0)
      return new String[0];
   
    Group group = Group.find(context,groupID);
   
    if (group == null)
      return new String[0];
   
    Group[] groups = group.getMemberGroups();
   
    String[] groupIDs = new String[groups.length];
    for (int i=0; i < groups.length; i++)
      groupIDs[i] = String.valueOf(groups[i].getID());
   
View Full Code Here

        catch (UnsupportedEncodingException uee)
        {
            throw new UIException(uee);
        }
   
    Group group = null;
    if (groupID == -1)
    {
      // First check if the name is blank.
      if (newName == null || newName.length() == 0)
      {
        // Group's can not have blank names.
        result.setContinue(false);
        result.addError("group_name");
        result.setOutcome(false);
        result.setMessage(new Message("default","The group name may not be blank."));
       
        return result;
      }
     
      // Create a new group, check if the newName is allready in use.
      Group potentialDuplicate = Group.findByName(context,newName);
     
      if (potentialDuplicate == null)
        {
        // All good, create the new group.
        group = Group.create(context);
        group.setName(newName);
        }
      else
      {
        // The name is allready in use, return in error.
          result.setContinue(false);
          result.addError("group_name");
          result.addError("group_name_duplicate");
          result.setOutcome(false);
          result.setMessage(new Message("default","The group name is allready in use"));
         
          return result;
      }
    }
    else
    {
      group = Group.find(context,groupID);
      String name = group.getName();
     
      // Only update the name if there has been a change.
      if (newName != null && newName.length() > 0 && !name.equals(newName))
      {
        // The group name is to be updated, check if the newName is allready in use.
        Group potentialDuplicate = Group.findByName(context,newName);
       
        if (potentialDuplicate == null)
          {
          // All good, update the name
          group.setName(newName);
          }
        else
        {
          // The name is allready in use, return in error.
            result.setContinue(false);
            result.addError("group_name");
            result.addError("group_name_duplicate");
            result.setOutcome(false);
            result.setMessage(new Message("default","The group name is allready in use"));
           
            return result;
        }
      }
    }
   
    // Second, Prepare to check members by turning arrays into lists
    List<Integer> newEPeopleIDs = new ArrayList<Integer>();
    for (String epeopleID : newEPeopleIDsArray)
      newEPeopleIDs.add(Integer.valueOf(epeopleID));
    List<Integer> newGroupIDs = new ArrayList<Integer>();
    for (String _groupID : newGroupIDsArray)
      newGroupIDs.add(Integer.valueOf(_groupID));
   
   
    // Third, check if there are any members to remove
    // i.e. scan the list on the group against the ids.
    for (EPerson epersonMember : group.getMembers())
    {
      if (!newEPeopleIDs.contains(epersonMember.getID()))
      {
        // The current eperson is not contained in the new list.
        group.removeMember(epersonMember);
      }
      else
      {
        // If they are still in the list then remove them
        // from the list of people to add.
        newEPeopleIDs.remove((Object)epersonMember.getID());
      }
    }
    for (Group groupMember : group.getMemberGroups())
    {
      if (!newGroupIDs.contains(groupMember.getID()))
      {
        // The current group is not contained in the new list.
        group.removeMember(groupMember);
      }
      else
      {
        // If they are still in the list then remove them
        // from the list of groups to add.
        newGroupIDs.remove((Object)group.getID());
      }
    }
   
    // Third, check if there are any members to add
    // i.e. scan the list of ids against the group.
    for (Integer epersonID : newEPeopleIDs)
    {
      EPerson eperson = EPerson.find(context, epersonID);
     
      group.addMember(eperson);
    }
   
    for (Integer _groupID : newGroupIDs)
    {
      Group _group = Group.find(context, _groupID);
     
      group.addMember(_group);
    }
   
    // Last, create the result flow
View Full Code Here

    FlowResult result = new FlowResult();
    result.setContinue(true);
   
      for (String id : groupIDs)
      {
        Group groupDeleted = Group.find(context, Integer.valueOf(id));
       
        // If this group is related to a collection, then un-link it.
        int collectionId = getCollectionId(groupDeleted.getName());
        Role role = getCollectionRole(groupDeleted.getName());
        if (collectionId != -1 && role != Role.none)
        {
          Collection collection = Collection.find(context, collectionId);
         
          if (collection != null)
          {
            if (role == Role.Administrators)
            {
              collection.removeAdministrators();
              collection.update();
            }
            else if (role == Role.Submitters)
            {
              collection.removeSubmitters();
              collection.update();
            }
            else if (role == Role.WorkflowStep1)
            {
              collection.setWorkflowGroup(1, null);
              collection.update();
            }
            else if (role == Role.WorkflowStep2)
            {
              collection.setWorkflowGroup(2, null);
              collection.update();
            }
            else if (role == Role.WorkflowStep3)
            {
              collection.setWorkflowGroup(3, null);
              collection.update();
            }
            else if (role == Role.DefaultRead)
            {
              // Nothing special needs to happen.
            }
          }
        }

      groupDeleted.delete();
      }
     
      result.setOutcome(true);
    result.setMessage(T_delete_group_success_notice);
     
View Full Code Here

        CheckBox select = row.addCell().addCheckBox("select_policy");
          select.setLabel(String.valueOf(policy.getID()));
          select.addOption(String.valueOf(policy.getID()));
         
          // Accounting for the funky case of an empty policy
          Group policyGroup = policy.getGroup();
         
          row.addCell().addXref(baseURL + "&submit_edit&policy_id=" + policy.getID(), String.valueOf(policy.getID()));
          row.addCell().addXref(baseURL + "&submit_edit&policy_id=" + policy.getID(), policy.getActionText());
          if (policyGroup != null) {
            Cell groupCell = row.addCell();
            groupCell.addContent(policyGroup.getName());
            Highlight groupHigh = groupCell.addHighlight("fade");
            groupHigh.addContent(" [");
            groupHigh.addXref(baseURL + "&submit_edit_group&group_id=" + policyGroup.getID(), T_group_edit);
            groupHigh.addContent("]");
          }
          else {
              row.addCell().addContent("...");
          }
View Full Code Here

    int collectionID = parameters.getParameterAsInteger("collectionID", -1);
    Collection thisCollection = Collection.find(context, collectionID);
   
    String baseURL = contextPath + "/admin/collection?administrative-continue=" + knot.getId();
   
    Group admins = thisCollection.getAdministrators();
    Group wfStep1 = thisCollection.getWorkflowGroup(1);
    Group wfStep2 = thisCollection.getWorkflowGroup(2);
    Group wfStep3 = thisCollection.getWorkflowGroup(3);
    Group submitters = thisCollection.getSubmitters();

    Group defaultRead = null;
    int defaultReadID = FlowContainerUtils.getCollectionDefaultRead(context, collectionID);
    if (defaultReadID >= 0)
      defaultRead = Group.find(context, defaultReadID);
   
    // DIVISION: main
      Division main = body.addInteractiveDivision("collection-assign-roles",contextPath+"/admin/collection",Division.METHOD_POST,"primary administrative collection");
      main.setHead(T_main_head.parameterize(thisCollection.getMetadata("name")));
     
      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);
      options.addItem().addXref(baseURL+"&submit_harvesting",T_options_harvest);
           
      // 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 collection 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, thisCollection);
                tableRow.addCell().addXref(baseURL + "&submit_edit_admin", admins.getName());
            }
          catch (AuthorizeException authex) {
                // add a notice, the user is not authorized to create/edit collection's admin group
                tableRow.addCell().addContent(T_not_allowed);
            }
            try
            {
                AuthorizeUtil.authorizeRemoveAdminGroup(context, thisCollection);
                tableRow.addCell().addButton("submit_delete_admin").setValue(T_delete);
            }
            catch (AuthorizeException authex)
            {
                // nothing to add, the user is not allowed to delete the group
            }
      }
      else
      {
        tableRow.addCell().addContent(T_no_role);
        try
            {
                AuthorizeUtil.authorizeManageAdminGroup(context, thisCollection);
                tableRow.addCell().addButton("submit_create_admin").setValue(T_create);
            }
            catch (AuthorizeException authex) {
                // add a notice, the user is not authorized to create/edit collection's admin group
                tableRow.addCell().addContent(T_not_allowed);
            }
      }
      // help and directions row
      tableRow = rolesTable.addRow(Row.ROLE_DATA);
      tableRow.addCell();
      tableRow.addCell(1,2).addHighlight("fade offset").addContent(T_help_admins);
     
     
      /*
       * Workflow steps 1-3
       */
      // data row
      try
        {
            AuthorizeUtil.authorizeManageWorkflowsGroup(context, thisCollection);
          tableRow = rolesTable.addRow(Row.ROLE_DATA);
          tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_wf_step1);
          if (wfStep1 != null)
          {
            tableRow.addCell().addXref(baseURL + "&submit_edit_wf_step1", wfStep1.getName());
                tableRow.addCell().addButton("submit_delete_wf_step1").setValue(T_delete);
          }
          else
          {
            tableRow.addCell().addContent(T_no_role);
                tableRow.addCell().addButton("submit_create_wf_step1").setValue(T_create);
          }
          // help and directions row
          tableRow = rolesTable.addRow(Row.ROLE_DATA);
          tableRow.addCell();
          tableRow.addCell(1,2).addHighlight("fade offset").addContent(T_help_wf_step1);
         
         
          // data row
          tableRow = rolesTable.addRow(Row.ROLE_DATA);
          tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_wf_step2);
          if (wfStep2 != null)
          {
            tableRow.addCell().addXref(baseURL + "&submit_edit_wf_step2", wfStep2.getName());
                tableRow.addCell().addButton("submit_delete_wf_step2").setValue(T_delete);
          }
          else
          {
            tableRow.addCell().addContent(T_no_role);
                tableRow.addCell().addButton("submit_create_wf_step2").setValue(T_create);
          }
          // help and directions row
          tableRow = rolesTable.addRow(Row.ROLE_DATA);
          tableRow.addCell();
          tableRow.addCell(1,2).addHighlight("fade offset").addContent(T_help_wf_step2);
         
         
          // data row
          tableRow = rolesTable.addRow(Row.ROLE_DATA);
          tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_wf_step3);
          if (wfStep3 != null)
          {
            tableRow.addCell().addXref(baseURL + "&submit_edit_wf_step3", wfStep3.getName());
                tableRow.addCell().addButton("submit_delete_wf_step3").setValue(T_delete);
          }
          else
          {
            tableRow.addCell().addContent(T_no_role);
                tableRow.addCell().addButton("submit_create_wf_step3").setValue(T_create);
          }
          // help and directions row
          tableRow = rolesTable.addRow(Row.ROLE_DATA);
          tableRow.addCell();
          tableRow.addCell(1,2).addHighlight("fade offset").addContent(T_help_wf_step3);
        }
      catch (AuthorizeException authex) {
            // add a notice, the user is not allowed to manage workflow group
          tableRow = rolesTable.addRow(Row.ROLE_DATA);
            tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_wf);
            tableRow.addCell().addContent(T_not_allowed);
        }
       
      /*
       * The collection submitters
       */
      tableRow = rolesTable.addRow(Row.ROLE_DATA);
      tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_submitters);
      try
      {
          AuthorizeUtil.authorizeManageSubmittersGroup(context, thisCollection);
          if (submitters != null)
          {
            tableRow.addCell().addXref(baseURL + "&submit_edit_submit", submitters.getName());
                tableRow.addCell().addButton("submit_delete_submit").setValue(T_delete);
          }
          else
          {
            tableRow.addCell().addContent(T_no_role);
                tableRow.addCell().addButton("submit_create_submit").setValue(T_create);
          }
      }
      catch (AuthorizeException authex)
      {
          tableRow.addCell().addContent(T_not_allowed);
      }
      // help and directions row
      tableRow = rolesTable.addRow(Row.ROLE_DATA);
      tableRow.addCell();
      tableRow.addCell(1,2).addHighlight("fade offset").addContent(T_help_submitters);
     
     
      /*
       * The collection's default read authorizations
       */
      tableRow = rolesTable.addRow(Row.ROLE_DATA);
      tableRow.addCell(Cell.ROLE_HEADER).addContent(T_label_default_read);
      if (defaultRead == null)
      {
        // Custome reading permissions, we can't handle it, just provide a link to the
        // authorizations manager.
        tableRow.addCell(1,2).addContent(T_default_read_custom);
      }
      else if (defaultRead.getID() == 0) {
        // Anonymous reading
        tableRow.addCell().addContent(T_default_read_anonymous);
        addAdministratorOnlyButton(tableRow.addCell(),"submit_create_default_read",T_restrict);
      }
      else
      {
        // A specific group is dedicated to reading.
        tableRow.addCell().addXref(baseURL + "&submit_edit_default_read", defaultRead.getName());
        addAdministratorOnlyButton(tableRow.addCell(),"submit_delete_default_read",T_delete);
      }
  
      // help and directions row
      tableRow = rolesTable.addRow(Row.ROLE_DATA);
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.