From b89eb6f065c63fd3fff9c67f75a2f06b462bdc80 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Wed, 19 Jun 2024 16:37:28 +0200 Subject: [PATCH] Fetched right files from origin/dtq-dev --- .../java/org/dspace/app/util/DCInput.java | 5 - .../org/dspace/content/ItemServiceImpl.java | 5 - .../google/GoogleAsyncEventListener.java | 1 - .../test/data/dspaceFolder/config/local.cfg | 11 - .../repository/EPersonRestRepository.java | 2 +- .../repository/RequestItemRepository.java | 2 +- .../rest/AuthenticationRestControllerIT.java | 3 - .../app/rest/BrowsesResourceControllerIT.java | 12 +- .../rest/WorkspaceItemRestRepositoryIT.java | 297 ------------------ dspace/config/spring/api/discovery.xml | 28 +- 10 files changed, 19 insertions(+), 347 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/app/util/DCInput.java b/dspace-api/src/main/java/org/dspace/app/util/DCInput.java index 582200d0534..9c7f4396c96 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/DCInput.java +++ b/dspace-api/src/main/java/org/dspace/app/util/DCInput.java @@ -153,11 +153,6 @@ public class DCInput { */ private ACL acl = null; - /** - * the computed pattern, null if nothing - */ - private Pattern pattern = null; - /** * allowed document types */ diff --git a/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java index e656878519b..e135f614ec4 100644 --- a/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java @@ -300,11 +300,6 @@ public Iterator findAllRegularItems(Context context) throws SQLException { return itemDAO.findAllRegularItems(context); } - @Override - public Iterator findAllRegularItems(Context context) throws SQLException { - return itemDAO.findAllRegularItems(context); - } - @Override public Iterator findBySubmitter(Context context, EPerson eperson) throws SQLException { return itemDAO.findBySubmitter(context, eperson); diff --git a/dspace-api/src/main/java/org/dspace/google/GoogleAsyncEventListener.java b/dspace-api/src/main/java/org/dspace/google/GoogleAsyncEventListener.java index ea750f8007b..99668688ae8 100644 --- a/dspace-api/src/main/java/org/dspace/google/GoogleAsyncEventListener.java +++ b/dspace-api/src/main/java/org/dspace/google/GoogleAsyncEventListener.java @@ -224,7 +224,6 @@ private void logReceiveEventException(UsageEvent usageEvent, Exception e) { for (int x = 1; x <= context.getEvents().size(); x++) { LOGGER.error(" Context Event " + x + ": " + context.getEvents().get(x)); } - return allowedBundles.stream().anyMatch(bitstreamBundles::contains); } } diff --git a/dspace-api/src/test/data/dspaceFolder/config/local.cfg b/dspace-api/src/test/data/dspaceFolder/config/local.cfg index bd1018e27d6..cc9ccb26bbb 100644 --- a/dspace-api/src/test/data/dspaceFolder/config/local.cfg +++ b/dspace-api/src/test/data/dspaceFolder/config/local.cfg @@ -87,17 +87,6 @@ handle.hide.listhandles = false # Set is to null because of failing some IT handle.additional.prefixes = -# Whether to enable the DSpace handle resolver endpoints necessary for -# https://github.com/DSpace/Remote-Handle-Resolver -# Defaults to "false" which means these handle resolver endpoints are not available. -handle.remote-resolver.enabled = true - -# Whether to enable the DSpace listhandles resolver that lists all available -# handles for this DSpace installation. -# Defaults to "false" which means is possible to obtain the list of handles -# of this DSpace installation, whenever the `handle.remote-resolver.enabled = true`. -handle.hide.listhandles = false - ##################### # LOGLEVEL SETTINGS # ##################### diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/EPersonRestRepository.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/EPersonRestRepository.java index 5b6accac429..b213b6d1eab 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/EPersonRestRepository.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/EPersonRestRepository.java @@ -83,7 +83,7 @@ public class EPersonRestRepository extends DSpaceObjectRestRepository updateSeries = new ArrayList(); - List> seriesValues = new ArrayList<>(); - Map value = new HashMap(); - value.put("value", "New Series"); - seriesValues.add(value); - updateSeries.add(new AddOperation("/sections/traditionalpageone/dc.relation.ispartofseries", seriesValues)); - - String patchBody = getPatchContent(updateSeries); - - getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) - .content(patchBody) - .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - // Check this - we should match an item with no series or type - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeAndSeries(witem, null, null)))); - - // Verify that the metadata isn't in the workspace item - getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - // Check this - we should match an item with no series or type - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeAndSeries(witem, null, null)))); - - // Set the type to Technical Report confirm it worked - List updateType = new ArrayList<>(); - List> typeValues = new ArrayList<>(); - value = new HashMap(); - value.put("value", "Technical Report"); - typeValues.add(value); - updateType.add(new AddOperation("/sections/traditionalpageone/dc.type", typeValues)); - patchBody = getPatchContent(updateType); - - getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) - .content(patchBody) - .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - // Check this - we should now match an item with the expected type and series - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeAndSeries(witem, "Technical Report", - null)))); - - getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeAndSeries(witem, "Technical Report", - null)))); - - // Another test, this time adding the series value should be successful and we'll see the value - patchBody = getPatchContent(updateSeries); - - getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) - .content(patchBody) - .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - // Check this - we should match an item with the expected series and type - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeAndSeries(witem, - "Technical Report", "New Series")))); - - // Verify that the metadata isn't in the workspace item - getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - // Check this - we should match an item with the expected series and type - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeAndSeries(witem, - "Technical Report", "New Series")))); - - // One final update, to a different type, this should lose the series as we're back to a non-matching type - updateType = new ArrayList<>(); - typeValues = new ArrayList<>(); - value = new HashMap(); - value.put("value", "Article"); - typeValues.add(value); - updateType.add(new AddOperation("/sections/traditionalpageone/dc.type", typeValues)); - patchBody = getPatchContent(updateType); - - getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) - .content(patchBody) - .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - // Check this - we should NOT match an item with the series "New Series" - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeAndSeries(witem, "Article", - null)))); - - getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeAndSeries(witem, "Article", - null)))); - - // Submit the workspace item to complete the deposit (as there is no workflow configured) and ensure a - // successful result with no validation errors - getClient(authToken) - .perform(post(BASE_REST_SERVER_URL + "/api/workflow/workflowitems") - .content("/api/submission/workspaceitems/" + witem.getID()) - .contentType(textUriContentType)) - .andExpect(status().isCreated()); - } - - @Test - /** - * Test the update of metadata for fields configured with type-bind in the specific case where - * a field is configured more than once and could be bound to one type in a certain case, and another type - * later on (perhaps with a different label or validation rules) - * - * @throws Exception - */ - public void patchUpdateMetadataWithBindForRepeatedFieldConfigurationTest() throws Exception { - context.turnOffAuthorisationSystem(); - - String testIsbnString = "978-3-16-148410-0"; - - //** GIVEN ** - //1. A community-collection structure with one parent community with sub-community and two collections. - parentCommunity = CommunityBuilder.createCommunity(context) - .withName("Parent Community") - .build(); - Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity) - .withName("Sub Community") - .build(); - Collection col1 = CollectionBuilder.createCollection(context, child1, "123456789/typebind-test") - .withName("Collection 1").build(); - String authToken = getAuthToken(eperson.getEmail(), password); - - WorkspaceItem witem = WorkspaceItemBuilder.createWorkspaceItem(context, col1) - .withSubmitter(eperson) - .withTitle("Workspace Item 1") - .withIssueDate("2017-10-17") - .withSubject("ExtraEntry") - .grantLicense() - .build(); - - //disable file upload mandatory - configurationService.setProperty("webui.submit.upload.required", false); - - context.restoreAuthSystemState(); - - // Try to add ISBN (type bound to book and book chapter) - this should not work and instead we'll get - // no JSON path for that field, because this item has no type yet - List updateOperations = new ArrayList(); - List> updateValues = new ArrayList<>(); - Map value = new HashMap(); - value.put("value", "978-3-16-148410-0"); - updateValues.add(value); - updateOperations.add(new AddOperation("/sections/typebindtest/dc.identifier.isbn", updateValues)); - - String patchBody = getPatchContent(updateOperations); - - getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) - .content(patchBody) - .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - // Check this - we should match an item with no series or ISBN - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeFieldAndValue - (witem, "typebindtest",null, "dc.identifier.isbn", null)))); - - // Verify that the metadata isn't in the workspace item - getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeFieldAndValue - (witem, "typebindtest", null, "dc.identifier.isbn", null)))); - - // Set the type to Book (which ISBN is bound to, in one of the two configurations) - List updateType = new ArrayList<>(); - List> typeValues = new ArrayList<>(); - value = new HashMap(); - value.put("value", "Book"); - typeValues.add(value); - updateType.add(new AddOperation("/sections/typebindtest/dc.type", typeValues)); - patchBody = getPatchContent(updateType); - - getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) - .content(patchBody) - .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) - .andExpect(status().isOk()) -// .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - // Check this - we should now match an item with the expected type and no ISBN - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeFieldAndValue(witem, - "typebindtest","Book", "dc.identifier.isbn", null)))); - - // Fetch workspace item and confirm type has persisted - getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())) - .andExpect(status().isOk()) -// .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeFieldAndValue(witem, - "typebindtest", "Book", "dc.identifier.isbn", null)))); - - // Now we test that the validate process does NOT strip out ISBN metadata while it's analysing the - // Book Chapter input config, even though that won't match the current item type (Book) - patchBody = getPatchContent(updateOperations); - - getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) - .content(patchBody) - .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - // Check this - we should now match an item with the expected type and the test ISBN - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeFieldAndValue(witem, "typebindtest", - "Book", "dc.identifier.isbn", testIsbnString)))); - - // Verify that the metadata is persisted - getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeFieldAndValue(witem, "typebindtest", - "Book","dc.identifier.isbn", testIsbnString)))); - - // Switch type to "Book chapter" - this is also bound to ISBN in a second configuration of the field - // And should allow us to preserve the ISBN that was set while the type was Book - updateType = new ArrayList<>(); - typeValues = new ArrayList<>(); - value = new HashMap(); - value.put("value", "Book chapter"); - typeValues.add(value); - updateType.add(new AddOperation("/sections/typebindtest/dc.type", typeValues)); - patchBody = getPatchContent(updateType); - - getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) - .content(patchBody) - .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - // Check this - we should now match an item with the expected type and no ISBN - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeFieldAndValue(witem,"typebindtest", - "Book chapter", "dc.identifier.isbn", testIsbnString)))); - - // Fetch workspace item and confirm type has persisted - getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.errors").doesNotExist()) - .andExpect(jsonPath("$", - Matchers.is(WorkspaceItemMatcher.matchItemWithTypeFieldAndValue(witem, - "typebindtest", "Book chapter", "dc.identifier.isbn", testIsbnString)))); - - // Submit the workspace item to complete the deposit (as there is no workflow configured) and ensure a - // successful result with no validation errors - getClient(authToken) - .perform(post(BASE_REST_SERVER_URL + "/api/workflow/workflowitems") - .content("/api/submission/workspaceitems/" + witem.getID()) - .contentType(textUriContentType)) - .andExpect(status().isCreated()); - } - @Test public void patchUpdateMetadataForbiddenTest() throws Exception { context.turnOffAuthorisationSystem(); diff --git a/dspace/config/spring/api/discovery.xml b/dspace/config/spring/api/discovery.xml index ed5e9df6330..a5cce1ffd2b 100644 --- a/dspace/config/spring/api/discovery.xml +++ b/dspace/config/spring/api/discovery.xml @@ -582,18 +582,6 @@ - - - - - - - - - - - - + + @@ -777,12 +767,13 @@ - - - - + + + + + @@ -795,6 +786,8 @@ + + @@ -918,7 +911,6 @@ -