int actionID = parameters.getParameterAsInteger("actionID",-1);
int page = parameters.getParameterAsInteger("page",0);
String query = URLDecode(parameters.getParameter("query","-1"));
// 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();
}
else currentGroup = null;
// Same for the current action; it can either blank (-1), manually set, or inherited from the current policy
if (policy != null && actionID == -1)
actionID = policy.getAction();
String errorString = parameters.getParameter("errors",null);
ArrayList<String> errors = new ArrayList<String>();
if (errorString != null)
{
for (String error : errorString.split(","))
errors.add(error);
}
/* Set up our current Dspace object */
DSpaceObject dso;
switch (objectType) {
case Constants.COMMUNITY: dso = Community.find(context, objectID); break;
case Constants.COLLECTION: dso = Collection.find(context, objectID); break;
case Constants.ITEM: dso = org.dspace.content.Item.find(context, objectID); break;
case Constants.BUNDLE: dso = Bundle.find(context, objectID); break;
case Constants.BITSTREAM: dso = Bitstream.find(context, objectID); break;
default: dso = null;
}
// DIVISION: edit-container-policies
Division main = body.addInteractiveDivision("edit-policy",contextPath+"/admin/authorize",Division.METHOD_POST,"primary administrative authorization");
if (policyID >= 0) {
objectID = policy.getResourceID();
objectType = policy.getResourceType();
main.setHead(T_main_head_edit.parameterize(policyID,Constants.typeText[objectType],objectID));
}
else
main.setHead(T_main_head_new.parameterize(Constants.typeText[objectType],objectID));