added implementation that allows to see withdrawn items to anonynous groups

This commit is contained in:
Mykhaylo
2021-05-04 11:36:11 +02:00
parent c1710cd95d
commit 0f38a8d0c8
2 changed files with 9 additions and 2 deletions

View File

@@ -8,8 +8,10 @@
package org.dspace.app.rest.converter; package org.dspace.app.rest.converter;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Objects;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -73,6 +75,9 @@ public class ItemConverter
List<MetadataValue> fullList = itemService.getMetadata(obj, Item.ANY, Item.ANY, Item.ANY, Item.ANY, true); List<MetadataValue> fullList = itemService.getMetadata(obj, Item.ANY, Item.ANY, Item.ANY, Item.ANY, true);
List<MetadataValue> returnList = new LinkedList<>(); List<MetadataValue> returnList = new LinkedList<>();
try { try {
if (obj.isWithdrawn() && (Objects.isNull(context) || Objects.isNull(context.getCurrentUser()))) {
return new MetadataValueList(new ArrayList<MetadataValue>());
}
if (context != null && authorizeService.isAdmin(context)) { if (context != null && authorizeService.isAdmin(context)) {
return new MetadataValueList(fullList); return new MetadataValueList(fullList);
} }

View File

@@ -89,8 +89,10 @@ public class AuthorizeServicePermissionEvaluatorPlugin extends RestObjectPermiss
// If the item is still inprogress we can process here only the READ permission. // If the item is still inprogress we can process here only the READ permission.
// Other actions need to be evaluated against the wrapper object (workspace or workflow item) // Other actions need to be evaluated against the wrapper object (workspace or workflow item)
if (dSpaceObject instanceof Item) { if (dSpaceObject instanceof Item) {
if (!DSpaceRestPermission.READ.equals(restPermission) if (((Item) dSpaceObject).isWithdrawn()) {
&& !((Item) dSpaceObject).isArchived() && !((Item) dSpaceObject).isWithdrawn()) { return true;
}
if (!DSpaceRestPermission.READ.equals(restPermission) && !((Item) dSpaceObject).isArchived()) {
return false; return false;
} }
} }