int permission = UIUtil.getIntParameter(request, "permission");
// First, we deal with the special case of the MIT group...
if (UIUtil.getBoolParameter(request, "mitgroup"))
{
Group mitGroup = Group.findByName(context, "MIT Users");
int action;
if (permission == PERM_READ)
{
// assign default item and bitstream read to mitGroup
AuthorizeManager.addPolicy(context, collection,
Constants.DEFAULT_ITEM_READ, mitGroup);
AuthorizeManager.addPolicy(context, collection,
Constants.DEFAULT_BITSTREAM_READ, mitGroup);
}
else
{
// Must be submit
AuthorizeManager.addPolicy(context, collection, Constants.ADD,
mitGroup);
}
}
//We need to add the selected people to the group.
// First, get the relevant group
Group g = null;
switch (permission)
{
case PERM_READ:
// Actually need to create a group for this.
g = Group.create(context);
// Name it according to our conventions
g
.setName("COLLECTION_" + collection.getID()
+ "_DEFAULT_ITEM_READ");
// Give it the needed permission
AuthorizeManager.addPolicy(context, collection,
Constants.DEFAULT_ITEM_READ, g);
AuthorizeManager.addPolicy(context, collection,
Constants.DEFAULT_BITSTREAM_READ, g);
break;
case PERM_SUBMIT:
g = collection.getSubmitters();
break;
case PERM_WF1:
g = collection.getWorkflowGroup(1);
break;
case PERM_WF2:
g = collection.getWorkflowGroup(2);
break;
case PERM_WF3:
g = collection.getWorkflowGroup(3);
break;
case PERM_ADMIN:
g = collection.getAdministrators();
break;
}
// Add people and groups from the form to the group
int[] eperson_ids = UIUtil.getIntParameters(request, "eperson_id");
int[] group_ids = UIUtil.getIntParameters(request, "group_ids");
if (eperson_ids != null)
{
for (int i = 0; i < eperson_ids.length; i++)
{
EPerson eperson = EPerson.find(context, eperson_ids[i]);
if (eperson != null)
{
g.addMember(eperson);
}
}
}
if (group_ids != null)
{
for (int i = 0; i < group_ids.length; i++)
{
Group group = Group.find(context, group_ids[i]);
if (group != null)
{
g.addMember(group);
}