diff --git a/dspace-api/src/main/java/org/dspace/app/ldn/action/LDNCorrectionAction.java b/dspace-api/src/main/java/org/dspace/app/ldn/action/LDNCorrectionAction.java index a302c1478fb1..a0755eeec340 100644 --- a/dspace-api/src/main/java/org/dspace/app/ldn/action/LDNCorrectionAction.java +++ b/dspace-api/src/main/java/org/dspace/app/ldn/action/LDNCorrectionAction.java @@ -44,8 +44,10 @@ public class LDNCorrectionAction implements LDNAction { public ActionStatus execute(Notification notification, Item item) throws Exception { ActionStatus result; Context context = ContextUtil.obtainCurrentRequestContext(); + //FIXME the original id should be just an (optional) identifier/reference of the event in + // the external system. The target Item should be passed as a constructor argument QAEvent qaEvent = new QAEvent(QAEvent.COAR_NOTIFY, - notification.getObject().getId(), item.getID().toString(), item.getName(), + "oai:localhost:" + item.getHandle(), item.getID().toString(), item.getName(), this.getQaEventTopic(), getScore(context, notification).doubleValue(), "{\"abstracts[0]\": \"" + notification.getObject().getIetfCiteAs() + "\"}" , new Date()); diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/LDNInboxControllerIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/LDNInboxControllerIT.java index fbe3223bef7c..8a58b43549fb 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/LDNInboxControllerIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/LDNInboxControllerIT.java @@ -17,17 +17,20 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import java.io.InputStream; +import java.math.BigDecimal; import java.nio.charset.Charset; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.IOUtils; import org.dspace.app.ldn.LDNMessageEntity; +import org.dspace.app.ldn.NotifyServiceEntity; import org.dspace.app.ldn.model.Notification; import org.dspace.app.ldn.service.LDNMessageService; import org.dspace.app.rest.test.AbstractControllerIntegrationTest; import org.dspace.builder.CollectionBuilder; import org.dspace.builder.CommunityBuilder; import org.dspace.builder.ItemBuilder; +import org.dspace.builder.NotifyServiceBuilder; import org.dspace.content.Collection; import org.dspace.content.Community; import org.dspace.content.Item; @@ -58,7 +61,6 @@ public void ldnInboxEndorsementActionTest() throws Exception { Collection collection = CollectionBuilder.createCollection(context, community).build(); Item item = ItemBuilder.createItem(context, collection).build(); String object = configurationService.getProperty("dspace.ui.url") + "/handle/" + item.getHandle(); - context.restoreAuthSystemState(); InputStream offerEndorsementStream = getClass().getResourceAsStream("ldn_offer_endorsement_object.json"); @@ -68,7 +70,7 @@ public void ldnInboxEndorsementActionTest() throws Exception { ObjectMapper mapper = new ObjectMapper(); Notification notification = mapper.readValue(message, Notification.class); - getClient(getAuthToken(admin.getEmail(), password)) + getClient() .perform(post("/ldn/inbox") .contentType("application/ld+json") .content(message)) @@ -96,7 +98,7 @@ public void ldnInboxAnnounceEndorsementTest() throws Exception { ObjectMapper mapper = new ObjectMapper(); Notification notification = mapper.readValue(message, Notification.class); - getClient(getAuthToken(admin.getEmail(), password)) + getClient() .perform(post("/ldn/inbox") .contentType("application/ld+json") .content(message)) @@ -109,12 +111,22 @@ public void ldnInboxAnnounceEndorsementTest() throws Exception { @Test public void ldnInboxAnnounceReviewTest() throws Exception { + context.turnOffAuthorisationSystem(); + NotifyServiceEntity serviceEntity = NotifyServiceBuilder.createNotifyServiceBuilder(context) + .withName("Review Service") + .withLdnUrl("https://review-service.com/inbox/") + .withScore(BigDecimal.valueOf(0.6d)) + .build(); + Community com = CommunityBuilder.createCommunity(context).withName("Test Community").build(); + Collection col = CollectionBuilder.createCollection(context, com).withName("Test Collection").build(); + Item item = ItemBuilder.createItem(context, col).withHandle("123456789/9999").withTitle("Test Item").build(); + context.restoreAuthSystemState(); InputStream announceReviewStream = getClass().getResourceAsStream("ldn_announce_review.json"); String message = IOUtils.toString(announceReviewStream, Charset.defaultCharset()); announceReviewStream.close(); ObjectMapper mapper = new ObjectMapper(); Notification notification = mapper.readValue(message, Notification.class); - getClient(getAuthToken(admin.getEmail(), password)) + getClient() .perform(post("/ldn/inbox") .contentType("application/ld+json") .content(message)) @@ -134,7 +146,7 @@ public void ldnInboxEndorsementActionBadRequestTest() throws Exception { offerEndorsementStream.close(); ObjectMapper mapper = new ObjectMapper(); Notification notification = mapper.readValue(message, Notification.class); - getClient(getAuthToken(admin.getEmail(), password)) + getClient() .perform(post("/ldn/inbox") .contentType("application/ld+json") .content(message)) diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionCOARNotifyRestRepositoryIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionCOARNotifyRestRepositoryIT.java index 3edb12f3c098..89c2a0cbea1d 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionCOARNotifyRestRepositoryIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionCOARNotifyRestRepositoryIT.java @@ -41,7 +41,7 @@ public void findAllTest() throws Exception { .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$._embedded.submissioncoarnotifyconfigs", Matchers.containsInAnyOrder( - SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("default", + SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("coarnotify", List.of("review", "endorsement", "ingest")) ))); } @@ -64,11 +64,11 @@ public void findOneTestNonExistingCOARNotify() throws Exception { public void findOneTest() throws Exception { String epersonToken = getAuthToken(eperson.getEmail(), password); - getClient(epersonToken).perform(get("/api/config/submissioncoarnotifyconfigs/default")) + getClient(epersonToken).perform(get("/api/config/submissioncoarnotifyconfigs/coarnotify")) .andExpect(status().isOk()) .andExpect(content().contentType(contentType)) .andExpect(jsonPath("$", Matchers.is( - SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("default", + SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("coarnotify", List.of("review", "endorsement", "ingest")) ))); } diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionDefinitionsControllerIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionDefinitionsControllerIT.java index babb1fac2326..41c8f081b6f8 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionDefinitionsControllerIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionDefinitionsControllerIT.java @@ -205,7 +205,7 @@ public void findSections() throws Exception { // We expect the content type to be "application/hal+json;charset=UTF-8" .andExpect(content().contentType(contentType)) // Match only that a section exists with a submission configuration behind - .andExpect(jsonPath("$._embedded.submissionsections", hasSize(9))) + .andExpect(jsonPath("$._embedded.submissionsections", hasSize(10))) .andExpect(jsonPath("$._embedded.submissionsections", Matchers.hasItem( allOf( diff --git a/dspace-server-webapp/src/test/resources/org/dspace/app/rest/ldn_announce_review.json b/dspace-server-webapp/src/test/resources/org/dspace/app/rest/ldn_announce_review.json index 607dfc784716..ffaf90a60008 100644 --- a/dspace-server-webapp/src/test/resources/org/dspace/app/rest/ldn_announce_review.json +++ b/dspace-server-webapp/src/test/resources/org/dspace/app/rest/ldn_announce_review.json @@ -9,7 +9,7 @@ "type": "Service" }, "context": { - "id": "oai:http://localhost:4000/handle:123456789/12", + "id": "http://localhost:4000/handle/123456789/9999", "ietf:cite-as": "https://doi.org/10.5555/12345680", "type": "sorg:AboutPage", "url": { diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg index 33bc58244358..e2888aa49242 100644 --- a/dspace/config/dspace.cfg +++ b/dspace/config/dspace.cfg @@ -929,6 +929,7 @@ registry.metadata.load = openaire4-types.xml registry.metadata.load = dspace-types.xml registry.metadata.load = iiif-types.xml registry.metadata.load = datacite-types.xml +registry.metadata.load = coar-types.xml #---------------------------------------------------------------#