diff --git a/dspace-api/src/main/java/org/dspace/discovery/ClarinSolrItemsCommunityIndexPlugin.java b/dspace-api/src/main/java/org/dspace/discovery/ClarinSolrItemsCommunityIndexPlugin.java index fe419cb6d2ff..36e60e3af816 100644 --- a/dspace-api/src/main/java/org/dspace/discovery/ClarinSolrItemsCommunityIndexPlugin.java +++ b/dspace-api/src/main/java/org/dspace/discovery/ClarinSolrItemsCommunityIndexPlugin.java @@ -39,7 +39,11 @@ public void additionalIndex(Context context, IndexableObject indexableObject, So Community owningCommunity = clarinItemService.getOwningCommunity(context, item); String communityName = Objects.isNull(owningCommunity) ? " " : owningCommunity.getName(); + // _keyword and _filter because + // they are needed in order to work as a facet and filter. document.addField("items_owning_community", communityName); + document.addField("items_owning_community_keyword", communityName); + document.addField("items_owning_community_filter", communityName); } } } diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/MetadataBitstreamWrapperConverter.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/MetadataBitstreamWrapperConverter.java index 49728da0b899..e42c023f72a5 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/MetadataBitstreamWrapperConverter.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/MetadataBitstreamWrapperConverter.java @@ -10,7 +10,6 @@ import org.dspace.app.rest.model.MetadataBitstreamWrapperRest; import org.dspace.app.rest.model.wrapper.MetadataBitstreamWrapper; import org.dspace.app.rest.projection.Projection; -import org.dspace.util.FileTreeViewGenerator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; @@ -41,8 +40,7 @@ public MetadataBitstreamWrapperRest convert(MetadataBitstreamWrapper modelObject bitstreamWrapperRest.setId(modelObject.getBitstream().getID().toString()); bitstreamWrapperRest.setDescription(modelObject.getDescription()); bitstreamWrapperRest.setChecksum(modelObject.getBitstream().getChecksum()); - bitstreamWrapperRest.setFileSize(FileTreeViewGenerator.humanReadableFileSize( - modelObject.getBitstream().getSizeBytes())); + bitstreamWrapperRest.setFileSize(modelObject.getBitstream().getSizeBytes()); bitstreamWrapperRest.setFileInfo(modelObject.getFileInfo()); bitstreamWrapperRest.setHref(modelObject.getHref()); bitstreamWrapperRest.setFormat(modelObject.getFormat()); diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/MetadataBitstreamWrapperRest.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/MetadataBitstreamWrapperRest.java index 7e3c1c03568e..8e4d60d4bfab 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/MetadataBitstreamWrapperRest.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/MetadataBitstreamWrapperRest.java @@ -23,14 +23,14 @@ public class MetadataBitstreamWrapperRest extends BaseObjectRest { private String name; private String description; - private String fileSize; + private long fileSize; private String checksum; private List fileInfo; private String format; private String href; private boolean canPreview; - public MetadataBitstreamWrapperRest(String name, String description, String fileSize, String checksum, + public MetadataBitstreamWrapperRest(String name, String description, long fileSize, String checksum, List fileInfo, String format, String href, boolean canPreview) { this.name = name; this.description = description; @@ -93,11 +93,11 @@ public void setDescription(String description) { this.description = description; } - public String getFileSize() { + public long getFileSize() { return fileSize; } - public void setFileSize(String fileSize) { + public void setFileSize(long fileSize) { this.fileSize = fileSize; } diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/security/UsageReportRestPermissionEvaluatorPlugin.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/security/UsageReportRestPermissionEvaluatorPlugin.java index 06254d561ace..8e0b57e6791a 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/security/UsageReportRestPermissionEvaluatorPlugin.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/security/UsageReportRestPermissionEvaluatorPlugin.java @@ -18,6 +18,7 @@ import org.dspace.app.rest.utils.DSpaceObjectUtils; import org.dspace.authorize.service.AuthorizeService; import org.dspace.content.DSpaceObject; +import org.dspace.content.Site; import org.dspace.core.Context; import org.dspace.services.ConfigurationService; import org.dspace.services.RequestService; @@ -93,6 +94,15 @@ public boolean hasDSpacePermission(Authentication authentication, Serializable t if (Objects.isNull(dso)) { return true; } + + // Show Site usage reports to anonymous users if the configuration is set to do so + // This Site usage reports are used in the home page and are not sensitive + if (dso instanceof Site) { + if (!configurationService.getBooleanProperty("site.usage-reports.enable.auth.anonymous", + false)) { + return true; + } + } return authorizeService.authorizeActionBoolean(context, dso, restPermission.getDspaceApiActionId()); } catch (SQLException e) { log.error(e.getMessage(), e); diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinDiscoveryRestControllerIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinDiscoveryRestControllerIT.java index 72b12c7962af..460373091d27 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinDiscoveryRestControllerIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinDiscoveryRestControllerIT.java @@ -122,7 +122,8 @@ public void discoverFacetsTestWithoutParameters() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false))) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false))) ); } @@ -1006,9 +1007,11 @@ public void discoverSearchTest() throws Exception { SortOptionMatcher.sortOptionMatcher( "dc.title", DiscoverySortFieldConfiguration.SORT_ORDER.asc.name()), SortOptionMatcher.sortOptionMatcher( - "dc.date.issued", DiscoverySortFieldConfiguration.SORT_ORDER.desc.name()), + "dc.title", DiscoverySortFieldConfiguration.SORT_ORDER.desc.name()), + SortOptionMatcher.sortOptionMatcher( + "dc.date.issued", DiscoverySortFieldConfiguration.SORT_ORDER.asc.name()), SortOptionMatcher.sortOptionMatcher( - "dc.date.accessioned", DiscoverySortFieldConfiguration.SORT_ORDER.desc.name()) + "dc.date.issued", DiscoverySortFieldConfiguration.SORT_ORDER.desc.name()) ))); } @@ -1146,7 +1149,8 @@ public void discoverSearchObjectsTest() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -1287,7 +1291,8 @@ public void discoverSearchObjectsTestHasMoreAuthorFacet() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -1379,7 +1384,8 @@ public void discoverSearchObjectsTestHasMoreSubjectFacet() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -1461,7 +1467,8 @@ public void discoverSearchObjectsTestWithBasicQuery() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -1571,7 +1578,8 @@ public void discoverSearchObjectsTestWithScope() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -1653,7 +1661,8 @@ public void discoverSearchObjectsTestWithDsoType() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))); @@ -1690,7 +1699,8 @@ public void discoverSearchObjectsTestWithDsoType() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))); @@ -1728,7 +1738,8 @@ public void discoverSearchObjectsTestWithDsoType() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))); @@ -1770,7 +1781,8 @@ public void discoverSearchObjectsTestWithDsoType() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))); @@ -1859,7 +1871,8 @@ public void discoverSearchObjectsTestWithDsoTypeAndSort() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //We want to get the sort that's been used as well in the response .andExpect(jsonPath("$.sort", is( @@ -2073,7 +2086,8 @@ public void discoverSearchObjectsTestForPaginationAndNextLinks() throws Exceptio FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), FacetEntryMatcher.hasContentInOriginalBundleFacet(false), - FacetEntryMatcher.entityTypeFacet(false) + FacetEntryMatcher.entityTypeFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -2165,7 +2179,8 @@ public void discoverSearchObjectsTestWithContentInABitstream() throws Exception FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -2257,7 +2272,8 @@ public void discoverSearchObjectsTestForEmbargoedItemsAndPrivateItems() throws E FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -2343,7 +2359,8 @@ public void discoverSearchObjectsTestWithContentInAPrivateBitstream() throws Exc FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -2424,7 +2441,8 @@ public void discoverSearchObjectsTestForScope() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -2511,7 +2529,8 @@ public void discoverSearchObjectsTestForScopeWithPrivateItem() throws Exception FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -2693,7 +2712,8 @@ public void discoverSearchObjectsTestForHitHighlights() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -2839,7 +2859,8 @@ public void discoverSearchObjectsWithQueryOperatorContains_query() throws Except FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -2917,7 +2938,8 @@ public void discoverSearchObjectsWithQueryOperatorContains() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -2993,7 +3015,8 @@ public void discoverSearchObjectsWithQueryOperatorNotContains_query() throws Exc FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -3070,7 +3093,8 @@ public void discoverSearchObjectsWithQueryOperatorNotContains() throws Exception FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -3157,7 +3181,8 @@ public void discoverSearchObjectsTestForMinMaxValues() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -3228,7 +3253,8 @@ public void discoverSearchFacetsTestForMinMaxValues() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/facets"))) @@ -3304,7 +3330,8 @@ public void discoverSearchObjectsWithQueryOperatorEquals_query() throws Exceptio FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -3381,7 +3408,8 @@ public void discoverSearchObjectsWithQueryOperatorEquals() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -3458,7 +3486,8 @@ public void discoverSearchObjectsWithQueryOperatorNotEquals_query() throws Excep FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -3536,7 +3565,8 @@ public void discoverSearchObjectsWithQueryOperatorNotEquals() throws Exception { FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -3612,7 +3642,8 @@ public void discoverSearchObjectsWithQueryOperatorNotAuthority_query() throws Ex FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -3689,7 +3720,8 @@ public void discoverSearchObjectsWithQueryOperatorNotAuthority() throws Exceptio FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.hasContentInOriginalBundleFacet(false) + FacetEntryMatcher.hasContentInOriginalBundleFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link available .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) @@ -4138,7 +4170,8 @@ public void discoverSearchObjectsWithInProgressSubmissionTest() throws Exception FacetEntryMatcher.clarinItemsLanguageFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), FacetEntryMatcher.hasContentInOriginalBundleFacet(false), - FacetEntryMatcher.entityTypeFacet(false) + FacetEntryMatcher.entityTypeFacet(false), + FacetEntryMatcher.typeFacet(false) ))) //There always needs to be a self link .andExpect(jsonPath("$._links.self.href", containsString("/api/discover/search/objects"))) diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/DiscoveryScopeBasedRestControllerIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/DiscoveryScopeBasedRestControllerIT.java index 67e514d5084d..4a83a0ea593b 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/DiscoveryScopeBasedRestControllerIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/DiscoveryScopeBasedRestControllerIT.java @@ -509,7 +509,8 @@ public void ScopeBasedIndexingAndSearchTestParentCommunity2() throws Exception { FacetEntryMatcher.entityTypeFacet(false), FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.clarinItemsLanguageFacet(false) + FacetEntryMatcher.clarinItemsLanguageFacet(false), + FacetEntryMatcher.typeFacet(false) )) ); } @@ -624,7 +625,8 @@ public void ScopeBasedIndexingAndSearchTestSubcommunity22() throws Exception { FacetEntryMatcher.entityTypeFacet(false), FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.clarinItemsLanguageFacet(false) + FacetEntryMatcher.clarinItemsLanguageFacet(false), + FacetEntryMatcher.typeFacet(false) )) ); } @@ -677,7 +679,8 @@ public void ScopeBasedIndexingAndSearchTestCollection222() throws Exception { FacetEntryMatcher.entityTypeFacet(false), FacetEntryMatcher.clarinLicenseRightsFacet(false), FacetEntryMatcher.clarinItemsCommunityFacet(false), - FacetEntryMatcher.clarinItemsLanguageFacet(false) + FacetEntryMatcher.clarinItemsLanguageFacet(false), + FacetEntryMatcher.typeFacet(false) )) ); } diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/MetadataBitstreamRestRepositoryIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/MetadataBitstreamRestRepositoryIT.java index 59e39285bea1..c966ecfa58e3 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/MetadataBitstreamRestRepositoryIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/MetadataBitstreamRestRepositoryIT.java @@ -7,6 +7,7 @@ */ package org.dspace.app.rest; +import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -34,7 +35,6 @@ import org.dspace.content.service.clarin.ClarinLicenseResourceMappingService; import org.dspace.core.Constants; import org.dspace.services.ConfigurationService; -import org.dspace.util.FileTreeViewGenerator; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; @@ -115,9 +115,9 @@ public void findByHandle() throws Exception { .andExpect(jsonPath("$._embedded.metadatabitstreams[*].format") .value(Matchers.containsInAnyOrder(Matchers.containsString( bts.getFormat(context).getMIMEType())))) + // Convert the long into int because Marchers has a problem to compare long format .andExpect(jsonPath("$._embedded.metadatabitstreams[*].fileSize") - .value(Matchers.containsInAnyOrder(Matchers.containsString( - FileTreeViewGenerator.humanReadableFileSize(bts.getSizeBytes()))))) + .value(hasItem(is((int) bts.getSizeBytes())))) .andExpect(jsonPath("$._embedded.metadatabitstreams[*].canPreview") .value(Matchers.containsInAnyOrder(Matchers.is(canPreview)))) .andExpect(jsonPath("$._embedded.metadatabitstreams[*].fileInfo").exists()) @@ -150,8 +150,7 @@ public void previewingIsDisabledByCfg() throws Exception { .value(Matchers.containsInAnyOrder(Matchers.containsString( bts.getFormat(context).getMIMEType())))) .andExpect(jsonPath("$._embedded.metadatabitstreams[*].fileSize") - .value(Matchers.containsInAnyOrder(Matchers.containsString( - FileTreeViewGenerator.humanReadableFileSize(bts.getSizeBytes()))))) + .value(hasItem(is((int) bts.getSizeBytes())))) .andExpect(jsonPath("$._embedded.metadatabitstreams[*].canPreview") .value(Matchers.containsInAnyOrder(Matchers.is(false)))) .andExpect(jsonPath("$._embedded.metadatabitstreams[*].fileInfo").exists()) diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/StatisticsRestRepositoryIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/StatisticsRestRepositoryIT.java index 5544ecdb032b..2a07dc479807 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/StatisticsRestRepositoryIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/StatisticsRestRepositoryIT.java @@ -53,6 +53,7 @@ import org.dspace.content.DSpaceObject; import org.dspace.content.Item; import org.dspace.content.Site; +import org.dspace.content.service.SiteService; import org.dspace.core.Constants; import org.dspace.eperson.EPerson; import org.dspace.services.ConfigurationService; @@ -76,6 +77,8 @@ public class StatisticsRestRepositoryIT extends AbstractControllerIntegrationTes ConfigurationService configurationService; @Autowired protected AuthorizeService authorizeService; + @Autowired + protected SiteService siteService; private Community communityNotVisited; private Community communityVisited; @@ -1532,6 +1535,22 @@ public void usageReportsSearch_Bitstream_Visited() throws Exception { ))); } + // Show usage reports for the Anonymous user - it could be configured by cfg property + // `site.usage-reports.enable.auth.anonymous` + @Test + public void usageReportsSearch_Site_For_Anonymous() throws Exception { + // This property is set to `true` before each test + configurationService.setProperty("usage-statistics.authorization.admin.usage", false); + + // Get the site object UUID + Site site = siteService.findSite(context); + // Allow accessing Site usage reports for anonymous + getClient() + .perform(get("/api/statistics/usagereports/search/object?uri=http://localhost:8080/server/api/core" + + "/sites/" + site.getID())) + .andExpect(status().isOk()); + } + // Create expected points from -6 months to now, with given number of views in current month private List getListOfVisitsPerMonthsPoints(int viewsLastMonth) { List expectedPoints = new ArrayList<>(); diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/FacetEntryMatcher.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/FacetEntryMatcher.java index 9176a42616f9..23d66754dcc6 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/FacetEntryMatcher.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/FacetEntryMatcher.java @@ -124,7 +124,7 @@ public static Matcher matchFacet(boolean hasNext, String name, S public static Matcher clarinLicenseRightsFacet(boolean hasNext) { return allOf( hasJsonPath("$.name", is("rights")), - hasJsonPath("$.facetType", is("standard")), + hasJsonPath("$.facetType", is("text")), hasJsonPath("$.facetLimit", any(Integer.class)), hasJsonPath("$._links.self.href", containsString("api/discover/facets/rights")), hasJsonPath("$._links", matchNextLink(hasNext, "api/discover/facets/rights")) @@ -144,7 +144,7 @@ public static Matcher clarinItemsLanguageFacet(boolean hasNext) public static Matcher clarinItemsCommunityFacet(boolean hasNext) { return allOf( hasJsonPath("$.name", is("items_owning_community")), - hasJsonPath("$.facetType", is("standard")), + hasJsonPath("$.facetType", is("text")), hasJsonPath("$.facetLimit", any(Integer.class)), hasJsonPath("$._links.self.href", containsString("api/discover/facets/items_owning_community")), diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SearchFilterMatcher.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SearchFilterMatcher.java index 7700d5291249..b60f26940ff8 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SearchFilterMatcher.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SearchFilterMatcher.java @@ -160,7 +160,7 @@ public static Matcher clarinLicenseRightsFilter() { return allOf( hasJsonPath("$.filter", is("rights")), hasJsonPath("$.hasFacets", is(true)), - hasJsonPath("$.type", is("standard")), + hasJsonPath("$.type", is("text")), hasJsonPath("$.openByDefault", is(false)), checkOperators() ); @@ -180,7 +180,7 @@ public static Matcher clarinItemsCommunityFilter() { return allOf( hasJsonPath("$.filter", is("items_owning_community")), hasJsonPath("$.hasFacets", is(true)), - hasJsonPath("$.type", is("standard")), + hasJsonPath("$.type", is("text")), hasJsonPath("$.openByDefault", is(false)), checkOperators() ); @@ -189,7 +189,7 @@ public static Matcher clarinItemsCommunityFilter() { public static Matcher clarinItemsTypeFilter() { return allOf( hasJsonPath("$.filter", is("itemtype")), - hasJsonPath("$.hasFacets", is(false)), + hasJsonPath("$.hasFacets", is(true)), hasJsonPath("$.type", is("text")), hasJsonPath("$.openByDefault", is(false)), checkOperators() diff --git a/dspace/config/clarin-dspace.cfg b/dspace/config/clarin-dspace.cfg index a13a684a4118..04f86a00ed6f 100644 --- a/dspace/config/clarin-dspace.cfg +++ b/dspace/config/clarin-dspace.cfg @@ -156,6 +156,9 @@ matomo.tracker.bitstream.site_id = 1 matomo.tracker.oai.site_id = 1 statistics.cache-server.uri = http://cache-server.none +#### Statistic usage reports #### +# site.usage-reports.enable.auth.anonymous = true + ##### Citacepro config ##### # citace.pro.url = https://www.citacepro.com/api/dspace/citace/oai diff --git a/dspace/config/spring/api/discovery.xml b/dspace/config/spring/api/discovery.xml index 2b7f42fff99a..9be4c456195a 100644 --- a/dspace/config/spring/api/discovery.xml +++ b/dspace/config/spring/api/discovery.xml @@ -64,6 +64,7 @@ + @@ -171,6 +172,7 @@ + @@ -207,8 +209,167 @@ - - + + + + + + + + + + + + + (search.resourcetype:Item AND latestVersion:true) OR search.resourcetype:Collection OR search.resourcetype:Community + -withdrawn:true AND -discoverable:false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + dc.title + dc.contributor.author + dc.creator + dc.subject + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -355,8 +516,10 @@ - - + + + + @@ -504,8 +667,10 @@ - - + + + + @@ -643,8 +808,10 @@ - - + + + + @@ -773,8 +940,10 @@ - - + + + + @@ -924,8 +1093,10 @@ - - + + + + @@ -999,8 +1170,10 @@ - - + + + + @@ -1074,8 +1247,10 @@ - - + + + + @@ -1158,8 +1333,10 @@ - - + + + + @@ -1228,8 +1405,10 @@ - - + + + + @@ -2333,7 +2512,7 @@ dc.rights.label - + @@ -2358,7 +2537,7 @@ - + @@ -2368,6 +2547,8 @@ dc.type + edm.type + metashare.ResourceInfo#ContentInfo.mediaType @@ -3003,6 +3184,17 @@ + + + + + + + + + + +