Package org.dspace.eperson

Examples of org.dspace.eperson.Group


        else if (button.startsWith("submit_wf_create_"))
        {
            int step = Integer.parseInt(button.substring(17));

            // Create new group
            Group newGroup = collection.createWorkflowGroup(step);
            collection.update();

            // Forward to group edit page
            response.sendRedirect(response.encodeRedirectURL(request
                    .getContextPath()
                    + "/tools/group-edit?group_id=" + newGroup.getID()));
        }
        else if (button.equals("submit_admins_create"))
        {
            // Create new group
            Group newGroup = collection.createAdministrators();
            collection.update();
           
            // Forward to group edit page
            response.sendRedirect(response.encodeRedirectURL(request
                    .getContextPath()
                    + "/tools/group-edit?group_id=" + newGroup.getID()));
        }
        else if (button.equals("submit_admins_delete"))
        {
          // Remove the administrators group.
          Group g = collection.getAdministrators();
          collection.removeAdministrators();
            collection.update();
            g.delete();

            // Show edit page again - attributes set in doDSPost()
            JSPManager.showJSP(request, response, "/tools/edit-collection.jsp");
        }
        else if (button.equals("submit_submitters_create"))
        {
            // Create new group
            Group newGroup = collection.createSubmitters();
            collection.update();
           
            // Forward to group edit page
            response.sendRedirect(response.encodeRedirectURL(request
                    .getContextPath()
                    + "/tools/group-edit?group_id=" + newGroup.getID()));
        }
        else if (button.equals("submit_submitters_delete"))
        {
          // Remove the administrators group.
          Group g = collection.getSubmitters();
          collection.removeSubmitters();
            collection.update();
            g.delete();

            // Show edit page again - attributes set in doDSPost()
            JSPManager.showJSP(request, response, "/tools/edit-collection.jsp");
        }
        else if (button.equals("submit_authorization_edit"))
        {
            // Forward to policy edit page
            response.sendRedirect(response.encodeRedirectURL(request
                    .getContextPath()
                    + "/tools/authorize?collection_id="
                    + collection.getID() + "&submit_collection_select=1"));
        }
        else if (button.startsWith("submit_wf_edit_"))
        {
            int step = Integer.parseInt(button.substring(15));

            // Edit workflow group
            Group g = collection.getWorkflowGroup(step);
            response.sendRedirect(response.encodeRedirectURL(request
                    .getContextPath()
                    + "/tools/group-edit?group_id=" + g.getID()));
        }
        else if (button.equals("submit_submitters_edit"))
        {
            // Edit submitters group
            Group g = collection.getSubmitters();
            response.sendRedirect(response.encodeRedirectURL(request
                    .getContextPath()
                    + "/tools/group-edit?group_id=" + g.getID()));
        }
        else if (button.equals("submit_admins_edit"))
        {
            // Edit 'collection administrators' group
            Group g = collection.getAdministrators();
            response.sendRedirect(response.encodeRedirectURL(request
                    .getContextPath()
                    + "/tools/group-edit?group_id=" + g.getID()));
        }
        else if (button.startsWith("submit_wf_delete_"))
        {
            // Delete workflow group
            int step = Integer.parseInt(button.substring(17));

            Group g = collection.getWorkflowGroup(step);
            collection.setWorkflowGroup(step, null);

            // Have to update to avoid ref. integrity error
            collection.update();
            g.delete();

            // Show edit page again - attributes set in doDSPost()
            JSPManager.showJSP(request, response, "/tools/edit-collection.jsp");
        }
        else if (button.equals("submit_create_template"))
View Full Code Here


      policy = ResourcePolicy.create(context);
      policy.setResource(policyParent);
      added = true;
    }
   
      Group group = Group.find(context, groupID);
     
      //  modify the policy
      policy.setAction(actionID);
      policy.setGroup(group);
       
View Full Code Here

            bs.setDescription(ce.description);
          }
                   
          if ((ce.permissionsActionId != -1) && (ce.permissionsGroupName != null))
          {
        Group group = Group.findByName(context, ce.permissionsGroupName);
       
        if (group != null)
        {
              AuthorizeManager.removeAllPolicies(context, bs)// remove the default policy
              ResourcePolicy rp = ResourcePolicy.create(context);
View Full Code Here

            Community community = null;
            String display_page = null;

            ResourcePolicy policy = ResourcePolicy.find(c, policy_id);
            AuthorizeUtil.authorizeManagePolicy(c, policy);
            Group group = Group.find(c, group_id);

            if (collection_id != -1)
            {
                collection = Collection.find(c, collection_id);
View Full Code Here

                        // See if we have a group name
                        String groupName = ipMatcherGroupNames.get(ipm);

                        if (groupName != null)
                        {
                            Group group = Group.findByName(context, groupName);
                            if (group != null)
                            {
                                // Add ID so we won't have to do lookup again
                                ipMatcherGroupIDs.put(ipm, new Integer(group
                                        .getID()));
                                ipMatcherGroupNames.remove(ipm);

                                groupIDs.add(new Integer(group.getID()));
                            }
                            else
                            {
                                log.warn(LogManager.getHeader(context,
                                        "configuration_error", "unknown_group="
                                                + groupName));
                            }
                        }
                    }
                }
            }
            catch (IPMatcherException ipme)
            {
                log.warn(LogManager.getHeader(context, "configuration_error",
                        "bad_ip=" + addr), ipme);
            }
        }

        // Now remove any negative matches
        for (IPMatcher ipm : ipNegativeMatchers)
        {
            try
            {
                if (ipm.match(addr))
                {
                    // Do we know group ID?
                    Integer g = ipMatcherGroupIDs.get(ipm);
                    if (g != null)
                    {
                        groupIDs.remove(g);
                    }
                    else
                    {
                        // See if we have a group name
                        String groupName = ipMatcherGroupNames.get(ipm);

                        if (groupName != null)
                        {
                            Group group = Group.findByName(context, groupName);
                            if (group != null)
                            {
                                // Add ID so we won't have to do lookup again
                                ipMatcherGroupIDs.put(ipm, new Integer(group
                                        .getID()));
                                ipMatcherGroupNames.remove(ipm);

                                groupIDs.remove(new Integer(group.getID()));
                            }
                            else
                            {
                                log.warn(LogManager.getHeader(context,
                                        "configuration_error", "unknown_group="
View Full Code Here

  public static int getCollectionRole(Context context, int collectionID, String roleName) throws SQLException, AuthorizeException, IOException
  {
    Collection collection = Collection.find(context, collectionID);
   
    // Determine the group based upon wich role we are looking for.
    Group role = null;
    if (ROLE_ADMIN.equals(roleName))
    {
      role = collection.getAdministrators();
      if (role == null)
        role = collection.createAdministrators();
    }
    else if (ROLE_SUBMIT.equals(roleName))
    {
      role = collection.getSubmitters();
      if (role == null)
        role = collection.createSubmitters();
    }
    else if (ROLE_WF_STEP1.equals(roleName))
    { 
      role = collection.getWorkflowGroup(1);
      if (role == null)
        role = collection.createWorkflowGroup(1);
     
    }
    else if (ROLE_WF_STEP2.equals(roleName))
    {
      role = collection.getWorkflowGroup(2);
      if (role == null)
        role = collection.createWorkflowGroup(2);
    }
    else if (ROLE_WF_STEP3.equals(roleName))
    {
      role = collection.getWorkflowGroup(3);
      if (role == null)
        role = collection.createWorkflowGroup(3);
     
    }
   
    // In case we needed to create a group, save our changes
    collection.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 processDeleteCollectionRole(Context context, int collectionID, String roleName, int groupID) throws SQLException, UIException, IOException, AuthorizeException
  {
    FlowResult result = new FlowResult();
   
    Collection collection = Collection.find(context,collectionID);
    Group role = Group.find(context, groupID);
   
    // First, Unregister the role
    if (ROLE_ADMIN.equals(roleName))
    {
      collection.removeAdministrators();
    }
    else if (ROLE_SUBMIT.equals(roleName))
    {
      collection.removeSubmitters();
    }
    else if (ROLE_WF_STEP1.equals(roleName))
    { 
      collection.setWorkflowGroup(1, null);
    }
    else if (ROLE_WF_STEP2.equals(roleName))
    {
      collection.setWorkflowGroup(2, null);
    }
    else if (ROLE_WF_STEP3.equals(roleName))
    {
      collection.setWorkflowGroup(3, null);
     
    }
   
    // Second, remove all outhorizations 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,collection);
    for (ResourcePolicy policy : policies)
    {
      if (policy.getGroupID() == groupID)
        policy.delete();
    }
   
    // Finally, Delete the role's actual group.
    collection.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

    if (itemGroups.length != 1 && bitstreamGroups.length != 1)
      // If there are more than one groups assigned either of these privleges then this role based method will not work.
      // The user will need to go to the authorization section to manualy straight this out.
      return -1;
   
    Group itemGroup = itemGroups[0];
    Group bitstreamGroup = bitstreamGroups[0];
   
    if (itemGroup.getID() != bitstreamGroup.getID())
      // If the same group is not assigned both of these priveleges then this role based method will not work. The user
      // will need to go to the authorization section to manualy straighten this out.
      return -1;
   
   
View Full Code Here

   
    if (roleID != 0)
      throw new UIException("Unable to create a new default read group because either the group allready exists or multiple groups are assigned the default privleges.");
   
    Collection collection = Collection.find(context,collectionID);
    Group role = Group.create(context);
    role.setName("COLLECTION_"+collection.getID() +"_DEFAULT_READ");
   
    // Remove existing privleges from the anynomous group.
    AuthorizeManager.removePoliciesActionFilter(context, collection, Constants.DEFAULT_ITEM_READ);
    AuthorizeManager.removePoliciesActionFilter(context, collection, Constants.DEFAULT_BITSTREAM_READ);
   
    // Grant our new role the default privleges.
    AuthorizeManager.addPolicy(context, collection, Constants.DEFAULT_ITEM_READ,      role);
    AuthorizeManager.addPolicy(context, collection, Constants.DEFAULT_BITSTREAM_READ, role);
   
    // Committ the changes
    role.update();
    context.commit();
   
    return role.getID();
  }
View Full Code Here

    {
      throw new UIException("Unable to delete the default read role because the role is either allready assigned to the anonymous group or multiple groups are assigned the default priveleges.");
    }
   
    Collection collection = Collection.find(context,collectionID);
    Group role = Group.find(context, roleID);
    Group anonymous = Group.find(context,0);
   
    // Delete the old role, this will remove the default privleges.
    role.delete();
   
    // Set anonymous as the default read group.
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.