mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 22:43:12 +00:00
[CST-5294] FIxed NBEventRestRepositoryIT test
This commit is contained in:
@@ -1017,6 +1017,58 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection retrieveCollectionByEntityType(Context context, Item item, String entityType)
|
||||
throws SQLException {
|
||||
Collection ownCollection = item.getOwningCollection();
|
||||
return retrieveCollectionByEntityType(context, ownCollection.getCommunities(), entityType);
|
||||
}
|
||||
|
||||
private Collection retrieveCollectionByEntityType(Context context, List<Community> communities, String entityType) {
|
||||
|
||||
for (Community community : communities) {
|
||||
Collection collection = retrieveCollectionByCommunityAndEntityType(context, community, entityType);
|
||||
if (collection != null) {
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
||||
for (Community community : communities) {
|
||||
List<Community> parentCommunities = community.getParentCommunities();
|
||||
Collection collection = retrieveCollectionByEntityType(context, parentCommunities, entityType);
|
||||
if (collection != null) {
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
||||
return retrieveCollectionByCommunityAndEntityType(context, null, entityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection retrieveCollectionByCommunityAndEntityType(Context context, Community community,
|
||||
String entityType) {
|
||||
context.turnOffAuthorisationSystem();
|
||||
List<Collection> collections;
|
||||
try {
|
||||
collections = findCollectionsWithSubmit(null, context, community, entityType, 0, 1);
|
||||
} catch (SQLException | SearchServiceException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
context.restoreAuthSystemState();
|
||||
if (collections != null && collections.size() > 0) {
|
||||
return collections.get(0);
|
||||
}
|
||||
if (community != null) {
|
||||
for (Community subCommunity : community.getSubcommunities()) {
|
||||
Collection collection = retrieveCollectionByCommunityAndEntityType(context, subCommunity, entityType);
|
||||
if (collection != null) {
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Collection> findCollectionsWithSubmit(String q, Context context, Community community, String entityType,
|
||||
int offset, int limit) throws SQLException, SearchServiceException {
|
||||
|
Reference in New Issue
Block a user