mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
103818 Add boolean parameters to ItemServiceImpl methodds to decide whether to override read policies
This commit is contained in:
@@ -925,20 +925,11 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
|
||||
@Override
|
||||
public void inheritCollectionDefaultPolicies(Context context, Item item, Collection collection,
|
||||
boolean overrideItemReadPolicies)
|
||||
boolean replaceReadRPWithCollectionRP)
|
||||
throws SQLException, AuthorizeException {
|
||||
|
||||
// If collection has READ policies, remove the item's READ policies.
|
||||
if (overrideItemReadPolicies) {
|
||||
List<ResourcePolicy> defaultCollectionPolicies = authorizeService
|
||||
.getPoliciesActionFilter(context, collection, Constants.DEFAULT_ITEM_READ);
|
||||
if (!defaultCollectionPolicies.isEmpty()) {
|
||||
authorizeService.removePoliciesActionFilter(context, item, Constants.READ);
|
||||
}
|
||||
}
|
||||
|
||||
adjustItemPolicies(context, item, collection);
|
||||
adjustBundleBitstreamPolicies(context, item, collection);
|
||||
adjustItemPolicies(context, item, collection, replaceReadRPWithCollectionRP);
|
||||
adjustBundleBitstreamPolicies(context, item, collection, replaceReadRPWithCollectionRP);
|
||||
|
||||
log.debug(LogHelper.getHeader(context, "item_inheritCollectionDefaultPolicies",
|
||||
"item_id=" + item.getID()));
|
||||
@@ -947,6 +938,13 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
@Override
|
||||
public void adjustBundleBitstreamPolicies(Context context, Item item, Collection collection)
|
||||
throws SQLException, AuthorizeException {
|
||||
adjustBundleBitstreamPolicies(context, item, collection, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustBundleBitstreamPolicies(Context context, Item item, Collection collection,
|
||||
boolean replaceReadRPWithCollectionRP)
|
||||
throws SQLException, AuthorizeException {
|
||||
// Bundles should inherit from DEFAULT_ITEM_READ so that if the item is readable, the files
|
||||
// can be listed (even if they are themselves not readable as per DEFAULT_BITSTREAM_READ or other
|
||||
// policies or embargos applied
|
||||
@@ -969,6 +967,10 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
// Remove bundles
|
||||
List<Bundle> bunds = item.getBundles();
|
||||
for (Bundle mybundle : bunds) {
|
||||
// If collection has default READ policies, remove the bitstream's READ policies.
|
||||
if (replaceReadRPWithCollectionRP && defaultCollectionBitstreamPolicies.size() > 0) {
|
||||
authorizeService.removePoliciesActionFilter(context, item, Constants.READ);
|
||||
}
|
||||
|
||||
// if come from InstallItem: remove all submission/workflow policies
|
||||
authorizeService.removeAllPoliciesByDSOAndType(context, mybundle, ResourcePolicy.TYPE_SUBMISSION);
|
||||
@@ -985,7 +987,14 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustBitstreamPolicies(Context context, Item item, Collection collection , Bitstream bitstream)
|
||||
public void adjustBitstreamPolicies(Context context, Item item, Collection collection, Bitstream bitstream)
|
||||
throws SQLException, AuthorizeException {
|
||||
adjustBitstreamPolicies(context, item, collection, bitstream, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustBitstreamPolicies(Context context, Item item, Collection collection , Bitstream bitstream,
|
||||
boolean replaceReadRPWithCollectionRP)
|
||||
throws SQLException, AuthorizeException {
|
||||
List<ResourcePolicy> defaultCollectionPolicies = authorizeService
|
||||
.getPoliciesActionFilter(context, collection, Constants.DEFAULT_BITSTREAM_READ);
|
||||
@@ -1015,10 +1024,22 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
@Override
|
||||
public void adjustItemPolicies(Context context, Item item, Collection collection)
|
||||
throws SQLException, AuthorizeException {
|
||||
adjustItemPolicies(context, item, collection, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustItemPolicies(Context context, Item item, Collection collection,
|
||||
boolean replaceReadRPWithCollectionRP)
|
||||
throws SQLException, AuthorizeException {
|
||||
// read collection's default READ policies
|
||||
List<ResourcePolicy> defaultCollectionPolicies = authorizeService
|
||||
.getPoliciesActionFilter(context, collection, Constants.DEFAULT_ITEM_READ);
|
||||
|
||||
// If collection has defaultREAD policies, remove the item's READ policies.
|
||||
if (replaceReadRPWithCollectionRP && defaultCollectionPolicies.size() > 0) {
|
||||
authorizeService.removePoliciesActionFilter(context, item, Constants.READ);
|
||||
}
|
||||
|
||||
// MUST have default policies
|
||||
if (defaultCollectionPolicies.size() < 1) {
|
||||
throw new SQLException("Collection " + collection.getID()
|
||||
|
@@ -527,6 +527,28 @@ public interface ItemService
|
||||
public void adjustBundleBitstreamPolicies(Context context, Item item, Collection collection)
|
||||
throws SQLException, AuthorizeException;
|
||||
|
||||
/**
|
||||
* Adjust the Bundle and Bitstream policies to reflect what have been defined
|
||||
* during the submission/workflow. The temporary SUBMISSION and WORKFLOW
|
||||
* policies are removed and the policies defined at the item and collection
|
||||
* level are copied and inherited as appropriate. Custom selected Item policies
|
||||
* are copied to the bundle/bitstream only if no explicit custom policies were
|
||||
* already applied to the bundle/bitstream. Collection's policies are inherited
|
||||
* if there are no other policies defined or if the append mode is defined by
|
||||
* the configuration via the core.authorization.installitem.inheritance-read.append-mode property
|
||||
*
|
||||
* @param context DSpace context object
|
||||
* @param item Item to adjust policies on
|
||||
* @param collection Collection
|
||||
* @param replaceReadRPWithCollectionRP if true, all read policies on the item are replaced (but only if the
|
||||
* collection has a default read policy)
|
||||
* @throws SQLException If database error
|
||||
* @throws AuthorizeException If authorization error
|
||||
*/
|
||||
public void adjustBundleBitstreamPolicies(Context context, Item item, Collection collection,
|
||||
boolean replaceReadRPWithCollectionRP)
|
||||
throws SQLException, AuthorizeException;
|
||||
|
||||
/**
|
||||
* Adjust the Bitstream policies to reflect what have been defined
|
||||
* during the submission/workflow. The temporary SUBMISSION and WORKFLOW
|
||||
@@ -547,6 +569,29 @@ public interface ItemService
|
||||
public void adjustBitstreamPolicies(Context context, Item item, Collection collection, Bitstream bitstream)
|
||||
throws SQLException, AuthorizeException;
|
||||
|
||||
/**
|
||||
* Adjust the Bitstream policies to reflect what have been defined
|
||||
* during the submission/workflow. The temporary SUBMISSION and WORKFLOW
|
||||
* policies are removed and the policies defined at the item and collection
|
||||
* level are copied and inherited as appropriate. Custom selected Item policies
|
||||
* are copied to the bitstream only if no explicit custom policies were
|
||||
* already applied to the bitstream. Collection's policies are inherited
|
||||
* if there are no other policies defined or if the append mode is defined by
|
||||
* the configuration via the core.authorization.installitem.inheritance-read.append-mode property
|
||||
*
|
||||
* @param context DSpace context object
|
||||
* @param item Item to adjust policies on
|
||||
* @param collection Collection
|
||||
* @param bitstream Bitstream to adjust policies on
|
||||
* @param replaceReadRPWithCollectionRP If true, all read policies on the bitstream are replaced (but only if the
|
||||
* collection has a default read policy)
|
||||
* @throws SQLException If database error
|
||||
* @throws AuthorizeException If authorization error
|
||||
*/
|
||||
public void adjustBitstreamPolicies(Context context, Item item, Collection collection, Bitstream bitstream,
|
||||
boolean replaceReadRPWithCollectionRP)
|
||||
throws SQLException, AuthorizeException;
|
||||
|
||||
|
||||
/**
|
||||
* Adjust the Item's policies to reflect what have been defined during the
|
||||
@@ -565,6 +610,26 @@ public interface ItemService
|
||||
public void adjustItemPolicies(Context context, Item item, Collection collection)
|
||||
throws SQLException, AuthorizeException;
|
||||
|
||||
/**
|
||||
* Adjust the Item's policies to reflect what have been defined during the
|
||||
* submission/workflow. The temporary SUBMISSION and WORKFLOW policies are
|
||||
* removed and the default policies defined at the collection level are
|
||||
* inherited as appropriate. Collection's policies are inherited if there are no
|
||||
* other policies defined or if the append mode is defined by the configuration
|
||||
* via the core.authorization.installitem.inheritance-read.append-mode property
|
||||
*
|
||||
* @param context DSpace context object
|
||||
* @param item Item to adjust policies on
|
||||
* @param collection Collection
|
||||
* @param replaceReadRPWithCollectionRP If true, all read policies on the item are replaced (but only if the
|
||||
* collection has a default read policy)
|
||||
* @throws SQLException If database error
|
||||
* @throws AuthorizeException If authorization error
|
||||
*/
|
||||
public void adjustItemPolicies(Context context, Item item, Collection collection,
|
||||
boolean replaceReadRPWithCollectionRP)
|
||||
throws SQLException, AuthorizeException;
|
||||
|
||||
/**
|
||||
* Moves the item from one collection to another one
|
||||
*
|
||||
@@ -810,24 +875,24 @@ public interface ItemService
|
||||
int countWithdrawnItems(Context context) throws SQLException;
|
||||
|
||||
/**
|
||||
* finds all items for which the current user has editing rights
|
||||
* @param context DSpace context object
|
||||
* @param offset page offset
|
||||
* @param limit page size limit
|
||||
* @return list of items for which the current user has editing rights
|
||||
* @throws SQLException
|
||||
* @throws SearchServiceException
|
||||
*/
|
||||
* finds all items for which the current user has editing rights
|
||||
* @param context DSpace context object
|
||||
* @param offset page offset
|
||||
* @param limit page size limit
|
||||
* @return list of items for which the current user has editing rights
|
||||
* @throws SQLException
|
||||
* @throws SearchServiceException
|
||||
*/
|
||||
public List<Item> findItemsWithEdit(Context context, int offset, int limit)
|
||||
throws SQLException, SearchServiceException;
|
||||
|
||||
/**
|
||||
* counts all items for which the current user has editing rights
|
||||
* @param context DSpace context object
|
||||
* @return list of items for which the current user has editing rights
|
||||
* @throws SQLException
|
||||
* @throws SearchServiceException
|
||||
*/
|
||||
* counts all items for which the current user has editing rights
|
||||
* @param context DSpace context object
|
||||
* @return list of items for which the current user has editing rights
|
||||
* @throws SQLException
|
||||
* @throws SearchServiceException
|
||||
*/
|
||||
public int countItemsWithEdit(Context context) throws SQLException, SearchServiceException;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user