mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 13:03:11 +00:00
[DS-92] Bitstream access rights inheritenc, editing in_archive items - ID: 1993036
git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@3659 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -50,6 +50,7 @@ import java.util.ListIterator;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.authorize.AuthorizeManager;
|
import org.dspace.authorize.AuthorizeManager;
|
||||||
|
import org.dspace.authorize.ResourcePolicy;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.LogManager;
|
import org.dspace.core.LogManager;
|
||||||
@@ -594,4 +595,67 @@ public class Bundle extends DSpaceObject
|
|||||||
{
|
{
|
||||||
return Constants.BUNDLE;
|
return Constants.BUNDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* remove all policies on the bundle and its contents, and replace them with
|
||||||
|
* the DEFAULT_BITSTREAM_READ policies belonging to the collection.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* Collection
|
||||||
|
* @throws java.sql.SQLException
|
||||||
|
* if an SQL error or if no default policies found. It's a bit
|
||||||
|
* draconian, but default policies must be enforced.
|
||||||
|
* @throws AuthorizeException
|
||||||
|
*/
|
||||||
|
public void inheritCollectionDefaultPolicies(Collection c)
|
||||||
|
throws java.sql.SQLException, AuthorizeException
|
||||||
|
{
|
||||||
|
List<ResourcePolicy> policies = AuthorizeManager.getPoliciesActionFilter(ourContext, c,
|
||||||
|
Constants.DEFAULT_BITSTREAM_READ);
|
||||||
|
|
||||||
|
// change the action to just READ
|
||||||
|
// just don't call update on the resourcepolicies!!!
|
||||||
|
Iterator<ResourcePolicy> i = policies.iterator();
|
||||||
|
|
||||||
|
if (!i.hasNext())
|
||||||
|
{
|
||||||
|
throw new java.sql.SQLException("Collection " + c.getID()
|
||||||
|
+ " has no default bitstream READ policies");
|
||||||
|
}
|
||||||
|
|
||||||
|
while (i.hasNext())
|
||||||
|
{
|
||||||
|
ResourcePolicy rp = (ResourcePolicy) i.next();
|
||||||
|
rp.setAction(Constants.READ);
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceAllBitstreamPolicies(policies);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* remove all of the policies for the bundle and bitstream contents and replace
|
||||||
|
* them with a new list of policies
|
||||||
|
*
|
||||||
|
* @param newpolicies -
|
||||||
|
* this will be all of the new policies for the bundle and
|
||||||
|
* bitstream contents
|
||||||
|
* @throws SQLException
|
||||||
|
* @throws AuthorizeException
|
||||||
|
*/
|
||||||
|
public void replaceAllBitstreamPolicies(List<ResourcePolicy> newpolicies)
|
||||||
|
throws SQLException, AuthorizeException
|
||||||
|
{
|
||||||
|
if (bitstreams != null && bitstreams.size() > 0)
|
||||||
|
{
|
||||||
|
for (Bitstream bs : bitstreams)
|
||||||
|
{
|
||||||
|
// change bitstream policies
|
||||||
|
AuthorizeManager.removeAllPolicies(ourContext, bs);
|
||||||
|
AuthorizeManager.addPolicies(ourContext, newpolicies, bs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// change bundle policies
|
||||||
|
AuthorizeManager.removeAllPolicies(ourContext, this);
|
||||||
|
AuthorizeManager.addPolicies(ourContext, newpolicies, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2018,21 +2018,7 @@ public class Item extends DSpaceObject
|
|||||||
for (int i = 0; i < bunds.length; i++)
|
for (int i = 0; i < bunds.length; i++)
|
||||||
{
|
{
|
||||||
Bundle mybundle = bunds[i];
|
Bundle mybundle = bunds[i];
|
||||||
|
mybundle.replaceAllBitstreamPolicies(newpolicies);
|
||||||
Bitstream[] bs = mybundle.getBitstreams();
|
|
||||||
|
|
||||||
for (int j = 0; j < bs.length; j++)
|
|
||||||
{
|
|
||||||
Bitstream mybitstream = bs[j];
|
|
||||||
|
|
||||||
// change bitstream policies
|
|
||||||
AuthorizeManager.removeAllPolicies(ourContext, bs[j]);
|
|
||||||
AuthorizeManager.addPolicies(ourContext, newpolicies, bs[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// change bundle policies
|
|
||||||
AuthorizeManager.removeAllPolicies(ourContext, mybundle);
|
|
||||||
AuthorizeManager.addPolicies(ourContext, newpolicies, mybundle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -684,6 +684,14 @@ public class EditItemServlet extends DSpaceServlet
|
|||||||
{
|
{
|
||||||
// set bundle's name to ORIGINAL
|
// set bundle's name to ORIGINAL
|
||||||
b = item.createSingleBitstream(is, "ORIGINAL");
|
b = item.createSingleBitstream(is, "ORIGINAL");
|
||||||
|
|
||||||
|
// set the permission as defined in the owning collection
|
||||||
|
Collection owningCollection = item.getOwningCollection();
|
||||||
|
if (owningCollection != null)
|
||||||
|
{
|
||||||
|
Bundle bnd = b.getBundles()[0];
|
||||||
|
bnd.inheritCollectionDefaultPolicies(owningCollection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -391,6 +391,14 @@ public class FlowItemUtils
|
|||||||
{
|
{
|
||||||
// set bundle's name to ORIGINAL
|
// set bundle's name to ORIGINAL
|
||||||
bitstream = item.createSingleBitstream(is, bundleName);
|
bitstream = item.createSingleBitstream(is, bundleName);
|
||||||
|
|
||||||
|
// set the permission as defined in the owning collection
|
||||||
|
Collection owningCollection = item.getOwningCollection();
|
||||||
|
if (owningCollection != null)
|
||||||
|
{
|
||||||
|
Bundle bnd = bitstream.getBundles()[0];
|
||||||
|
bnd.inheritCollectionDefaultPolicies(owningCollection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -121,6 +121,7 @@
|
|||||||
- [DS-115] metadata not showed in verify step
|
- [DS-115] metadata not showed in verify step
|
||||||
- [DS-122] Problems with repeatable metadata
|
- [DS-122] Problems with repeatable metadata
|
||||||
- [DS-116] File description not correct
|
- [DS-116] File description not correct
|
||||||
|
- [DS-92] Bitstream access rights inheritenc, editing in_archive items - ID: 1993036
|
||||||
|
|
||||||
(Paulo Jobim)
|
(Paulo Jobim)
|
||||||
- SF Patch [2655052] Authors re-ordered when item edited (xmlui)
|
- SF Patch [2655052] Authors re-ordered when item edited (xmlui)
|
||||||
|
Reference in New Issue
Block a user