mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
[DS-525] Move item - inherit default policies of destination collection
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5829 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -659,9 +659,9 @@ public class Item extends DSpaceObject
|
||||
* value has no language (for example, a date).
|
||||
* @param values
|
||||
* the values to add.
|
||||
* @param authority
|
||||
* @param authorities
|
||||
* the external authority key for this value (or null)
|
||||
* @param confidence
|
||||
* @param confidences
|
||||
* the authority confidence (default 0)
|
||||
*/
|
||||
public void addMetadata(String schema, String element, String qualifier, String lang,
|
||||
@@ -2037,7 +2037,7 @@ public class Item extends DSpaceObject
|
||||
* Return <code>true</code> if <code>other</code> is the same Item as
|
||||
* this object, <code>false</code> otherwise
|
||||
*
|
||||
* @param other
|
||||
* @param obj
|
||||
* object to compare to
|
||||
* @return <code>true</code> if object passed in represents the same item
|
||||
* as this object
|
||||
@@ -2246,6 +2246,9 @@ public class Item extends DSpaceObject
|
||||
}
|
||||
|
||||
replaceAllBitstreamPolicies(policies);
|
||||
|
||||
log.debug(LogManager.getHeader(ourContext, "item_inheritCollectionDefaultPolicies",
|
||||
"item_id=" + getID()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2256,6 +2259,19 @@ public class Item extends DSpaceObject
|
||||
* @throws IOException
|
||||
*/
|
||||
public void move (Collection from, Collection to) throws SQLException, AuthorizeException, IOException
|
||||
{
|
||||
// Use the normal move method, and default to not inherit permissions
|
||||
this.move(from, to, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the item from one collection to another one
|
||||
*
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void move (Collection from, Collection to, boolean inheritDefaultPolicies) throws SQLException, AuthorizeException, IOException
|
||||
{
|
||||
// Check authorisation on the item before that the move occur
|
||||
// otherwise we will need edit permission on the "target collection" to archive our goal
|
||||
@@ -2272,7 +2288,22 @@ public class Item extends DSpaceObject
|
||||
// If we are moving from the owning collection, update that too
|
||||
if (isOwningCollection(from))
|
||||
{
|
||||
// Update the owning collection
|
||||
log.info(LogManager.getHeader(ourContext, "move_item",
|
||||
"item_id=" + getID() + ", from " +
|
||||
"collection_id=" + from.getID() + " to " +
|
||||
"collection_id=" + to.getID()));
|
||||
setOwningCollection(to);
|
||||
|
||||
// If applicable, update the item policies
|
||||
if (inheritDefaultPolicies)
|
||||
{
|
||||
log.info(LogManager.getHeader(ourContext, "move_item",
|
||||
"Updating item with inherited policies"));
|
||||
inheritCollectionDefaultPolicies(to);
|
||||
}
|
||||
|
||||
// Update the item
|
||||
ourContext.turnOffAuthorisationSystem();
|
||||
update();
|
||||
ourContext.restoreAuthSystemState();
|
||||
|
@@ -1256,6 +1256,7 @@ jsp.tools.move-item.collection.from.msg = Collection to
|
||||
jsp.tools.move-item.collection.to.msg = Collection to move to
|
||||
jsp.tools.move-item.item.name.msg = Name of the item to be moved
|
||||
jsp.tools.move-item.title = Moving an item
|
||||
jsp.tools.move-item.inheritpolicies = Inherit default policies of destination collection
|
||||
jsp.tools.upload-bitstream.info = Select the bitstream to upload
|
||||
jsp.tools.upload-bitstream.title = Upload Bitstream
|
||||
jsp.tools.upload-bitstream.upload = Upload
|
||||
|
@@ -325,12 +325,18 @@ public class EditItemServlet extends DSpaceServlet
|
||||
Collection fromCollection = Collection.find(context, UIUtil.getIntParameter(request, "collection_from_id"));
|
||||
Collection toCollection = Collection.find(context, UIUtil.getIntParameter(request, "collection_to_id"));
|
||||
|
||||
Boolean inheritPolicies = false;
|
||||
if (request.getParameter("inheritpolicies") != null)
|
||||
{
|
||||
inheritPolicies = true;
|
||||
}
|
||||
|
||||
if (fromCollection == null || toCollection == null)
|
||||
{
|
||||
throw new ServletException("Missing or incorrect collection IDs for moving item");
|
||||
}
|
||||
|
||||
item.move(fromCollection, toCollection);
|
||||
item.move(fromCollection, toCollection, inheritPolicies);
|
||||
|
||||
showEditForm(context, request, response, item);
|
||||
|
||||
@@ -354,7 +360,7 @@ public class EditItemServlet extends DSpaceServlet
|
||||
/**
|
||||
* Throw an exception if user isn't authorized to edit this item
|
||||
*
|
||||
* @param context
|
||||
* @param c
|
||||
* @param item
|
||||
*/
|
||||
private void checkEditAuthorization(Context c, Item item)
|
||||
|
@@ -106,6 +106,10 @@
|
||||
%>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="standard"><small><strong><fmt:message key="jsp.tools.move-item.inheritpolicies"/></strong></small></td>
|
||||
<td class="standard"><input type="checkbox" name="inheritpolicies" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="standard"></td>
|
||||
|
@@ -346,9 +346,10 @@ public class FlowItemUtils
|
||||
* @param context The DSpace context
|
||||
* @param itemID The id of the to-be-moved item.
|
||||
* @param collectionID The id of the destination collection.
|
||||
* @param inherit Whether to inherit the policies of the destination collection
|
||||
* @return A result object
|
||||
*/
|
||||
public static FlowResult processMoveItem(Context context, int itemID, int collectionID) throws SQLException, AuthorizeException, IOException
|
||||
public static FlowResult processMoveItem(Context context, int itemID, int collectionID, boolean inherit) throws SQLException, AuthorizeException, IOException
|
||||
{
|
||||
FlowResult result = new FlowResult();
|
||||
result.setContinue(false);
|
||||
@@ -357,10 +358,13 @@ public class FlowItemUtils
|
||||
|
||||
if(AuthorizeManager.isAdmin(context, item))
|
||||
{
|
||||
//Add a policy giving this user *explicit* admin permissions on the item itself.
|
||||
//Add an action giving this user *explicit* admin permissions on the item itself.
|
||||
//This ensures that the user will be able to call item.update() even if he/she
|
||||
// moves it to a Collection that he/she doesn't administer.
|
||||
AuthorizeManager.addPolicy(context, item, Constants.ADMIN, context.getCurrentUser());
|
||||
if (item.canEdit())
|
||||
{
|
||||
AuthorizeManager.authorizeAction(context, item, Constants.WRITE);
|
||||
}
|
||||
|
||||
Collection destination = Collection.find(context, collectionID);
|
||||
if (destination == null)
|
||||
@@ -408,6 +412,13 @@ public class FlowItemUtils
|
||||
}
|
||||
|
||||
item.setOwningCollection(destination);
|
||||
|
||||
// Inherit policies of destination collection if required
|
||||
if (inherit)
|
||||
{
|
||||
item.inheritCollectionDefaultPolicies(destination);
|
||||
}
|
||||
|
||||
item.update();
|
||||
context.commit();
|
||||
|
||||
|
@@ -45,6 +45,7 @@ import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
||||
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.CheckBox;
|
||||
import org.dspace.app.xmlui.wing.element.Division;
|
||||
import org.dspace.app.xmlui.wing.element.List;
|
||||
import org.dspace.app.xmlui.wing.element.PageMeta;
|
||||
@@ -73,6 +74,8 @@ public class MoveItemForm extends AbstractDSpaceTransformer {
|
||||
private static final Message T_collection_help = message("xmlui.administrative.item.MoveItemForm.collection_help");
|
||||
private static final Message T_collection_default = message("xmlui.administrative.item.MoveItemForm.collection_default");
|
||||
private static final Message T_submit_move = message("xmlui.administrative.item.MoveItemForm.submit_move");
|
||||
private static final Message T_submit_inherit = message("xmlui.administrative.item.MoveItemForm.inherit_policies");
|
||||
private static final Message T_submit_inherit_help = message("xmlui.administrative.item.MoveItemForm.inherit_policies_help");
|
||||
|
||||
|
||||
public void addPageMeta(PageMeta pageMeta) throws WingException
|
||||
@@ -114,10 +117,19 @@ public class MoveItemForm extends AbstractDSpaceTransformer {
|
||||
{
|
||||
name = name.substring(0, 47) + "...";
|
||||
}
|
||||
|
||||
// Only add the item if it isn't already the owner
|
||||
if (!item.isOwningCollection(collection))
|
||||
{
|
||||
select.addOption(collection.equals(owningCollection), collection.getID(), name);
|
||||
}
|
||||
}
|
||||
|
||||
org.dspace.app.xmlui.wing.element.Item actions = list.addItem();
|
||||
CheckBox inheritPolicies = actions.addCheckBox("inheritPolicies");
|
||||
inheritPolicies.setLabel(T_submit_inherit);
|
||||
inheritPolicies.setHelp(T_submit_inherit_help);
|
||||
inheritPolicies.addOption("inheritPolicies");
|
||||
actions.addButton("submit_move").setValue(T_submit_move);
|
||||
actions.addButton("submit_cancel").setValue(T_submit_cancel);
|
||||
|
||||
|
@@ -1707,12 +1707,20 @@ function doMoveItem(itemID)
|
||||
{
|
||||
var collectionID = cocoon.request.get("collectionID");
|
||||
if (!collectionID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var inherit = false;
|
||||
if (cocoon.request.get("inheritPolicies"))
|
||||
{
|
||||
inherit = true;
|
||||
}
|
||||
|
||||
// Actually move the item
|
||||
assertEditItem(itemID);
|
||||
|
||||
result = FlowItemUtils.processMoveItem(getDSContext(),itemID,collectionID);
|
||||
result = FlowItemUtils.processMoveItem(getDSContext(), itemID, collectionID, inherit);
|
||||
}
|
||||
} while (result == null || !result.getContinue());
|
||||
|
||||
|
@@ -630,6 +630,7 @@ to administer DSpace.
|
||||
<map:transform type="MoveItemForm">
|
||||
<map:parameter name="itemID" value="{flow-attribute:itemID}"/>
|
||||
<map:parameter name="collectionID" value="{flow-attribute:collectionID}"/>
|
||||
<map:parameter name="inheritPolicies" value="{flow-attribute:inheritPolicies}"/>
|
||||
</map:transform>
|
||||
</map:match>
|
||||
|
||||
|
@@ -1289,6 +1289,8 @@
|
||||
<message key="xmlui.administrative.item.MoveItemForm.collection_help">Select the collection you wish to move this item to.</message>
|
||||
<message key="xmlui.administrative.item.MoveItemForm.collection_default">Select a collection...</message>
|
||||
<message key="xmlui.administrative.item.MoveItemForm.submit_move">Move</message>
|
||||
<message key="xmlui.administrative.item.MoveItemForm.inherit_policies">Inherit policies</message>
|
||||
<message key="xmlui.administrative.item.MoveItemForm.inherit_policies_help">Inherit the default policies of the destination collection</message>
|
||||
|
||||
<!-- org.dspace.app.xmlui.administrative.item.EditBitstreamForm -->
|
||||
<message key="xmlui.administrative.item.EditBitstreamForm.title">Edit Bitstream</message>
|
||||
|
@@ -64,6 +64,7 @@
|
||||
|
||||
(Stuart Lewis)
|
||||
- [DS-467] Consider making the JSPUI styles.css.jsp a static file
|
||||
- [DS-525] Move item - inherit default policies of destination collection
|
||||
- [DS-550] Upgrade to latest Google Analytics tracking code
|
||||
- [DS-632] Batch Metadata Import needs to validate metadata fields specified in CSVs
|
||||
- [DS-646] Remove /bin scripts (replaced by 'dspace' command)
|
||||
|
Reference in New Issue
Block a user