AuthorizeException
if all the authorizations fail.
- *
+ *
* @param c
- * context with the current user
+ * context with the current user
* @param o
- * DSpace object user is attempting to perform action on
+ * DSpace object user is attempting to perform action on
* @param actions
- * array of action IDs from
- * org.dspace.core.Constants
+ * array of action IDs from
+ * org.dspace.core.Constants
* @throws AuthorizeException
- * if any one of the specified actions cannot be performed by
- * the current user on the given object.
+ * if any one of the specified actions cannot be performed by
+ * the current user on the given object.
* @throws SQLException
- * if there's a database problem
+ * if there's a database problem
*/
public static void authorizeAnyOf(Context c, DSpaceObject o, int[] actions)
throws AuthorizeException, SQLException
@@ -67,8 +68,7 @@ public class AuthorizeManager
authorizeAction(c, o, actions[i]);
return;
- }
- catch (AuthorizeException e)
+ } catch (AuthorizeException e)
{
if (ex == null)
{
@@ -84,16 +84,15 @@ public class AuthorizeManager
* Checks that the context's current user can perform the given action on
* the given object. Throws an exception if the user is not authorized,
* otherwise the method call does nothing.
- *
+ *
* @param c
- * context
+ * context
* @param o
- * a DSpaceObject
+ * a DSpaceObject
* @param action
- * action to perform from org.dspace.core.Constants
- *
+ * action to perform from org.dspace.core.Constants
* @throws AuthorizeException
- * if the user is denied
+ * if the user is denied
*/
public static void authorizeAction(Context c, DSpaceObject o, int action)
throws AuthorizeException, SQLException
@@ -105,19 +104,18 @@ public class AuthorizeManager
* Checks that the context's current user can perform the given action on
* the given object. Throws an exception if the user is not authorized,
* otherwise the method call does nothing.
- *
+ *
* @param c
- * context
+ * context
* @param o
- * a DSpaceObject
+ * a DSpaceObject
* @param useInheritance
- * flag to say if ADMIN action on the current object or parent
- * object can be used
+ * flag to say if ADMIN action on the current object or parent
+ * object can be used
* @param action
- * action to perform from org.dspace.core.Constants
- *
+ * action to perform from org.dspace.core.Constants
* @throws AuthorizeException
- * if the user is denied
+ * if the user is denied
*/
public static void authorizeAction(Context c, DSpaceObject o, int action, boolean useInheritance)
throws AuthorizeException, SQLException
@@ -130,8 +128,7 @@ public class AuthorizeManager
if (action == -1)
{
actionText = "null";
- }
- else
+ } else
{
actionText = Constants.actionText[action];
}
@@ -142,8 +139,7 @@ public class AuthorizeManager
if (e == null)
{
userid = 0;
- }
- else
+ } else
{
userid = e.getID();
}
@@ -164,8 +160,7 @@ public class AuthorizeManager
if (e == null)
{
userid = 0;
- }
- else
+ } else
{
userid = e.getID();
}
@@ -178,8 +173,7 @@ public class AuthorizeManager
if (action == -1)
{
actionText = "null";
- }
- else
+ } else
{
actionText = Constants.actionText[action];
}
@@ -193,44 +187,42 @@ public class AuthorizeManager
/**
* same authorize, returns boolean for those who don't want to deal with
* catching exceptions.
- *
+ *
* @param c
- * DSpace context, containing current user
+ * DSpace context, containing current user
* @param o
- * DSpaceObject
+ * DSpaceObject
* @param a
- * action being attempted, from
- * org.dspace.core.Constants
- *
+ * action being attempted, from
+ * org.dspace.core.Constants
* @return true
if the current user in the context is
* authorized to perform the given action on the given object
*/
public static boolean authorizeActionBoolean(Context c, DSpaceObject o,
- int a) throws SQLException
+ int a) throws SQLException
{
return authorizeActionBoolean(c, o, a, true);
}
-
+
/**
* same authorize, returns boolean for those who don't want to deal with
* catching exceptions.
- *
+ *
* @param c
- * DSpace context, containing current user
+ * DSpace context, containing current user
* @param o
- * DSpaceObject
+ * DSpaceObject
* @param a
- * action being attempted, from
- * org.dspace.core.Constants
+ * action being attempted, from
+ * org.dspace.core.Constants
* @param useInheritance
- * flag to say if ADMIN action on the current object or parent
- * object can be used
- *
+ * flag to say if ADMIN action on the current object or parent
+ * object can be used
* @return true
if the current user in the context is
* authorized to perform the given action on the given object
*/
public static boolean authorizeActionBoolean(Context c, DSpaceObject o,
- int a, boolean useInheritance) throws SQLException
+ int a, boolean useInheritance) throws SQLException
{
boolean isAuthorized = true;
@@ -242,8 +234,7 @@ public class AuthorizeManager
try
{
authorizeAction(c, o, a, useInheritance);
- }
- catch (AuthorizeException e)
+ } catch (AuthorizeException e)
{
isAuthorized = false;
}
@@ -255,26 +246,26 @@ public class AuthorizeManager
* Check to see if the given user can perform the given action on the given
* object. Always returns true if the ignore authorization flat is set in
* the current context.
- *
+ *
* @param c
- * current context. User is irrelevant; "ignore authorization"
- * flag is relevant
+ * current context. User is irrelevant; "ignore authorization"
+ * flag is relevant
* @param o
- * object action is being attempted on
+ * object action is being attempted on
* @param action
- * ID of action being attempted, from
- * org.dspace.core.Constants
+ * ID of action being attempted, from
+ * org.dspace.core.Constants
* @param e
- * user attempting action
+ * user attempting action
* @param useInheritance
- * flag to say if ADMIN action on the current object or parent
- * object can be used
+ * flag to say if ADMIN action on the current object or parent
+ * object can be used
* @return true
if user is authorized to perform the given
* action, false
otherwise
* @throws SQLException
*/
private static boolean authorize(Context c, DSpaceObject o, int action,
- EPerson e, boolean useInheritance) throws SQLException
+ EPerson e, boolean useInheritance) throws SQLException
{
// return FALSE if there is no DSpaceObject
if (o == null)
@@ -289,21 +280,32 @@ public class AuthorizeManager
}
// is eperson set? if not, userid = 0 (anonymous)
- int userid = 0;
+ int userid = 0;
if (e != null)
{
userid = e.getID();
// perform isAdmin check to see
// if user is an Admin on this object
- DSpaceObject testObject = useInheritance?o.getAdminObject(action):null;
-
+ DSpaceObject testObject = useInheritance ? o.getAdminObject(action) : null;
+
if (isAdmin(c, testObject))
{
return true;
}
}
+ if (o instanceof Item)
+ {
+ Item i = (Item) o;
+ if (!i.isArchived()) return false;
+
+ if (i.isWithdrawn()) return false;
+
+ if (!i.isDiscoverable()) return false;
+ }
+
+
for (ResourcePolicy rp : getPoliciesActionFilter(c, o, action))
{
// check policies for date validity
@@ -336,43 +338,43 @@ public class AuthorizeManager
* Check to see if the current user is an Administrator of a given object
* within DSpace. Always return true
if the user is a System
* Admin
- *
+ *
* @param c
- * current context
+ * current context
* @param o
- * current DSpace Object, if null
the call will be
- * equivalent to a call to the isAdmin(Context c)
- * method
- *
+ * current DSpace Object, if null
the call will be
+ * equivalent to a call to the isAdmin(Context c)
+ * method
* @return true
if user has administrative privileges on the
* given DSpace object
*/
- public static boolean isAdmin(Context c, DSpaceObject o) throws SQLException {
+ public static boolean isAdmin(Context c, DSpaceObject o) throws SQLException
+ {
- // return true if user is an Administrator
- if (isAdmin(c))
- {
- return true;
- }
+ // return true if user is an Administrator
+ if (isAdmin(c))
+ {
+ return true;
+ }
- if (o == null)
- {
- return false;
- }
+ if (o == null)
+ {
+ return false;
+ }
// is eperson set? if not, userid = 0 (anonymous)
- int userid = 0;
- EPerson e = c.getCurrentUser();
- if(e != null)
- {
+ int userid = 0;
+ EPerson e = c.getCurrentUser();
+ if (e != null)
+ {
userid = e.getID();
- }
+ }
//
// First, check all Resource Policies directly on this object
//
- Listtrue
if c.ignoreAuthorization is set. Anonymous users
* can't be Admins (EPerson set to NULL)
- *
+ *
* @param c
- * current context
- *
+ * current context
* @return true
if user is an admin or ignore authorization
* flag set
*/
@@ -431,8 +432,7 @@ public class AuthorizeManager
if (e == null)
{
return false; // anonymous users can't be admins....
- }
- else
+ } else
{
return Group.isMember(c, 1);
}
@@ -444,73 +444,122 @@ public class AuthorizeManager
/**
* Add a policy for an individual eperson
- *
+ *
* @param c
- * context. Current user irrelevant
+ * context. Current user irrelevant
* @param o
- * DSpaceObject to add policy to
+ * DSpaceObject to add policy to
* @param actionID
- * ID of action from org.dspace.core.Constants
+ * ID of action from org.dspace.core.Constants
* @param e
- * eperson who can perform the action
- *
+ * eperson who can perform the action
* @throws AuthorizeException
- * if current user in context is not authorized to add policies
+ * if current user in context is not authorized to add policies
*/
public static void addPolicy(Context c, DSpaceObject o, int actionID,
- EPerson e) throws SQLException, AuthorizeException
+ EPerson e) throws SQLException, AuthorizeException
+ {
+ addPolicy(c, o, actionID, e, null);
+ }
+
+
+ /**
+ * Add a policy for an individual eperson
+ *
+ * @param c
+ * context. Current user irrelevant
+ * @param o
+ * DSpaceObject to add policy to
+ * @param actionID
+ * ID of action from org.dspace.core.Constants
+ * @param e
+ * eperson who can perform the action
+ * @param type
+ * policy type, deafult types are declared in the ResourcePolicy class
+ * @throws AuthorizeException
+ * if current user in context is not authorized to add policies
+ */
+ public static void addPolicy(Context c, DSpaceObject o, int actionID,
+ EPerson e, String type) throws SQLException, AuthorizeException
{
ResourcePolicy rp = ResourcePolicy.create(c);
rp.setResource(o);
rp.setAction(actionID);
rp.setEPerson(e);
+ rp.setRpType(type);
rp.update();
}
/**
* Add a policy for a group
- *
+ *
* @param c
- * current context
+ * current context
* @param o
- * object to add policy for
+ * object to add policy for
* @param actionID
- * ID of action from org.dspace.core.Constants
+ * ID of action from org.dspace.core.Constants
* @param g
- * group to add policy for
+ * group to add policy for
* @throws SQLException
- * if there's a database problem
+ * if there's a database problem
* @throws AuthorizeException
- * if the current user is not authorized to add this policy
+ * if the current user is not authorized to add this policy
*/
public static void addPolicy(Context c, DSpaceObject o, int actionID,
- Group g) throws SQLException, AuthorizeException
+ Group g) throws SQLException, AuthorizeException
+ {
+ addPolicy(c, o, actionID, g, null);
+ }
+
+ /**
+ * Add a policy for a group
+ *
+ * @param c
+ * current context
+ * @param o
+ * object to add policy for
+ * @param actionID
+ * ID of action from org.dspace.core.Constants
+ * @param g
+ * group to add policy for
+ * @param type
+ * policy type, deafult types are declared in the ResourcePolicy class
+ * @throws SQLException
+ * if there's a database problem
+ * @throws AuthorizeException
+ * if the current user is not authorized to add this policy
+ */
+ public static void addPolicy(Context c, DSpaceObject o, int actionID,
+ Group g, String type) throws SQLException, AuthorizeException
{
ResourcePolicy rp = ResourcePolicy.create(c);
rp.setResource(o);
rp.setAction(actionID);
rp.setGroup(g);
+ rp.setRpType(type);
rp.update();
}
/**
* Return a List of the policies for an object
- *
- * @param c current context
- * @param o object to retrieve policies for
- *
+ *
+ * @param c
+ * current context
+ * @param o
+ * object to retrieve policies for
* @return List of ResourcePolicy
objects
*/
public static ListResourcePolicy
objects
+ */
+ public static ListResourcePolicy
objects
*/
public static Listorg.dspace.core.Constants
, or -1=all
+ * ID of action to match from
+ * org.dspace.core.Constants
, or -1=all
* @throws SQLException
- * if there's a database problem
+ * if there's a database problem
*/
public static void removePoliciesActionFilter(Context context,
- DSpaceObject dso, int actionID) throws SQLException
+ DSpaceObject dso, int actionID) throws SQLException
{
if (actionID == -1)
{
// remove all policies from object
removeAllPolicies(context, dso);
- }
- else
+ } else
{
- DatabaseManager.updateQuery(context,
- "DELETE FROM resourcepolicy WHERE resource_type_id= ? AND "+
- "resource_id= ? AND action_id= ? ",
+ DatabaseManager.updateQuery(context,
+ "DELETE FROM resourcepolicy WHERE resource_type_id= ? AND " +
+ "resource_id= ? AND action_id= ? ",
dso.getType(), dso.getID(), actionID);
}
}
@@ -765,13 +898,13 @@ public class AuthorizeManager
/**
* Removes all policies relating to a particular group. FIXME doesn't check
* authorization
- *
+ *
* @param c
- * current context
+ * current context
* @param groupID
- * ID of the group
+ * ID of the group
* @throws SQLException
- * if there's a database problem
+ * if there's a database problem
*/
public static void removeGroupPolicies(Context c, int groupID)
throws SQLException
@@ -783,15 +916,15 @@ public class AuthorizeManager
/**
* Removes all policies from a group for a particular object that belong to
* a Group. FIXME doesn't check authorization
- *
+ *
* @param c
- * current context
+ * current context
* @param o
- * the object
+ * the object
* @param g
- * the group
+ * the group
* @throws SQLException
- * if there's a database problem
+ * if there's a database problem
*/
public static void removeGroupPolicies(Context c, DSpaceObject o, Group g)
throws SQLException
@@ -806,13 +939,13 @@ public class AuthorizeManager
* an EPerson. FIXME doesn't check authorization
*
* @param c
- * current context
+ * current context
* @param o
- * the object
+ * the object
* @param e
- * the eperson
+ * the eperson
* @throws java.sql.SQLException
- * if there's a database problem
+ * if there's a database problem
*/
public static void removeEPersonPolicies(Context c, DSpaceObject o, EPerson e)
throws SQLException
@@ -825,25 +958,25 @@ public class AuthorizeManager
/**
* Returns all groups authorized to perform an action on an object. Returns
* empty array if no matches.
- *
+ *
* @param c
- * current context
+ * current context
* @param o
- * object
+ * object
* @param actionID
- * ID of action frm org.dspace.core.Constants
+ * ID of action frm org.dspace.core.Constants
* @return array of Group
s that can perform the specified
* action on the specified object
* @throws java.sql.SQLException
- * if there's a database problem
+ * if there's a database problem
*/
public static Group[] getAuthorizedGroups(Context c, DSpaceObject o,
- int actionID) throws java.sql.SQLException
+ int actionID) throws java.sql.SQLException
{
// do query matching groups, actions, and objects
TableRowIterator tri = DatabaseManager.queryTable(c, "resourcepolicy",
- "SELECT * FROM resourcepolicy WHERE resource_type_id= ? "+
- "AND resource_id= ? AND action_id= ? ",o.getType(),o.getID(),actionID);
+ "SELECT * FROM resourcepolicy WHERE resource_type_id= ? " +
+ "AND resource_id= ? AND action_id= ? ", o.getType(), o.getID(), actionID);
Listtrue
, existing policies are removed first,
+ * otherwise add to existing policies
+ * @param clearOnly
+ * if true
, just delete policies for matching
+ * objects
+ * @param filter
+ * if non-null, only process bitstreams whose names contain filter
+ * @param name
+ * @param description
+ * @param startDate
+ * @param endDate
+ * @throws SQLException
+ * if database problem
+ * @throws AuthorizeException
+ * if current user is not authorized to change these policies
+ */
+ public static void setPoliciesFilter(Context c, int containerType,
+ int containerID, int contentType, int actionID, int groupID,
+ boolean isReplace, boolean clearOnly, String filter,
+ String name, String description, Date startDate, Date endDate) throws SQLException, AuthorizeException
{
if (containerType == Constants.COLLECTION)
{
@@ -171,14 +234,23 @@ public class PolicySet
if (!clearOnly)
{
- // now add the policy
- ResourcePolicy rp = ResourcePolicy.create(c);
- rp.setResource(myitem);
- rp.setAction(actionID);
- rp.setGroup(group);
+ // before create a new policy check if an identical policy is already in place
+ if(!AuthorizeManager.isAnIdenticalPolicyAlreadyInPlace(c, myitem, groupID, actionID, -1)){
+ // now add the policy
+ ResourcePolicy rp = ResourcePolicy.create(c);
- rp.update();
+ rp.setResource(myitem);
+ rp.setAction(actionID);
+ rp.setGroup(group);
+
+ rp.setRpName(name);
+ rp.setRpDescription(description);
+ rp.setStartDate(startDate);
+ rp.setEndDate(endDate);
+
+ rp.update();
+ }
}
}
}
@@ -194,24 +266,32 @@ public class PolicySet
for (int j = 0; j < bundles.length; j++)
{
- Bundle t = bundles[j]; // t for target
+ Bundle bundle = bundles[j]; // t for target
// is this a replace? delete policies first
if (isReplace || clearOnly)
{
- AuthorizeManager.removeAllPolicies(c, t);
+ AuthorizeManager.removeAllPolicies(c, bundle);
}
if (!clearOnly)
{
- // now add the policy
- ResourcePolicy rp = ResourcePolicy.create(c);
+ // before create a new policy check if an identical policy is already in place
+ if(!AuthorizeManager.isAnIdenticalPolicyAlreadyInPlace(c, bundle, groupID, actionID, -1)){
+ // now add the policy
+ ResourcePolicy rp = ResourcePolicy.create(c);
- rp.setResource(t);
- rp.setAction(actionID);
- rp.setGroup(group);
+ rp.setResource(bundle);
+ rp.setAction(actionID);
+ rp.setGroup(group);
- rp.update();
+ rp.setRpName(name);
+ rp.setRpDescription(description);
+ rp.setStartDate(startDate);
+ rp.setEndDate(endDate);
+
+ rp.update();
+ }
}
}
}
@@ -235,27 +315,35 @@ public class PolicySet
for (int k = 0; k < bitstreams.length; k++)
{
- Bitstream t = bitstreams[k]; // t for target
+ Bitstream bitstream = bitstreams[k]; // t for target
if ( filter == null ||
- t.getName().indexOf( filter ) != -1 )
+ bitstream.getName().indexOf( filter ) != -1 )
{
// is this a replace? delete policies first
if (isReplace || clearOnly)
{
- AuthorizeManager.removeAllPolicies(c, t);
+ AuthorizeManager.removeAllPolicies(c, bitstream);
}
if (!clearOnly)
{
+ // before create a new policy check if an identical policy is already in place
+ if(!AuthorizeManager.isAnIdenticalPolicyAlreadyInPlace(c, bitstream, groupID, actionID, -1)){
// now add the policy
ResourcePolicy rp = ResourcePolicy.create(c);
- rp.setResource(t);
+ rp.setResource(bitstream);
rp.setAction(actionID);
rp.setGroup(group);
+ rp.setRpName(name);
+ rp.setRpDescription(description);
+ rp.setStartDate(startDate);
+ rp.setEndDate(endDate);
+
rp.update();
+ }
}
}
}
diff --git a/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicy.java b/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicy.java
index 0383b400b5..78a4cb2524 100644
--- a/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicy.java
+++ b/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicy.java
@@ -8,6 +8,7 @@
package org.dspace.authorize;
import java.sql.SQLException;
+import java.util.Calendar;
import java.util.Date;
import org.apache.log4j.Logger;
@@ -27,6 +28,14 @@ import org.dspace.storage.rdbms.TableRow;
*/
public class ResourcePolicy
{
+
+ public static String TYPE_SUBMISSION = "TYPE_SUBMISSION";
+ public static String TYPE_WORKFLOW = "TYPE_WORKFLOW";
+ public static String TYPE_CUSTOM= "TYPE_CUSTOM";
+ public static String TYPE_INHERITED= "TYPE_INHERITED";
+
+
+
/** log4j logger */
private static Logger log = Logger.getLogger(ResourcePolicy.class);
@@ -451,4 +460,26 @@ public class ResourcePolicy
// FIXME: Check authorisation
DatabaseManager.update(myContext, myRow);
}
+
+
+ public String getRpName(){
+ return myRow.getStringColumn("rpname");
+ }
+ public void setRpName(String name){
+ myRow.setColumn("rpname", name);
+ }
+
+ public String getRpType(){
+ return myRow.getStringColumn("rptype");
+ }
+ public void setRpType(String type){
+ myRow.setColumn("rptype", type);
+ }
+
+ public String getRpDescription(){
+ return myRow.getStringColumn("rpdescription");
+ }
+ public void setRpDescription(String description){
+ myRow.setColumn("rpdescription", description);
+ }
}
diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java b/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java
index f0403ea0c1..73fca11cc0 100644
--- a/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java
+++ b/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java
@@ -61,6 +61,8 @@ public final class BrowseIndex
/** additional 'internal' tables that are always defined */
private static BrowseIndex itemIndex = new BrowseIndex("bi_item");
private static BrowseIndex withdrawnIndex = new BrowseIndex("bi_withdrawn");
+ private static BrowseIndex privateIndex = new BrowseIndex("bi_private");
+
/**
* Ensure no one else can create these
@@ -750,6 +752,12 @@ public final class BrowseIndex
{
return BrowseIndex.withdrawnIndex;
}
+
+
+ public static BrowseIndex getPrivateBrowseIndex()
+ {
+ return BrowseIndex.privateIndex;
+ }
/**
* Take a string representation of a metadata field, and return it as an array.
@@ -790,7 +798,7 @@ public final class BrowseIndex
*/
public boolean isInternalIndex()
{
- return (this == itemIndex || this == withdrawnIndex);
+ return (this == itemIndex || this == withdrawnIndex || this == privateIndex);
}
/**
diff --git a/dspace-api/src/main/java/org/dspace/browse/IndexBrowse.java b/dspace-api/src/main/java/org/dspace/browse/IndexBrowse.java
index 193052b931..16a2115e4a 100644
--- a/dspace-api/src/main/java/org/dspace/browse/IndexBrowse.java
+++ b/dspace-api/src/main/java/org/dspace/browse/IndexBrowse.java
@@ -286,6 +286,7 @@ public class IndexBrowse
dao.pruneExcess(BrowseIndex.getItemBrowseIndex().getTableName(), false);
dao.pruneExcess(BrowseIndex.getWithdrawnBrowseIndex().getTableName(), true);
+ dao.pruneExcess(BrowseIndex.getPrivateBrowseIndex().getTableName(), true);
}
private void pruneDistinctIndex(BrowseIndex bi, List+ * It is this method's job to save any data to the underlying database, as + * necessary, and return error messages (if any) which can then be processed + * by the appropriate user interface (JSP-UI or XML-UI) + *
+ * NOTE: If this step is a non-interactive step (i.e. requires no UI), then + * it should perform *all* of its processing in this method! + * + * @param context + * current DSpace context + * @param request + * current servlet request object + * @param response + * current servlet response object + * @param subInfo + * submission info object + * @return Status or error flag which will be processed by + * doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned, + * no errors occurred!) + */ + public int doProcessing(Context context, HttpServletRequest request, + HttpServletResponse response, SubmissionInfo subInfo) + throws ServletException, IOException, SQLException, + AuthorizeException{ + + String buttonPressed = Util.getSubmitButton(request, CANCEL_BUTTON); + + // get reference to item + Item item = subInfo.getSubmissionItem().getItem(); + + int groupID = 0; + if(request.getParameter("group_id")!=null){ + try{ + groupID=Integer.parseInt(request.getParameter("group_id")); + }catch (NumberFormatException nfe){ + return STATUS_ERROR_SELECT_GROUP; + } + } + + String name = request.getParameter("name"); + String reason = request.getParameter("reason"); + + + // SELECTED OPERATION: go to EditPolicyForm + if(wasEditPolicyPressed(context, buttonPressed, subInfo)) + return STATUS_EDIT_POLICY; + + // SELECTED OPERATION: Remove Policies + if(wasRemovePolicyPressed(buttonPressed)){ + removePolicy(context, buttonPressed); + context.commit(); + return STATUS_COMPLETE; + } + + // SELECTED OPERATION: Save or Cancel EditPolicy. + if(comeFromEditPolicy(request)) { + return saveOrCancelEditPolicy(context, request, subInfo, buttonPressed, item, name, groupID, reason); + } + + + // SELECTED OPERATION: ADD Policy + if(wasAddPolicyPressed(buttonPressed)){ + + int result=-1; + if( (result = checkForm(request))!=0){ + return result; + } + + // handle private checkbox + item.setDiscoverable(true); + if(request.getParameter("private_option")!=null){ + item.setDiscoverable(false); + } + + Date dateStartDate = getEmbargoUntil(request); + ResourcePolicy rp = null; + if( (rp=AuthorizeManager.createOrModifyPolicy(null, context, name, groupID, null, dateStartDate, org.dspace.core.Constants.READ, reason, item))==null){ + return STATUS_DUPLICATED_POLICY; + } + rp.update(); + context.commit(); + return STATUS_COMPLETE; + } + + + // if arrive here Next, Previous or Save has been pressed + boolean isAdvancedFormEnabled= ConfigurationManager.getBooleanProperty("xmlui.submission.restrictstep.enableAdvancedForm", false); + + // if it is a simple form we should create the policy for Anonymous + // if Anonymous does not have right on this collection, create policies for any other groups with + // DEFAULT_ITEM_READ specified. + if(!isAdvancedFormEnabled){ + AuthorizeManager.generateAutomaticPolicies(context, getEmbargoUntilDate(request), reason, item, (Collection)HandleManager.resolveToObject(context, subInfo.getCollectionHandle())); + } +// else{ +// Date dateStartDate = getEmbargoUntil(request); +// createOrModifyPolicy(null, context, name, groupID, null, dateStartDate, org.dspace.core.Constants.READ, reason, item); +// } + item.setDiscoverable(true); + if(request.getParameter("private_option")!=null){ + item.setDiscoverable(false); + } + item.update(); + context.commit(); + + return STATUS_COMPLETE; + } + + public static boolean wasEditPolicyPressed(Context context, String buttonPressed, SubmissionInfo subInfo) throws SQLException { + if (buttonPressed.startsWith("submit_edit_edit_policies_") && !buttonPressed.equals(FORM_EDIT_BUTTON_CANCEL)){ + String idPolicy = buttonPressed.substring("submit_edit_edit_policies_".length()); + ResourcePolicy rp = ResourcePolicy.find(context, Integer.parseInt(idPolicy)); + subInfo.put(SUB_INFO_SELECTED_RP, rp); + return true; + } + return false; + } + + public static boolean wasAddPolicyPressed(String buttonPressed) throws SQLException { + return (buttonPressed.equalsIgnoreCase(FORM_ACCESS_BUTTON_ADD)); + } + + public static boolean wasRemovePolicyPressed(String buttonPressed) throws SQLException { + return (buttonPressed.startsWith("submit_delete_edit_policies_")); + } + + public static boolean comeFromEditPolicy(HttpServletRequest request) throws SQLException { + return (request.getParameter("policy_id") != null); + } + + public static int saveOrCancelEditPolicy(Context context, HttpServletRequest request, SubmissionInfo subInfo, String buttonPressed, DSpaceObject dso, String name, int groupID, String reason) throws AuthorizeException, SQLException { + if (buttonPressed.equals(FORM_EDIT_BUTTON_CANCEL)){ + return STATUS_COMPLETE; + } + else if (buttonPressed.equals(FORM_EDIT_BUTTON_SAVE)){ + String idPolicy = request.getParameter("policy_id"); + ResourcePolicy resourcePolicy = ResourcePolicy.find(context, Integer.parseInt(idPolicy)); + subInfo.put(SUB_INFO_SELECTED_RP, resourcePolicy); + Date dateStartDate = getEmbargoUntil(request); + if( (resourcePolicy=AuthorizeManager.createOrModifyPolicy(resourcePolicy, context, name, groupID, null, dateStartDate, Constants.READ, reason, dso))==null){ + return EDIT_POLICY_STATUS_DUPLICATED_POLICY; + } + + resourcePolicy.update(); + context.commit(); + } + return STATUS_COMPLETE; + } + + public static void removePolicy(Context context, String buttonPressed) throws SQLException { + String idPolicy = buttonPressed.substring("submit_delete_edit_policies_".length()); + ResourcePolicy rp = ResourcePolicy.find(context, Integer.parseInt(idPolicy)); + rp.delete(); + } + + public static int checkForm(HttpServletRequest request){ + + String selectedRadio=null; + String dateEmbargoUntil = request.getParameter("embargo_until_date"); + + + // RADIO_OPEN_ACCESS_ITEM_VISIBLE=0; + // RADIO_OPEN_ACCESS_ITEM_EMBARGOED=1; + if((selectedRadio=request.getParameter("open_access_radios"))!=null && Integer.parseInt(selectedRadio)==1 + && (dateEmbargoUntil==null || dateEmbargoUntil.equals(""))){ + return STATUS_ERROR_MISSING_DATE; + } + + + if(dateEmbargoUntil !=null && !dateEmbargoUntil.equals("")){ + Date startDate = getEmbargoUntilDate(request); + if(startDate==null){ + return STATUS_ERROR_FORMAT_DATE; + } + } + return 0; + } + + + + + + + + public static Date getEmbargoUntil(HttpServletRequest request) { + // RADIO_OPEN_ACCESS_ITEM_VISIBLE=0; + // RADIO_OPEN_ACCESS_ITEM_EMBARGOED=1; + String selectedRadio; + Date dateStartDate=null; + if((selectedRadio=request.getParameter("open_access_radios"))!=null && Integer.parseInt(selectedRadio)==1){ + Date startDate = getEmbargoUntilDate(request); + if(startDate!=null) dateStartDate=startDate; + } + return dateStartDate; + } + + private static Date getEmbargoUntilDate(HttpServletRequest request) { + Date startDate = null; + try { + startDate = DateUtils.parseDate(request.getParameter("embargo_until_date"), new String[]{"yyyy-MM-dd", "yyyy-MM", "yyyy"}); + } catch (Exception e) { + //Ignore start date is already null + } + return startDate; + } + + /** + * Retrieves the number of pages that this "step" extends over. This method + * is used to build the progress bar. + *
+ * This method may just return 1 for most steps (since most steps consist of + * a single page). But, it should return a number greater than 1 for any + * "step" which spans across a number of HTML pages. For example, the + * configurable "Describe" step (configured using input-forms.xml) overrides + * this method to return the number of pages that are defined by its + * configuration file. + *
+ * Steps which are non-interactive (i.e. they do not display an interface to + * the user) should return a value of 1, so that they are only processed + * once! + * + * @param request + * The HTTP Request + * @param subInfo + * The current submission information object + * + * @return the number of pages in this step + */ + public int getNumberOfPages(HttpServletRequest request, + SubmissionInfo subInfo) throws ServletException + { + return 1; + + } + +} diff --git a/dspace-api/src/main/java/org/dspace/submit/step/UploadWithEmbargoStep.java b/dspace-api/src/main/java/org/dspace/submit/step/UploadWithEmbargoStep.java new file mode 100644 index 0000000000..41236f259a --- /dev/null +++ b/dspace-api/src/main/java/org/dspace/submit/step/UploadWithEmbargoStep.java @@ -0,0 +1,821 @@ +/** + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE and NOTICE files at the root of the source + * tree and available online at + * + * http://www.dspace.org/license/ + */ +package org.dspace.submit.step; + +import java.io.IOException; +import java.io.InputStream; +import java.sql.SQLException; +import java.util.Date; +import java.util.Enumeration; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.time.DateUtils; +import org.apache.log4j.Logger; + +import org.dspace.app.util.SubmissionInfo; +import org.dspace.app.util.Util; +import org.dspace.authorize.AuthorizeException; +import org.dspace.authorize.AuthorizeManager; +import org.dspace.authorize.ResourcePolicy; +import org.dspace.content.*; +import org.dspace.core.Context; +import org.dspace.core.ConfigurationManager; +import org.dspace.curate.Curator; +import org.dspace.handle.HandleManager; +import org.dspace.submit.AbstractProcessingStep; + +/** + * Upload step for DSpace. Processes the actual upload of files + * for an item being submitted into DSpace. + *
+ * This class performs all the behind-the-scenes processing that + * this particular step requires. This class's methods are utilized + * by both the JSP-UI and the Manakin XML-UI + * + * @see org.dspace.app.util.SubmissionConfig + * @see org.dspace.app.util.SubmissionStepConfig + * @see org.dspace.submit.AbstractProcessingStep + * + * @author Tim Donohue + * @version $Revision$ + */ +public class UploadWithEmbargoStep extends AbstractProcessingStep +{ + /** Button to upload a file * */ + public static final String SUBMIT_UPLOAD_BUTTON = "submit_upload"; + + /** Button to skip uploading a file * */ + public static final String SUBMIT_SKIP_BUTTON = "submit_skip"; + + /** Button to submit more files * */ + public static final String SUBMIT_MORE_BUTTON = "submit_more"; + + /** Button to cancel editing of file info * */ + public static final String CANCEL_EDIT_BUTTON = "submit_edit_cancel"; + + /*************************************************************************** + * STATUS / ERROR FLAGS (returned by doProcessing() if an error occurs or + * additional user interaction may be required) + * + * (Do NOT use status of 0, since it corresponds to STATUS_COMPLETE flag + * defined in the JSPStepManager class) + **************************************************************************/ + // integrity error occurred + public static final int STATUS_INTEGRITY_ERROR = 1; + + // error in uploading file + public static final int STATUS_UPLOAD_ERROR = 2; + + // error - no files uploaded! + public static final int STATUS_NO_FILES_ERROR = 5; + + // format of uploaded file is unknown + public static final int STATUS_UNKNOWN_FORMAT = 10; + + // virus checker unavailable ? + public static final int STATUS_VIRUS_CHECKER_UNAVAILABLE = 14; + + // file failed virus check + public static final int STATUS_CONTAINS_VIRUS = 16; + + // edit file information + public static final int STATUS_EDIT_BITSTREAM = 20; + + // return from editing file information + public static final int STATUS_EDIT_COMPLETE = 25; + + + public static final int STATUS_EDIT_POLICIES = 30; + + public static final int STATUS_EDIT_POLICIES_ERROR_SELECT_GROUP = 31; + public static final int STATUS_EDIT_POLICIES_DUPLICATED_POLICY = 32; + + public static final int STATUS_EDIT_POLICY_ERROR_SELECT_GROUP = 33; + public static final int STATUS_EDIT_POLICY_DUPLICATED_POLICY = 34; + + + /** log4j logger */ + private static Logger log = Logger.getLogger(UploadStep.class); + + /** is the upload required? */ + private boolean fileRequired = ConfigurationManager.getBooleanProperty("webui.submit.upload.required", true); + + /** + * Do any processing of the information input by the user, and/or perform + * step processing (if no user interaction required) + *
+ * It is this method's job to save any data to the underlying database, as + * necessary, and return error messages (if any) which can then be processed + * by the appropriate user interface (JSP-UI or XML-UI) + *
+ * NOTE: If this step is a non-interactive step (i.e. requires no UI), then + * it should perform *all* of its processing in this method! + * + * @param context + * current DSpace context + * @param request + * current servlet request object + * @param response + * current servlet response object + * @param subInfo + * submission info object + * @return Status or error flag which will be processed by + * doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned, + * no errors occurred!) + */ + public int doProcessing(Context context, HttpServletRequest request, + HttpServletResponse response, SubmissionInfo subInfo) + throws ServletException, IOException, SQLException, + AuthorizeException + { + // get button user pressed + String buttonPressed = Util.getSubmitButton(request, NEXT_BUTTON); + + // get reference to item + Item item = subInfo.getSubmissionItem().getItem(); + + // ----------------------------------- + // Step #0: Upload new files (if any) + // ----------------------------------- + String contentType = request.getContentType(); + + // if multipart form, then we are uploading a file + if ((contentType != null) + && (contentType.indexOf("multipart/form-data") != -1)) + { + // This is a multipart request, so it's a file upload + // (return any status messages or errors reported) + int status = processUploadFile(context, request, response, subInfo); + + // if error occurred, return immediately + if (status != STATUS_COMPLETE) + { + return status; + } + } + + // if user pressed jump-to button in process bar, + // return success (so that jump will occur) + if (buttonPressed.startsWith(PROGRESS_BAR_PREFIX)) + { + // check if a file is required to be uploaded + if (fileRequired && !item.hasUploadedFiles()) + { + return STATUS_NO_FILES_ERROR; + } + else + { + return STATUS_COMPLETE; + } + } + + // POLICIES FORM MANAGEMENT + int result = editBitstreamPolicies(request, context, subInfo, buttonPressed); + if(result != -1) return result; + + // --------------------------------------------- + // Step #1: Check if this was just a request to + // edit file information. + // (or canceled editing information) + // --------------------------------------------- + // check if we're already editing a specific bitstream + if (request.getParameter("bitstream_id") != null) + { + if (buttonPressed.equals(CANCEL_EDIT_BUTTON)) + { + // canceled an edit bitstream request + subInfo.setBitstream(null); + + // this flag will just return us to the normal upload screen + return STATUS_EDIT_COMPLETE; + } + else + { + // load info for bitstream we are editing + Bitstream b = Bitstream.find(context, Integer.parseInt(request + .getParameter("bitstream_id"))); + + // save bitstream to submission info + subInfo.setBitstream(b); + } + } + else if (buttonPressed.startsWith("submit_edit_")) + { + // get ID of bitstream that was requested for editing + String bitstreamID = buttonPressed.substring("submit_edit_" + .length()); + + Bitstream b = Bitstream + .find(context, Integer.parseInt(bitstreamID)); + + // save bitstream to submission info + subInfo.setBitstream(b); + + // return appropriate status flag to say we are now editing the + // bitstream + return STATUS_EDIT_BITSTREAM; + } + + // --------------------------------------------- + // Step #2: Process any remove file request(s) + // --------------------------------------------- + // Remove-selected requests come from Manakin + if (buttonPressed.equalsIgnoreCase("submit_remove_selected")) + { + // this is a remove multiple request! + + if (request.getParameter("remove") != null) + { + // get all files to be removed + String[] removeIDs = request.getParameterValues("remove"); + + // remove each file in the list + for (int i = 0; i < removeIDs.length; i++) + { + int id = Integer.parseInt(removeIDs[i]); + + int status = processRemoveFile(context, item, id); + + // if error occurred, return immediately + if (status != STATUS_COMPLETE) + { + return status; + } + } + + // remove current bitstream from Submission Info + subInfo.setBitstream(null); + } + } + else if (buttonPressed.startsWith("submit_remove_")) + { + // A single file "remove" button must have been pressed + + int id = Integer.parseInt(buttonPressed.substring(14)); + int status = processRemoveFile(context, item, id); + + // if error occurred, return immediately + if (status != STATUS_COMPLETE) + { + return status; + } + + // remove current bitstream from Submission Info + subInfo.setBitstream(null); + } + + // ------------------------------------------------- + // Step #3: Check for a change in file description + // ------------------------------------------------- + String fileDescription = request.getParameter("description"); + + if (fileDescription != null && fileDescription.length() > 0) + { + // save this file description + int status = processSaveFileDescription(context, request, response, + subInfo); + + // if error occurred, return immediately + if (status != STATUS_COMPLETE) + { + return status; + } + } + + // ------------------------------------------ + // Step #4: Check for a file format change + // (if user had to manually specify format) + // ------------------------------------------ + int formatTypeID = Util.getIntParameter(request, "format"); + String formatDesc = request.getParameter("format_description"); + + // if a format id or description was found, then save this format! + if (formatTypeID >= 0 + || (formatDesc != null && formatDesc.length() > 0)) + { + // save this specified format + int status = processSaveFileFormat(context, request, response, + subInfo); + + // if error occurred, return immediately + if (status != STATUS_COMPLETE) + { + return status; + } + } + + + // execute only if comes from EditBitstreamStep + if(buttonPressed.equals("submit_save")){ + processAccessFields(context, request, subInfo, subInfo.getBitstream()); + } + + + // --------------------------------------------------- + // Step #5: Check if primary bitstream has changed + // ------------------------------------------------- + if (request.getParameter("primary_bitstream_id") != null) + { + Bundle[] bundles = item.getBundles("ORIGINAL"); + if (bundles.length > 0) + { + bundles[0].setPrimaryBitstreamID(Integer.valueOf(request + .getParameter("primary_bitstream_id")).intValue()); + bundles[0].update(); + } + } + + // --------------------------------------------------- + // Step #6: Determine if there is an error because no + // files have been uploaded. + // --------------------------------------------------- + //check if a file is required to be uploaded + if (fileRequired && !item.hasUploadedFiles()) + { + return STATUS_NO_FILES_ERROR; + } + return STATUS_COMPLETE; + } + + + + /** + * Retrieves the number of pages that this "step" extends over. This method + * is used to build the progress bar. + *
+ * This method may just return 1 for most steps (since most steps consist of + * a single page). But, it should return a number greater than 1 for any + * "step" which spans across a number of HTML pages. For example, the + * configurable "Describe" step (configured using input-forms.xml) overrides + * this method to return the number of pages that are defined by its + * configuration file. + *
+ * Steps which are non-interactive (i.e. they do not display an interface to
+ * the user) should return a value of 1, so that they are only processed
+ * once!
+ *
+ * @param request
+ * The HTTP Request
+ * @param subInfo
+ * The current submission information object
+ *
+ * @return the number of pages in this step
+ */
+ public int getNumberOfPages(HttpServletRequest request,
+ SubmissionInfo subInfo) throws ServletException
+ {
+ // Despite using many JSPs, this step only appears
+ // ONCE in the Progress Bar, so it's only ONE page
+ return 1;
+ }
+
+ // ****************************************************************
+ // ****************************************************************
+ // METHODS FOR UPLOADING FILES (and associated information)
+ // ****************************************************************
+ // ****************************************************************
+
+ /**
+ * Remove a file from an item
+ *
+ * @param context
+ * current DSpace context
+ * @param item
+ * Item where file should be removed from
+ * @param bitstreamID
+ * The id of bitstream representing the file to remove
+ * @return Status or error flag which will be processed by
+ * UI-related code! (if STATUS_COMPLETE or 0 is returned,
+ * no errors occurred!)
+ */
+ protected int processRemoveFile(Context context, Item item, int bitstreamID)
+ throws IOException, SQLException, AuthorizeException
+ {
+ Bitstream bitstream;
+
+ // Try to find bitstream
+ try
+ {
+ bitstream = Bitstream.find(context, bitstreamID);
+ }
+ catch (NumberFormatException nfe)
+ {
+ bitstream = null;
+ }
+
+ if (bitstream == null)
+ {
+ // Invalid or mangled bitstream ID
+ // throw an error and return immediately
+ return STATUS_INTEGRITY_ERROR;
+ }
+
+ // remove bitstream from bundle..
+ // delete bundle if it's now empty
+ Bundle[] bundles = bitstream.getBundles();
+
+ bundles[0].removeBitstream(bitstream);
+
+ Bitstream[] bitstreams = bundles[0].getBitstreams();
+
+ // remove bundle if it's now empty
+ if (bitstreams.length < 1)
+ {
+ item.removeBundle(bundles[0]);
+ item.update();
+ }
+
+ // no errors occurred
+ return STATUS_COMPLETE;
+ }
+
+ /**
+ * Process the upload of a new file!
+ *
+ * @param context
+ * current DSpace context
+ * @param request
+ * current servlet request object
+ * @param response
+ * current servlet response object
+ * @param subInfo
+ * submission info object
+ *
+ * @return Status or error flag which will be processed by
+ * UI-related code! (if STATUS_COMPLETE or 0 is returned,
+ * no errors occurred!)
+ */
+ protected int processUploadFile(Context context, HttpServletRequest request,
+ HttpServletResponse response, SubmissionInfo subInfo)
+ throws ServletException, IOException, SQLException,
+ AuthorizeException
+ {
+ boolean formatKnown = true;
+ boolean fileOK = false;
+ BitstreamFormat bf = null;
+ Bitstream b = null;
+
+ //NOTE: File should already be uploaded.
+ //Manakin does this automatically via Cocoon.
+ //For JSP-UI, the SubmissionController.uploadFiles() does the actual upload
+
+ Enumeration attNames = request.getAttributeNames();
+
+ //loop through our request attributes
+ while(attNames.hasMoreElements())
+ {
+ String attr = (String) attNames.nextElement();
+
+ //if this ends with "-path", this attribute
+ //represents a newly uploaded file
+ if(attr.endsWith("-path"))
+ {
+ //strip off the -path to get the actual parameter
+ //that the file was uploaded as
+ String param = attr.replace("-path", "");
+
+ // Load the file's path and input stream and description
+ String filePath = (String) request.getAttribute(param + "-path");
+ InputStream fileInputStream = (InputStream) request.getAttribute(param + "-inputstream");
+
+ //attempt to get description from attribute first, then direct from a parameter
+ String fileDescription = (String) request.getAttribute(param + "-description");
+ if(fileDescription==null ||fileDescription.length()==0)
+ {
+ request.getParameter("description");
+ }
+
+ // if information wasn't passed by User Interface, we had a problem
+ // with the upload
+ if (filePath == null || fileInputStream == null)
+ {
+ return STATUS_UPLOAD_ERROR;
+ }
+
+ if (subInfo == null)
+ {
+ // In any event, if we don't have the submission info, the request
+ // was malformed
+ return STATUS_INTEGRITY_ERROR;
+ }
+
+
+ // Create the bitstream
+ Item item = subInfo.getSubmissionItem().getItem();
+
+ // do we already have a bundle?
+ Bundle[] bundles = item.getBundles("ORIGINAL");
+
+ if (bundles.length < 1)
+ {
+ // set bundle's name to ORIGINAL
+ b = item.createSingleBitstream(fileInputStream, "ORIGINAL");
+ }
+ else
+ {
+ // we have a bundle already, just add bitstream
+ b = bundles[0].createBitstream(fileInputStream);
+ }
+
+ // Strip all but the last filename. It would be nice
+ // to know which OS the file came from.
+ String noPath = filePath;
+
+ while (noPath.indexOf('/') > -1)
+ {
+ noPath = noPath.substring(noPath.indexOf('/') + 1);
+ }
+
+ while (noPath.indexOf('\\') > -1)
+ {
+ noPath = noPath.substring(noPath.indexOf('\\') + 1);
+ }
+
+ b.setName(noPath);
+ b.setSource(filePath);
+ b.setDescription(fileDescription);
+
+ // Identify the format
+ bf = FormatIdentifier.guessFormat(context, b);
+ b.setFormat(bf);
+
+ // Update to DB
+ b.update();
+ item.update();
+
+
+ processAccessFields(context, request, subInfo, b);
+
+
+ // commit all changes to database
+ context.commit();
+
+
+ if ((bf != null) && (bf.isInternal()))
+ {
+ log.warn("Attempt to upload file format marked as internal system use only");
+ backoutBitstream(subInfo, b, item);
+ return STATUS_UPLOAD_ERROR;
+ }
+
+ // Check for virus
+ if (ConfigurationManager.getBooleanProperty("submission-curation", "virus-scan"))
+ {
+ Curator curator = new Curator();
+ curator.addTask("vscan").curate(item);
+ int status = curator.getStatus("vscan");
+ if (status == Curator.CURATE_ERROR)
+ {
+ backoutBitstream(subInfo, b, item);
+ return STATUS_VIRUS_CHECKER_UNAVAILABLE;
+ }
+ else if (status == Curator.CURATE_FAIL)
+ {
+ backoutBitstream(subInfo, b, item);
+ return STATUS_CONTAINS_VIRUS;
+ }
+ }
+
+ // If we got this far then everything is more or less ok.
+
+ // Comment - not sure if this is the right place for a commit here
+ // but I'm not brave enough to remove it - Robin.
+ context.commit();
+
+ // save this bitstream to the submission info, as the
+ // bitstream we're currently working with
+ subInfo.setBitstream(b);
+
+ //if format was not identified
+ if (bf == null)
+ {
+ return STATUS_UNKNOWN_FORMAT;
+ }
+
+ }//end if attribute ends with "-path"
+ }//end while
+
+
+ return STATUS_COMPLETE;
+
+
+ }
+
+ private void processAccessFields(Context context, HttpServletRequest request, SubmissionInfo subInfo, Bitstream b) throws SQLException, AuthorizeException {
+ // ResourcePolicy Management
+ boolean isAdvancedFormEnabled= ConfigurationManager.getBooleanProperty("xmlui.submission.restrictstep.enableAdvancedForm", false);
+ // if it is a simple form we should create the policy for Anonymous
+ // if Anonymous does not have right on this collection, create policies for any other groups with
+ // DEFAULT_ITEM_READ specified.
+ if(!isAdvancedFormEnabled){
+ Date startDate = null;
+ try {
+ startDate = DateUtils.parseDate(request.getParameter("embargo_until_date"), new String[]{"yyyy-MM-dd", "yyyy-MM", "yyyy"});
+ } catch (Exception e) {
+ //Ignore start date already null
+ }
+ String reason = request.getParameter("reason");
+ AuthorizeManager.generateAutomaticPolicies(context, startDate, reason, b, (Collection) HandleManager.resolveToObject(context, subInfo.getCollectionHandle()));
+ }
+ }
+
+
+ /*
+ If we created a new Bitstream but now realised there is a problem then remove it.
+ */
+ private void backoutBitstream(SubmissionInfo subInfo, Bitstream b, Item item) throws SQLException, AuthorizeException, IOException
+ {
+ // remove bitstream from bundle..
+ // delete bundle if it's now empty
+ Bundle[] bnd = b.getBundles();
+
+ bnd[0].removeBitstream(b);
+
+ Bitstream[] bitstreams = bnd[0].getBitstreams();
+
+ // remove bundle if it's now empty
+ if (bitstreams.length < 1)
+ {
+ item.removeBundle(bnd[0]);
+ item.update();
+ }
+
+ subInfo.setBitstream(null);
+ }
+
+ /**
+ * Process input from get file type page
+ *
+ * @param context
+ * current DSpace context
+ * @param request
+ * current servlet request object
+ * @param response
+ * current servlet response object
+ * @param subInfo
+ * submission info object
+ *
+ * @return Status or error flag which will be processed by
+ * UI-related code! (if STATUS_COMPLETE or 0 is returned,
+ * no errors occurred!)
+ */
+ protected int processSaveFileFormat(Context context,
+ HttpServletRequest request, HttpServletResponse response,
+ SubmissionInfo subInfo) throws ServletException, IOException,
+ SQLException, AuthorizeException
+ {
+ if (subInfo.getBitstream() != null)
+ {
+ // Did the user select a format?
+ int typeID = Util.getIntParameter(request, "format");
+
+ BitstreamFormat format = BitstreamFormat.find(context, typeID);
+
+ if (format != null)
+ {
+ subInfo.getBitstream().setFormat(format);
+ }
+ else
+ {
+ String userDesc = request.getParameter("format_description");
+
+ subInfo.getBitstream().setUserFormatDescription(userDesc);
+ }
+
+ // update database
+ subInfo.getBitstream().update();
+ }
+ else
+ {
+ return STATUS_INTEGRITY_ERROR;
+ }
+
+ return STATUS_COMPLETE;
+ }
+
+ /**
+ * Process input from the "change file description" page
+ *
+ * @param context
+ * current DSpace context
+ * @param request
+ * current servlet request object
+ * @param response
+ * current servlet response object
+ * @param subInfo
+ * submission info object
+ *
+ * @return Status or error flag which will be processed by
+ * UI-related code! (if STATUS_COMPLETE or 0 is returned,
+ * no errors occurred!)
+ */
+ protected int processSaveFileDescription(Context context,
+ HttpServletRequest request, HttpServletResponse response,
+ SubmissionInfo subInfo) throws ServletException, IOException,
+ SQLException, AuthorizeException
+ {
+ if (subInfo.getBitstream() != null)
+ {
+ subInfo.getBitstream().setDescription(
+ request.getParameter("description"));
+ subInfo.getBitstream().update();
+
+ context.commit();
+ }
+ else
+ {
+ return STATUS_INTEGRITY_ERROR;
+ }
+
+ return STATUS_COMPLETE;
+ }
+
+ private int editBitstreamPolicies(HttpServletRequest request, Context context, SubmissionInfo subInfo, String buttonPressed)
+ throws SQLException, AuthorizeException {
+
+ // FORM: EditBitstreamPolicies SELECTED OPERATION: Return
+ if (buttonPressed.equals("bitstream_list_submit_return")){
+ return STATUS_COMPLETE;
+ }
+ // FORM: UploadStep SELECTED OPERATION: go to EditBitstreamPolicies
+ else if (buttonPressed.startsWith("submit_editPolicy_")){
+ String bitstreamID = buttonPressed.substring("submit_editPolicy_".length());
+ Bitstream b = Bitstream.find(context, Integer.parseInt(bitstreamID));
+ subInfo.setBitstream(b);
+ return STATUS_EDIT_POLICIES;
+ }
+ // FORM: EditBitstreamPolicies SELECTED OPERATION: Add New Policy.
+ else if (buttonPressed.startsWith(AccessStep.FORM_ACCESS_BUTTON_ADD)){
+ Bitstream b = Bitstream.find(context, Integer.parseInt(request.getParameter("bitstream_id")));
+ subInfo.setBitstream(b);
+
+ int result=-1;
+ if( (result = AccessStep.checkForm(request))!=0){
+ return result;
+ }
+ Date dateStartDate = AccessStep.getEmbargoUntil(request);
+ String reason = request.getParameter("reason");
+ String name = request.getParameter("name");
+
+ int groupID = 0;
+ if(request.getParameter("group_id")!=null){
+ try{
+ groupID=Integer.parseInt(request.getParameter("group_id"));
+ }catch (NumberFormatException nfe){
+ return STATUS_EDIT_POLICIES_ERROR_SELECT_GROUP;
+ }
+ }
+ ResourcePolicy rp = null;
+ if( (rp= AuthorizeManager.createOrModifyPolicy(null, context, name, groupID, null, dateStartDate, org.dspace.core.Constants.READ, reason, b))==null){
+ return STATUS_EDIT_POLICIES_DUPLICATED_POLICY;
+ }
+ rp.update();
+ context.commit();
+ return STATUS_EDIT_POLICIES;
+ }
+ // FORM: EditBitstreamPolicies SELECTED OPERATION: go to EditPolicyForm
+ else if(org.dspace.submit.step.AccessStep.wasEditPolicyPressed(context, buttonPressed, subInfo)){
+ Bitstream b = Bitstream.find(context, Integer.parseInt(request.getParameter("bitstream_id")));
+ subInfo.setBitstream(b);
+ return org.dspace.submit.step.AccessStep.STATUS_EDIT_POLICY;
+ }
+ // FORM: EditPolicy SELECTED OPERATION: Save or Cancel.
+ else if(org.dspace.submit.step.AccessStep.comeFromEditPolicy(request)) {
+ Bitstream b = Bitstream.find(context, Integer.parseInt(request.getParameter("bitstream_id")));
+ subInfo.setBitstream(b);
+ String reason = request.getParameter("reason");
+ String name = request.getParameter("name");
+
+ int groupID = 0;
+ if(request.getParameter("group_id")!=null){
+ try{
+ groupID=Integer.parseInt(request.getParameter("group_id"));
+ }catch (NumberFormatException nfe){
+ return STATUS_EDIT_POLICIES_ERROR_SELECT_GROUP;
+ }
+ }
+ if(org.dspace.submit.step.AccessStep.saveOrCancelEditPolicy(context, request,
+ subInfo, buttonPressed, b, name, groupID, reason)==org.dspace.submit.step.AccessStep.EDIT_POLICY_STATUS_DUPLICATED_POLICY)
+ return STATUS_EDIT_POLICY_DUPLICATED_POLICY;
+
+ return STATUS_EDIT_POLICIES;
+ }
+ // FORM: EditBitstreamPolicies SELECTED OPERATION: Remove Policies
+ if(org.dspace.submit.step.AccessStep.wasRemovePolicyPressed(buttonPressed)){
+ Bitstream b = Bitstream.find(context, Integer.parseInt(request.getParameter("bitstream_id")));
+ subInfo.setBitstream(b);
+ org.dspace.submit.step.AccessStep.removePolicy(context, buttonPressed);
+ context.commit();
+ return STATUS_EDIT_POLICIES;
+ }
+ return -1;
+ }
+}
diff --git a/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/FlowAuthorizationUtils.java b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/FlowAuthorizationUtils.java
index 9e581edfba..e4881765b9 100644
--- a/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/FlowAuthorizationUtils.java
+++ b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/FlowAuthorizationUtils.java
@@ -8,20 +8,19 @@
package org.dspace.app.xmlui.aspect.administrative;
import java.sql.SQLException;
+import java.text.ParseException;
+import java.util.Date;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
import org.dspace.app.util.AuthorizeUtil;
import org.dspace.app.xmlui.wing.Message;
import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.AuthorizeManager;
import org.dspace.authorize.PolicySet;
import org.dspace.authorize.ResourcePolicy;
-import org.dspace.content.Bitstream;
-import org.dspace.content.Bundle;
-import org.dspace.content.Collection;
-import org.dspace.content.Community;
-import org.dspace.content.DSpaceObject;
-import org.dspace.content.Item;
+import org.dspace.content.*;
import org.dspace.core.Context;
import org.dspace.eperson.Group;
import org.dspace.handle.HandleManager;
@@ -113,7 +112,8 @@ public class FlowAuthorizationUtils {
* @param actionID The ID of the action (dependent on the objectType) to be associated with this policy
* @return A process result's object.
*/
- public static FlowResult processEditPolicy(Context context, int objectType, int objectID, int policyID, int groupID, int actionID) throws SQLException, AuthorizeException
+ public static FlowResult processEditPolicy(Context context, int objectType, int objectID, int policyID, int groupID, int actionID,
+ String name, String description, String startDateParam, String endDateParam) throws SQLException, AuthorizeException
{
FlowResult result = new FlowResult();
boolean added = false;
@@ -136,9 +136,72 @@ public class FlowAuthorizationUtils {
result.setContinue(false);
result.addError("group_id");
return result;
- }
-
- /* If the policy doesn't exist, cretae a new one and set its parent resource */
+ }
+
+
+ // check dates
+ Date startDate = null;
+ Date endDate = null;
+
+ // 05/01/2012 valid date
+ if(StringUtils.isNotBlank(startDateParam)){
+
+ try {
+ startDate = DateUtils.parseDate(startDateParam, new String[]{"yyyy-MM-dd", "yyyy-MM", "yyyy"});
+ } catch (ParseException e) {
+ startDate = null;
+ }
+ if(startDate==null){
+ result.setContinue(false);
+ result.addError("startDate");
+ return result;
+ }
+ }
+
+ if(StringUtils.isNotBlank(endDateParam)){
+ try {
+ endDate = DateUtils.parseDate(endDateParam, new String[]{"yyyy-MM-dd", "yyyy-MM", "yyyy"});
+ } catch (ParseException e) {
+ endDate = null;
+ }
+
+ if(endDate==null){
+ result.setContinue(false);
+ result.addError("endDate");
+ return result;
+ }
+ }
+
+ if(endDate!=null && startDate!=null){
+ if(startDate.after(endDate)){
+ result.setContinue(false);
+ result.addError("startDateGreaterThenEndDate");
+ return result;
+ }
+ }
+ // end check dates
+
+ // check if a similar policy is already in place
+ if(policy==null){
+ if(AuthorizeManager.isAnIdenticalPolicyAlreadyInPlace(context, objectType, objectID, groupID, actionID, -1)){
+ result.setContinue(false);
+ result.addError("duplicatedPolicy");
+ return result;
+ }
+ }
+ else{
+ if(AuthorizeManager.isAnIdenticalPolicyAlreadyInPlace(context, objectType, objectID, groupID, actionID, policy.getID())){
+ result.setContinue(false);
+ result.addError("duplicatedPolicy");
+ return result;
+ }
+ }
+
+
+
+
+
+ /* If the policy doesn't exist, create a new one and set its parent resource */
DSpaceObject policyParent = null;
if (policy == null)
{
@@ -178,6 +241,7 @@ public class FlowAuthorizationUtils {
}
policy = ResourcePolicy.create(context);
policy.setResource(policyParent);
+ policy.setRpType(ResourcePolicy.TYPE_CUSTOM);
added = true;
}
@@ -186,6 +250,17 @@ public class FlowAuthorizationUtils {
// modify the policy
policy.setAction(actionID);
policy.setGroup(group);
+
+ policy.setRpName(name);
+ policy.setRpDescription(description);
+
+ if(endDate!=null) policy.setEndDate(endDate);
+ else policy.setEndDate(null);
+
+
+ if(startDate!=null) policy.setStartDate(startDate);
+ else policy.setStartDate(null);
+
// propagate the changes to the logo, which is treated on the same level as the parent object
Bitstream logo = null;
@@ -227,9 +302,11 @@ public class FlowAuthorizationUtils {
return result;
}
-
-
- /**
+
+
+
+
+ /**
* Delete the policies specified by the policyIDs parameter. This assumes that the
* deletion has been confirmed.
*
@@ -268,23 +345,79 @@ public class FlowAuthorizationUtils {
* @return A process result's object.
*/
public static FlowResult processAdvancedPolicyAdd(Context context, String[] groupIDs, int actionID,
- int resourceID, String [] collectionIDs) throws NumberFormatException, SQLException, AuthorizeException
+ int resourceID, String [] collectionIDs, String name, String description, String startDateParam, String endDateParam) throws NumberFormatException, SQLException, AuthorizeException
{
AuthorizeUtil.requireAdminRole(context);
FlowResult result = new FlowResult();
+
+
+ if(groupIDs==null){
+ result.setContinue(false);
+ result.addError("groupIDs");
+ return result;
+ }
+
+ if(collectionIDs==null){
+ result.setContinue(false);
+ result.addError("collectionIDs");
+ return result;
+ }
+
+ // check dates
+ Date startDate = null;
+ Date endDate = null;
+
+ // 05/01/2012 valid date
+ if(StringUtils.isNotBlank(startDateParam)){
+ try {
+ startDate = DateUtils.parseDate(startDateParam, new String[]{"yyyy-MM-dd", "yyyy-MM", "yyyy"});
+ } catch (ParseException e) {
+ startDate = null;
+ }
+ if(startDate==null){
+ result.setContinue(false);
+ result.addError("startDate");
+ return result;
+ }
+ }
+
+ if(StringUtils.isNotBlank(endDateParam)){
+ try {
+ endDate = DateUtils.parseDate(endDateParam, new String[]{"yyyy-MM-dd", "yyyy-MM", "yyyy"});
+ } catch (ParseException e) {
+ endDate = null;
+ }
+ if(endDate==null){
+ result.setContinue(false);
+ result.addError("endDate");
+ return result;
+ }
+ }
+
+ if(endDate!=null && startDate!=null){
+ if(startDate.after(endDate)){
+ result.setContinue(false);
+ result.addError("startDateGreaterThenEndDate");
+ return result;
+ }
+ }
+ // end check dates
+
+
+
for (String groupID : groupIDs)
{
for (String collectionID : collectionIDs)
{
PolicySet.setPolicies(context, Constants.COLLECTION, Integer.valueOf(collectionID),
- resourceID, actionID, Integer.valueOf(groupID), false, false);
+ resourceID, actionID, Integer.valueOf(groupID), false, false, name, description, startDate, endDate);
// if it's a bitstream, do it to the bundle too
if (resourceID == Constants.BITSTREAM)
{
PolicySet.setPolicies(context, Constants.COLLECTION, Integer.valueOf(collectionID),
- Constants.BUNDLE, actionID, Integer.valueOf(groupID), false, false);
+ Constants.BUNDLE, actionID, Integer.valueOf(groupID), false, false, name, description, startDate, endDate);
}
}
}
@@ -331,5 +464,4 @@ public class FlowAuthorizationUtils {
return result;
}
-
-}
+}
\ No newline at end of file
diff --git a/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/FlowItemUtils.java b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/FlowItemUtils.java
index 6386a5ffbc..4835f6d907 100644
--- a/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/FlowItemUtils.java
+++ b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/FlowItemUtils.java
@@ -11,10 +11,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Date;
import java.util.Enumeration;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.servlet.multipart.Part;
+import org.apache.commons.lang.time.DateUtils;
import org.dspace.app.util.Util;
import org.dspace.app.xmlui.utils.UIException;
import org.dspace.app.xmlui.wing.Message;
@@ -35,6 +37,9 @@ import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.curate.Curator;
import org.dspace.handle.HandleManager;
+import org.dspace.submit.step.AccessStep;
+
+import javax.servlet.http.HttpServletRequest;
/**
* Utility methods to processes actions on Groups. These methods are used
@@ -50,6 +55,8 @@ public class FlowItemUtils
private static final Message T_metadata_updated = new Message("default","The Item's metadata was successfully updated.");
private static final Message T_metadata_added = new Message("default","New metadata was added.");
private static final Message T_item_withdrawn = new Message("default","The item has been withdrawn.");
+ private static final Message T_item_public = new Message("default","The item is now public.");
+ private static final Message T_item_private = new Message("default","The item is now private.");
private static final Message T_item_reinstated = new Message("default","The item has been reinstated.");
private static final Message T_item_moved = new Message("default","The item has been moved.");
private static final Message T_item_move_destination_not_found = new Message("default","The selected destination collection could not be found.");
@@ -310,8 +317,61 @@ public class FlowItemUtils
return result;
}
-
-
+
+
+ /**
+ * Make the specified item Private, this method assumes that the action has been confirmed.
+ *
+ * @param context The DSpace context
+ * @param itemID The id of the to-be-withdrawn item.
+ * @return A result object
+ */
+ public static FlowResult processPrivateItem(Context context, int itemID) throws SQLException, AuthorizeException, IOException
+ {
+ FlowResult result = new FlowResult();
+ result.setContinue(false);
+
+ Item item = Item.find(context, itemID);
+ item.setDiscoverable(false);
+ // private item is withdrawn as well
+ item.withdraw();
+ item.update();
+ context.commit();
+
+ result.setContinue(true);
+ result.setOutcome(true);
+ result.setMessage(T_item_private);
+
+ return result;
+ }
+
+ /**
+ * Make the specified item Private, this method assumes that the action has been confirmed.
+ *
+ * @param context The DSpace context
+ * @param itemID The id of the to-be-withdrawn item.
+ * @return A result object
+ */
+ public static FlowResult processPublicItem(Context context, int itemID) throws SQLException, AuthorizeException, IOException
+ {
+ FlowResult result = new FlowResult();
+ result.setContinue(false);
+
+ Item item = Item.find(context, itemID);
+ item.setDiscoverable(true);
+ // since private Items are withdrawn they are reinstated during "make it public" process
+ item.reinstate();
+ item.update();
+ context.commit();
+
+ result.setContinue(true);
+ result.setOutcome(true);
+ result.setMessage(T_item_public);
+
+ return result;
+ }
+
+
/**
* Move the specified item to another collection.
*
@@ -516,6 +576,8 @@ public class FlowItemUtils
// Update to DB
bitstream.update();
item.update();
+
+ processAccessFields(context, request, item.getOwningCollection(), bitstream);
context.commit();
@@ -531,6 +593,21 @@ public class FlowItemUtils
}
return result;
}
+
+ private static void processAccessFields(Context context, HttpServletRequest request, Collection collection, Bitstream b) throws SQLException, AuthorizeException {
+
+ // if it is a simple form we should create the policy for Anonymous
+ // if Anonymous does not have right on this collection, create policies for any other groups with
+ // DEFAULT_ITEM_READ specified.
+ Date startDate = null;
+ try {
+ startDate = DateUtils.parseDate(request.getParameter("embargo_until_date"), new String[]{"yyyy-MM-dd", "yyyy-MM", "yyyy"});
+ } catch (Exception e) {
+ //Ignore, start date is already null
+ }
+ String reason = request.getParameter("reason");
+ AuthorizeManager.generateAutomaticPolicies(context, startDate, reason, b, collection);
+ }
/**
@@ -544,7 +621,8 @@ public class FlowItemUtils
* @param userFormat Any user supplied formats.
* @return A flow result object.
*/
- public static FlowResult processEditBitstream(Context context, int itemID, int bitstreamID, String bitstreamName, String primary, String description, int formatID, String userFormat) throws SQLException, AuthorizeException
+ public static FlowResult processEditBitstream(Context context, int itemID, int bitstreamID, String bitstreamName,
+ String primary, String description, int formatID, String userFormat, Request request) throws SQLException, AuthorizeException
{
FlowResult result = new FlowResult();
result.setContinue(false);
@@ -617,8 +695,11 @@ public class FlowItemUtils
// Save our changes
bitstream.update();
context.commit();
-
- result.setContinue(true);
+
+ processAccessFields(context, request, ((Item)bitstream.getParentObject()).getOwningCollection(), bitstream);
+
+
+ result.setContinue(true);
result.setOutcome(true);
result.setMessage(T_bitstream_updated);
diff --git a/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/Navigation.java b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/Navigation.java
index a20b05a3d2..70e47526a9 100644
--- a/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/Navigation.java
+++ b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/Navigation.java
@@ -72,6 +72,7 @@ public class Navigation extends AbstractDSpaceTransformer implements CacheablePr
private static final Message T_administrative_format = message("xmlui.administrative.Navigation.administrative_format");
private static final Message T_administrative_items = message("xmlui.administrative.Navigation.administrative_items");
private static final Message T_administrative_withdrawn = message("xmlui.administrative.Navigation.administrative_withdrawn");
+ private static final Message T_administrative_private = message("xmlui.administrative.Navigation.administrative_private");
private static final Message T_administrative_control_panel = message("xmlui.administrative.Navigation.administrative_control_panel");
private static final Message T_administrative_curation = message("xmlui.administrative.Navigation.administrative_curation");
@@ -291,7 +292,8 @@ public class Navigation extends AbstractDSpaceTransformer implements CacheablePr
registries.addItemXref(contextPath+"/admin/format-registry",T_administrative_format);
admin.addItemXref(contextPath+"/admin/item", T_administrative_items);
- admin.addItemXref(contextPath+"/admin/withdrawn", T_administrative_withdrawn);
+ admin.addItemXref(contextPath+"/admin/withdrawn", T_administrative_withdrawn);
+ admin.addItemXref(contextPath+"/admin/private", T_administrative_private);
admin.addItemXref(contextPath+"/admin/panel", T_administrative_control_panel);
admin.addItemXref(contextPath+"/statistics", T_statistics);
admin.addItemXref(contextPath+ "/admin/metadataimport", T_administrative_import_metadata);
diff --git a/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/PrivateItems.java b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/PrivateItems.java
new file mode 100644
index 0000000000..01471cce6e
--- /dev/null
+++ b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/administrative/PrivateItems.java
@@ -0,0 +1,852 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.xmlui.aspect.administrative;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cocoon.caching.CacheableProcessingComponent;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.util.HashUtil;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.log4j.Logger;
+import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
+import org.dspace.app.xmlui.utils.ContextUtil;
+import org.dspace.app.xmlui.utils.DSpaceValidity;
+import org.dspace.app.xmlui.utils.HandleUtil;
+import org.dspace.app.xmlui.utils.RequestUtils;
+import org.dspace.app.xmlui.utils.UIException;
+import org.dspace.app.xmlui.wing.Message;
+import org.dspace.app.xmlui.wing.WingException;
+import org.dspace.app.xmlui.wing.element.Body;
+import org.dspace.app.xmlui.wing.element.Cell;
+import org.dspace.app.xmlui.wing.element.Division;
+import org.dspace.app.xmlui.wing.element.List;
+import org.dspace.app.xmlui.wing.element.PageMeta;
+import org.dspace.app.xmlui.wing.element.Para;
+import org.dspace.app.xmlui.wing.element.ReferenceSet;
+import org.dspace.app.xmlui.wing.element.Row;
+import org.dspace.app.xmlui.wing.element.Select;
+import org.dspace.app.xmlui.wing.element.Table;
+import org.dspace.authorize.AuthorizeException;
+import org.dspace.browse.BrowseEngine;
+import org.dspace.browse.BrowseException;
+import org.dspace.browse.BrowseIndex;
+import org.dspace.browse.BrowseInfo;
+import org.dspace.browse.BrowseItem;
+import org.dspace.browse.BrowserScope;
+import org.dspace.sort.SortOption;
+import org.dspace.sort.SortException;
+import org.dspace.content.Collection;
+import org.dspace.content.Community;
+import org.dspace.content.DCDate;
+import org.dspace.content.DSpaceObject;
+import org.dspace.core.ConfigurationManager;
+import org.dspace.core.Context;
+import org.xml.sax.SAXException;
+
+/**
+ * Implements all the browse functionality (browse by title, subject, authors,
+ * etc.) The types of browse available are configurable by the implementor. See
+ * dspace.cfg and documentation for instructions on how to configure.
+ *
+ * @author Graham Triggs
+ */
+public class PrivateItems extends AbstractDSpaceTransformer implements
+ CacheableProcessingComponent
+{
+ private static final Logger log = Logger.getLogger(PrivateItems.class);
+
+ /**
+ * Static Messages for common text
+ */
+ private static final Message T_dspace_home = message("xmlui.general.dspace_home");
+
+ private static final Message T_go = message("xmlui.general.go");
+
+ private static final Message T_update = message("xmlui.general.update");
+
+ private static final Message T_choose_month = message("xmlui.ArtifactBrowser.ConfigurableBrowse.general.choose_month");
+
+ private static final Message T_choose_year = message("xmlui.ArtifactBrowser.ConfigurableBrowse.general.choose_year");
+
+ private static final Message T_jump_year = message("xmlui.ArtifactBrowser.ConfigurableBrowse.general.jump_year");
+
+ private static final Message T_jump_year_help = message("xmlui.ArtifactBrowser.ConfigurableBrowse.general.jump_year_help");
+
+ private static final Message T_jump_select = message("xmlui.ArtifactBrowser.ConfigurableBrowse.general.jump_select");
+
+ private static final Message T_starts_with = message("xmlui.ArtifactBrowser.ConfigurableBrowse.general.starts_with");
+
+ private static final Message T_starts_with_help = message("xmlui.ArtifactBrowser.ConfigurableBrowse.general.starts_with_help");
+
+ private static final Message T_sort_by = message("xmlui.ArtifactBrowser.ConfigurableBrowse.general.sort_by");
+
+ private static final Message T_order = message("xmlui.ArtifactBrowser.ConfigurableBrowse.general.order");
+
+ private static final Message T_rpp = message("xmlui.ArtifactBrowser.ConfigurableBrowse.general.rpp");
+
+ private static final Message T_order_asc = message("xmlui.ArtifactBrowser.ConfigurableBrowse.order.asc");
+
+ private static final Message T_order_desc = message("xmlui.ArtifactBrowser.ConfigurableBrowse.order.desc");
+
+ private static final String PRIVATE_URL_BASE = "private";
+
+ /**
+ * These variables dictate when the drop down list of years is to break from
+ * 1 year increments, to 5 year increments, to 10 year increments, and
+ * finally to stop.
+ */
+ private static final int ONE_YEAR_LIMIT = 10;
+
+ private static final int FIVE_YEAR_LIMIT = 30;
+
+ private static final int TEN_YEAR_LIMIT = 100;
+
+ /** Cached validity object */
+ private SourceValidity validity;
+
+ /** Cached UI parameters, results and messages */
+ private BrowseParams userParams;
+
+ private BrowseInfo browseInfo;
+
+ private Message titleMessage = null;
+ private Message trailMessage = null;
+
+ public Serializable getKey()
+ {
+ try
+ {
+ BrowseParams params = getUserParams();
+
+ String key = params.getKey();
+
+ if (key != null)
+ {
+ DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
+ if (dso != null)
+ {
+ key += "-" + dso.getHandle();
+ }
+
+ return HashUtil.hash(key);
+ }
+ }
+ catch (SQLException e)
+ {
+ log.error("Database error", e);
+ }
+ catch (UIException e)
+ {
+ log.error("UI error", e);
+ }
+
+ return "0";
+ }
+
+ public SourceValidity getValidity()
+ {
+ if (validity == null)
+ {
+ try
+ {
+ DSpaceValidity newValidity = new DSpaceValidity();
+ DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
+
+ if (dso != null)
+ {
+ newValidity.add(dso);
+ }
+
+ BrowseInfo info = getBrowseInfo();
+
+ // Are we browsing items, or unique metadata?
+ if (isItemBrowse(info))
+ {
+ // Add the browse items to the validity
+ for (BrowseItem item : (java.util.List
+ * The information to review should be tacked onto the passed in
+ * List object.
+ *
+ * NOTE: To remain consistent across all Steps, you should first
+ * add a sub-List object (with this step's name as the heading),
+ * by using a call to reviewList.addList(). This sublist is
+ * the list you return from this method!
+ *
+ * @param reviewList
+ * The List to which all reviewable information should be added
+ * @return
+ * The new sub-List object created by this step, which contains
+ * all the reviewable information. If this step has nothing to
+ * review, then return null!
+ */
+ public List addReviewSection(List reviewList) throws SAXException,
+ WingException, UIException, SQLException, IOException,
+ AuthorizeException
+ {
+ // License step doesn't require reviewing
+ return null;
+ }
+}
diff --git a/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/submission/submit/AccessStepUtil.java b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/submission/submit/AccessStepUtil.java
new file mode 100644
index 0000000000..b4b3422504
--- /dev/null
+++ b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/submission/submit/AccessStepUtil.java
@@ -0,0 +1,281 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.xmlui.aspect.submission.submit;
+
+import org.apache.commons.lang.time.DateFormatUtils;
+import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
+import org.dspace.app.xmlui.wing.Message;
+import org.dspace.authorize.AuthorizeManager;
+import org.dspace.authorize.ResourcePolicy;
+import org.dspace.content.*;
+import org.dspace.core.Context;
+import org.dspace.app.xmlui.wing.WingException;
+import org.dspace.app.xmlui.wing.element.*;
+import org.dspace.core.ConfigurationManager;
+import org.dspace.eperson.Group;
+import org.dspace.submit.step.AccessStep;
+import org.dspace.submit.step.UploadWithEmbargoStep;
+
+import java.sql.SQLException;
+
+
+/**
+ * This class represents a query which the discovery backend can use
+ *
+ * @author Fabio Bolognesi (fabio at atmire dot com)
+ * @author Mark Diggory (markd at atmire dot com)
+ * @author Ben Bosman (ben at atmire dot com)
+ *
+ */
+public class AccessStepUtil extends AbstractDSpaceTransformer {
+ Context context=null;
+
+ protected static final Message T_name =message("xmlui.Submission.submit.AccessStep.name");
+ protected static final Message T_reason = message("xmlui.Submission.submit.AccessStep.reason");
+ protected static final Message T_radios_embargo = message("xmlui.Submission.submit.AccessStep.embargo_visible");
+ protected static final Message T_groups = message("xmlui.Submission.submit.AccessStep.list_assigned_groups");
+ protected static final Message T_item_will_be_visible = message("xmlui.Submission.submit.AccessStep.open_access");
+ protected static final Message T_item_embargoed = message("xmlui.Submission.submit.AccessStep.embargo");
+ protected static final Message T_error_date_format = message("xmlui.Submission.submit.AccessStep.error_format_date");
+ protected static final Message T_error_missing_date = message("xmlui.Submission.submit.AccessStep.error_missing_date");
+ protected static final Message T_error_duplicated_policy = message("xmlui.Submission.submit.AccessStep.error_duplicated_policy");
+
+ // Policies Table
+ protected static final Message T_head_policies_table = message("xmlui.Submission.submit.AccessStep.table_policies");
+ protected static final Message T_column0 =message("xmlui.Submission.submit.AccessStep.column0");
+ protected static final Message T_column1 =message("xmlui.Submission.submit.AccessStep.column1");
+ protected static final Message T_column2 =message("xmlui.Submission.submit.AccessStep.column2");
+ protected static final Message T_column3 =message("xmlui.Submission.submit.AccessStep.column3");
+ protected static final Message T_column4 =message("xmlui.Submission.submit.AccessStep.column4");
+ protected static final Message T_table_submit_edit =message("xmlui.Submission.submit.AccessStep.table_edit_button");
+ protected static final Message T_table_submit_delete =message("xmlui.Submission.submit.AccessStep.table_delete_button");
+
+ private static final Message T_label_date_help =
+ message("xmlui.administrative.authorization.AccessStep.label_date_help");
+
+ public static final int RADIO_OPEN_ACCESS_ITEM_VISIBLE=0;
+ public static final int RADIO_OPEN_ACCESS_ITEM_EMBARGOED=1;
+
+ //public static final int CB_EMBARGOED=10;
+ private String globalReason = null;
+
+ private boolean isAdvancedFormEnabled=false;
+
+ public AccessStepUtil(Context c){
+ isAdvancedFormEnabled=ConfigurationManager.getBooleanProperty("xmlui.submission.restrictstep.enableAdvancedForm", false);
+ context=c;
+ }
+
+ public void addName(String name_, List form, int errorFlag) throws WingException {
+ if(isAdvancedFormEnabled){
+ Text name = form.addItem().addText("name");
+ name.setLabel(T_name);
+
+ if(name_!=null && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE)
+ name.setValue(name_);
+ }
+ }
+
+ public void addReason(String reason_, List form, int errorFlag) throws WingException {
+ TextArea reason = form.addItem("reason", null).addTextArea("reason");
+ reason.setLabel(T_reason);
+
+ if(!isAdvancedFormEnabled){
+ if(globalReason!=null)
+ reason.setValue(globalReason);
+ }
+ else{
+ if(reason_!=null && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE)
+ reason.setValue(reason_);
+ }
+ }
+
+ public void addListGroups(String groupID, List form, int errorFlag, Collection owningCollection) throws WingException, SQLException {
+
+ if(isAdvancedFormEnabled){
+ // currently set group
+ form.addLabel(T_groups);
+ Select groupSelect = form.addItem().addSelect("group_id");
+ groupSelect.setMultiple(false);
+
+ Group[] loadedGroups = null;
+
+ // retrieve groups
+ String name = ConfigurationManager.getProperty("xmlui.submission.restrictstep.groups");
+ if(name!=null){
+ Group uiGroup = Group.findByName(context, name);
+ if(uiGroup!=null)
+ loadedGroups= uiGroup.getMemberGroups();
+ }
+ if(loadedGroups==null || loadedGroups.length ==0){
+ loadedGroups = Group.findAll(context, Group.NAME);
+ }
+
+ // if no group selected for default set anonymous
+ if(groupID==null || groupID.equals("")) groupID= "0";
+ for (Group group : loadedGroups){
+ if(Integer.parseInt(groupID) == group.getID() && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE){
+ groupSelect.addOption(true, group.getID(), group.getName());
+
+ }else{
+ groupSelect.addOption(false, group.getID(), group.getName());
+ }
+ }
+
+ if (errorFlag == AccessStep.STATUS_DUPLICATED_POLICY || errorFlag == AccessStep.EDIT_POLICY_STATUS_DUPLICATED_POLICY
+ || errorFlag == UploadWithEmbargoStep.STATUS_EDIT_POLICIES_DUPLICATED_POLICY || errorFlag == UploadWithEmbargoStep.STATUS_EDIT_POLICY_DUPLICATED_POLICY){
+ groupSelect.addError(T_error_duplicated_policy);
+ }
+ }
+
+ }
+
+ public void addAccessRadios(String selectedRadio, String date, List form, int errorFlag, DSpaceObject dso) throws WingException, SQLException {
+
+ if(!isAdvancedFormEnabled){
+ addEmbargoDateSimpleForm(dso, form, errorFlag);
+ }
+ else{
+
+ org.dspace.app.xmlui.wing.element.Item radiosAndDate = form.addItem();
+ Radio openAccessRadios = radiosAndDate.addRadio("open_access_radios");
+ openAccessRadios.setLabel(T_radios_embargo);
+ if(selectedRadio!=null && Integer.parseInt(selectedRadio)==RADIO_OPEN_ACCESS_ITEM_EMBARGOED
+ && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE){
+ openAccessRadios.addOption(RADIO_OPEN_ACCESS_ITEM_VISIBLE, T_item_will_be_visible);
+ openAccessRadios.addOption(true, RADIO_OPEN_ACCESS_ITEM_EMBARGOED, T_item_embargoed);
+ }
+ else{
+ openAccessRadios.addOption(true, RADIO_OPEN_ACCESS_ITEM_VISIBLE, T_item_will_be_visible);
+ openAccessRadios.addOption(RADIO_OPEN_ACCESS_ITEM_EMBARGOED, T_item_embargoed);
+ }
+
+ // Date
+ Text startDate = radiosAndDate.addText("embargo_until_date");
+ startDate.setLabel("");
+ startDate.setHelp(T_label_date_help);
+ if (errorFlag == org.dspace.submit.step.AccessStep.STATUS_ERROR_FORMAT_DATE){
+ startDate.addError(T_error_date_format);
+ }
+ else if (errorFlag == org.dspace.submit.step.AccessStep.STATUS_ERROR_MISSING_DATE){
+ startDate.addError(T_error_missing_date);
+ }
+
+ if(date!=null && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE){
+ startDate.setValue(date);
+ }
+ }
+ }
+
+ public void addEmbargoDateSimpleForm(DSpaceObject dso, List form, int errorFlag) throws SQLException, WingException {
+
+ String date=null;
+
+ if(dso!=null){
+ java.util.List
+ * The information to review should be tacked onto the passed in
+ * List object.
+ *
+ * NOTE: To remain consistent across all Steps, you should first
+ * add a sub-List object (with this step's name as the heading),
+ * by using a call to reviewList.addList(). This sublist is
+ * the list you return from this method!
+ *
+ * @param reviewList
+ * The List to which all reviewable information should be added
+ * @return
+ * The new sub-List object created by this step, which contains
+ * all the reviewable information. If this step has nothing to
+ * review, then return null!
+ */
+ public List addReviewSection(List reviewList) throws SAXException,
+ WingException, UIException, SQLException, IOException,
+ AuthorizeException
+ {
+ // Create a new list section for this step (and set its heading)
+ List uploadSection = reviewList.addList("submit-review-" + this.stepAndPage, List.TYPE_FORM);
+ uploadSection.setHead(T_head);
+
+ // Review all uploaded files
+ Item item = submission.getItem();
+ Bundle[] bundles = item.getBundles("ORIGINAL");
+ Bitstream[] bitstreams = new Bitstream[0];
+ if (bundles.length > 0)
+ {
+ bitstreams = bundles[0].getBitstreams();
+ }
+
+ for (Bitstream bitstream : bitstreams)
+ {
+ BitstreamFormat bitstreamFormat = bitstream.getFormat();
+
+ String name = bitstream.getName();
+ String url = makeBitstreamLink(item, bitstream);
+ String format = bitstreamFormat.getShortDescription();
+ Message support = ReviewStep.T_unknown;
+ if (bitstreamFormat.getSupportLevel() == BitstreamFormat.KNOWN)
+ {
+ support = T_known;
+ }
+ else if (bitstreamFormat.getSupportLevel() == BitstreamFormat.SUPPORTED)
+ {
+ support = T_supported;
+ }
+
+ org.dspace.app.xmlui.wing.element.Item file = uploadSection.addItem();
+ file.addXref(url,name);
+ file.addContent(" - "+ format + " ");
+ file.addContent(support);
+
+ }
+
+ // return this new "upload" section
+ return uploadSection;
+ }
+
+ /**
+ * Returns canonical link to a bitstream in the item.
+ *
+ * @param item The DSpace Item that the bitstream is part of
+ * @param bitstream The bitstream to link to
+ * @returns a String link to the bitstream
+ */
+ private String makeBitstreamLink(Item item, Bitstream bitstream)
+ {
+ String name = bitstream.getName();
+ StringBuilder result = new StringBuilder(contextPath);
+ result.append("/bitstream/item/").append(String.valueOf(item.getID()));
+ // append name although it isn't strictly necessary
+ try
+ {
+ if (name != null)
+ {
+ result.append("/").append(Util.encodeBitstreamName(name, "UTF-8"));
+ }
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ // just ignore it, we don't have to have a pretty
+ // name on the end of the url because the sequence id will
+ // locate it. However it means that links in this file might
+ // not work....
+ }
+ result.append("?sequence=").append(String.valueOf(bitstream.getSequenceID()));
+ return result.toString();
+ }
+}
+
diff --git a/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/Administrative/administrative.js b/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/Administrative/administrative.js
index 7d592a4f13..2481210582 100644
--- a/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/Administrative/administrative.js
+++ b/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/Administrative/administrative.js
@@ -1483,6 +1483,16 @@ function doEditItemStatus(itemID)
// Confirm the reinstatiation of the item
result = doReinstateItem(itemID);
}
+ else if (cocoon.request.get("submit_private"))
+ {
+
+ result = doPrivateItem(itemID);
+ }
+ else if (cocoon.request.get("submit_public"))
+ {
+
+ result = doPublicItem(itemID);
+ }
else if (cocoon.request.get("submit_move"))
{
// Move this item somewhere else
@@ -1683,6 +1693,35 @@ function doReinstateItem(itemID)
return null;
}
+
+function doPrivateItem(itemID)
+{
+ assertEditItem(itemID);
+ sendPageAndWait("admin/item/private",{"itemID":itemID});
+
+ if (cocoon.request.get("submit_confirm"))
+ {
+ var result = FlowItemUtils.processPrivateItem(getDSContext(),itemID);
+ return result;
+ }
+ return null;
+}
+
+function doPublicItem(itemID)
+{
+ assertEditItem(itemID);
+ sendPageAndWait("admin/item/public",{"itemID":itemID});
+
+ if (cocoon.request.get("submit_confirm"))
+ {
+ var result = FlowItemUtils.processPublicItem(getDSContext(),itemID);
+ return result;
+ }
+ return null;
+}
+
+
+
/*
* Move this item to another collection
*/
@@ -1776,7 +1815,7 @@ function doEditBitstream(itemID, bitstreamID)
var userFormat = cocoon.request.get("user_format");
var bitstreamName = cocoon.request.get("bitstreamName");
- result = FlowItemUtils.processEditBitstream(getDSContext(),itemID,bitstreamID,bitstreamName,primary,description,formatID,userFormat);
+ result = FlowItemUtils.processEditBitstream(getDSContext(),itemID,bitstreamID,bitstreamName,primary,description,formatID,userFormat, cocoon.request);
}
} while (result == null || ! result.getContinue())
@@ -2159,20 +2198,39 @@ function doAdvancedAuthorization()
{
assertAdministrator();
var result;
-
+ var groupIDs;
+ var actionID;
+ var resourceID;
+ var collectionIDs;
+ var name;
+ var description;
+ var startDate;
+ var endDate;
do {
- sendPageAndWait("admin/authorize/advanced",{},result);
+
+ if(groupIDs!=null)
+ cocoon.request.setAttribute("groupIDs", groupIDs);
+ if(collectionIDs!=null)
+ cocoon.request.setAttribute("collectionIDs", collectionIDs);
+
+ sendPageAndWait("admin/authorize/advanced",{"resource_id":resourceID,"action_id":actionID,"name":name,
+ "description":description, "startDate":startDate, "endDate":endDate},result);
assertAdministrator();
result = null;
// For all of the selected groups...
- var groupIDs = cocoon.request.getParameterValues("group_id");
+ groupIDs = cocoon.request.getParameterValues("group_id");
// ...grant the ability to perform the following action...
- var actionID = cocoon.request.get("action_id");
+ actionID = cocoon.request.get("action_id");
// ...for all following object types...
- var resourceID = cocoon.request.get("resource_id");
+ resourceID = cocoon.request.get("resource_id");
// ...across the following collections.
- var collectionIDs = cocoon.request.getParameterValues("collection_id");
+ collectionIDs = cocoon.request.getParameterValues("collection_id");
+
+ name = cocoon.request.get("name");
+ description = cocoon.request.get("description");
+ startDate = cocoon.request.get("start_date");
+ endDate = cocoon.request.get("end_date");
if (cocoon.request.get("submit_return"))
{
@@ -2180,7 +2238,7 @@ function doAdvancedAuthorization()
}
else if (cocoon.request.get("submit_add"))
{
- result = FlowAuthorizationUtils.processAdvancedPolicyAdd(getDSContext(),groupIDs,actionID,resourceID,collectionIDs);
+ result = FlowAuthorizationUtils.processAdvancedPolicyAdd(getDSContext(),groupIDs,actionID,resourceID,collectionIDs, name, description, startDate, endDate);
}
else if (cocoon.request.get("submit_remove_all"))
{
@@ -2205,12 +2263,17 @@ function doEditPolicy(objectType,objectID,policyID)
var groupID;
var actionID;
var page = 0;
+ var name;
+ var description;
+ var startDate;
+ var endDate;
do {
/* The page receives parameters for the type and ID of the DSpace object that the policy is assciated with, the
* policy ID, the group search query (if a search was performed), the ID of the currently associated group, the
* current action and the currently viewed page (if a search returned more than one page of results) */
- sendPageAndWait("admin/authorize/edit",{"objectType":objectType,"objectID":objectID,"policyID":policyID,"query":query,"groupID":groupID,"actionID":actionID,"page":page},result);
+ sendPageAndWait("admin/authorize/edit",{"objectType":objectType,"objectID":objectID,"policyID":policyID,"query":query,"groupID":groupID,"actionID":actionID,"page":page,
+ "name":name, "description":description, "startDate":startDate, "endDate":endDate},result);
// authorize check moved to FlowAuthorizationUtils.processEditPolicy
// assertAdministrator();
result = null;
@@ -2247,10 +2310,12 @@ function doEditPolicy(objectType,objectID,policyID)
groupID = cocoon.request.get("group_id");
if (groupID == null) groupID = -1;
- actionID = cocoon.request.get("action_id");
- if (actionID == null) actionID = -1;
+ name = cocoon.request.get("name");
+ description = cocoon.request.get("description");
+ startDate = cocoon.request.get("start_date");
+ endDate = cocoon.request.get("end_date");
- result = FlowAuthorizationUtils.processEditPolicy(getDSContext(),objectType,objectID,policyID,groupID,actionID);
+ result = FlowAuthorizationUtils.processEditPolicy(getDSContext(),objectType,objectID,policyID,groupID,actionID, name, description, startDate, endDate);
}
else if (cocoon.request.get("submit_cancel"))
{
diff --git a/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/Administrative/sitemap.xmap b/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/Administrative/sitemap.xmap
index dcbc1f7915..376f9cc036 100644
--- a/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/Administrative/sitemap.xmap
+++ b/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/Administrative/sitemap.xmap
@@ -91,6 +91,7 @@ to administer DSpace.
a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0},m&&f.extend(p,{position:"absolute",left:-1e3,top:-1e3});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g]),d!==b&&(i[f.camelCase(c)]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[f.camelCase(c)]||i[c]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=w:v&&c!=="className"&&(f.nodeName(a,"form")||u.test(c))&&(i=v)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}},value:{get:function(a,b){if(v&&f.nodeName(a,"button"))return v.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(v&&f.nodeName(a,"button"))return v.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),w={get:function(a,c){return f.prop(a,c)?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(f.attrFix=f.propFix,v=f.attrHooks.name=f.attrHooks.title=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var x=/\.(.*)$/,y=/^(?:textarea|input|select)$/i,z=/\./g,A=/ /g,B=/[^\w\s.|`]/g,C=function(a){return a.replace(B,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=D;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=D);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),C).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;jt ","
"],tr:[2,"","
"],td:[3,"
"],col:[2,"","
"],area:[1,""],_default:[0,"",""]};bf.optgroup=bf.option,bf.tbody=bf.tfoot=bf.colgroup=bf.caption=bf.thead,bf.th=bf.td,f.support.htmlSerialize||(bf._default=[1,"div"&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&Y.test(k)&&o.insertBefore(b.createTextNode(Y.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i