mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-08 10:34:25 +00:00
Merged in coar-notify-7_CST-12401 (pull request #1553)
[CST-12401] Allow to configure which patterns can be requested by multiple services during the submission Approved-by: Stefano Maffei
This commit is contained in:
@@ -21,13 +21,13 @@ public class COARNotifyConfigurationService {
|
|||||||
* Mapping the submission step process identifier with the configuration
|
* Mapping the submission step process identifier with the configuration
|
||||||
* (see configuration at coar-notify.xml)
|
* (see configuration at coar-notify.xml)
|
||||||
*/
|
*/
|
||||||
private Map<String, List<String>> patterns;
|
private Map<String, List<LDNPattern>> patterns;
|
||||||
|
|
||||||
public Map<String, List<String>> getPatterns() {
|
public Map<String, List<LDNPattern>> getPatterns() {
|
||||||
return patterns;
|
return patterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPatterns(Map<String, List<String>> patterns) {
|
public void setPatterns(Map<String, List<LDNPattern>> patterns) {
|
||||||
this.patterns = patterns;
|
this.patterns = patterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,13 +26,13 @@ public class COARNotifySubmissionConfiguration {
|
|||||||
* the map values of configured bean of COARNotifyConfigurationService
|
* the map values of configured bean of COARNotifyConfigurationService
|
||||||
* in coar-notify.xml
|
* in coar-notify.xml
|
||||||
*/
|
*/
|
||||||
private List<String> patterns;
|
private List<LDNPattern> patterns;
|
||||||
|
|
||||||
public COARNotifySubmissionConfiguration() {
|
public COARNotifySubmissionConfiguration() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public COARNotifySubmissionConfiguration(String id, List<String> patterns) {
|
public COARNotifySubmissionConfiguration(String id, List<LDNPattern> patterns) {
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.patterns = patterns;
|
this.patterns = patterns;
|
||||||
@@ -51,7 +51,7 @@ public class COARNotifySubmissionConfiguration {
|
|||||||
*
|
*
|
||||||
* @return the list of configured COAR Notify Patterns
|
* @return the list of configured COAR Notify Patterns
|
||||||
*/
|
*/
|
||||||
public List<String> getPatterns() {
|
public List<LDNPattern> getPatterns() {
|
||||||
return patterns;
|
return patterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ public class COARNotifySubmissionConfiguration {
|
|||||||
* Sets the list of configured COAR Notify Patterns
|
* Sets the list of configured COAR Notify Patterns
|
||||||
* @param patterns
|
* @param patterns
|
||||||
*/
|
*/
|
||||||
public void setPatterns(final List<String> patterns) {
|
public void setPatterns(final List<LDNPattern> patterns) {
|
||||||
this.patterns = patterns;
|
this.patterns = patterns;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.coarnotify;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection of configured patterns to be met when adding COAR Notify services.
|
||||||
|
*
|
||||||
|
* @author Mohamed Eskander (mohamed.eskander at 4science.com)
|
||||||
|
*/
|
||||||
|
public class LDNPattern {
|
||||||
|
|
||||||
|
private String pattern;
|
||||||
|
private boolean multipleRequest;
|
||||||
|
|
||||||
|
public LDNPattern() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public LDNPattern(String pattern, boolean multipleRequest) {
|
||||||
|
this.pattern = pattern;
|
||||||
|
this.multipleRequest = multipleRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPattern() {
|
||||||
|
return pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPattern(String pattern) {
|
||||||
|
this.pattern = pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMultipleRequest() {
|
||||||
|
return multipleRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultipleRequest(boolean multipleRequest) {
|
||||||
|
this.multipleRequest = multipleRequest;
|
||||||
|
}
|
||||||
|
}
|
@@ -29,7 +29,7 @@ public class SubmissionCOARNotifyServiceImpl implements SubmissionCOARNotifyServ
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COARNotifySubmissionConfiguration findOne(String id) {
|
public COARNotifySubmissionConfiguration findOne(String id) {
|
||||||
List<String> patterns =
|
List<LDNPattern> patterns =
|
||||||
coarNotifyConfigurationService.getPatterns().get(id);
|
coarNotifyConfigurationService.getPatterns().get(id);
|
||||||
|
|
||||||
if (patterns == null) {
|
if (patterns == null) {
|
||||||
|
@@ -13,6 +13,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.dspace.app.rest.RestResourceController;
|
import org.dspace.app.rest.RestResourceController;
|
||||||
import org.dspace.coarnotify.COARNotifySubmissionConfiguration;
|
import org.dspace.coarnotify.COARNotifySubmissionConfiguration;
|
||||||
|
import org.dspace.coarnotify.LDNPattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is the REST representation of the COARNotifySubmissionConfiguration model object
|
* This class is the REST representation of the COARNotifySubmissionConfiguration model object
|
||||||
@@ -26,7 +27,7 @@ public class SubmissionCOARNotifyRest extends BaseObjectRest<String> {
|
|||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private List<String> patterns;
|
private List<LDNPattern> patterns;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
@@ -36,11 +37,11 @@ public class SubmissionCOARNotifyRest extends BaseObjectRest<String> {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getPatterns() {
|
public List<LDNPattern> getPatterns() {
|
||||||
return patterns;
|
return patterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPatterns(final List<String> patterns) {
|
public void setPatterns(final List<LDNPattern> patterns) {
|
||||||
this.patterns = patterns;
|
this.patterns = patterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@ import org.dspace.app.rest.exception.UnprocessableEntityException;
|
|||||||
import org.dspace.app.rest.model.step.DataCOARNotify;
|
import org.dspace.app.rest.model.step.DataCOARNotify;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.coarnotify.COARNotifyConfigurationService;
|
import org.dspace.coarnotify.COARNotifyConfigurationService;
|
||||||
|
import org.dspace.coarnotify.LDNPattern;
|
||||||
import org.dspace.content.InProgressSubmission;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -106,12 +107,13 @@ public class COARNotifySubmissionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isContainPattern(String config, String pattern) {
|
private boolean isContainPattern(String config, String pattern) {
|
||||||
List<String> patterns = coarNotifyConfigurationService.getPatterns().get(config);
|
List<LDNPattern> patterns = coarNotifyConfigurationService.getPatterns().get(config);
|
||||||
if (CollectionUtils.isEmpty(patterns)) {
|
if (CollectionUtils.isEmpty(patterns)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return patterns.stream()
|
return patterns.stream()
|
||||||
|
.map(LDNPattern::getPattern)
|
||||||
.anyMatch(v ->
|
.anyMatch(v ->
|
||||||
v.equals(pattern));
|
v.equals(pattern));
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ import org.dspace.app.rest.utils.ContextUtil;
|
|||||||
import org.dspace.app.util.DCInputsReaderException;
|
import org.dspace.app.util.DCInputsReaderException;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
import org.dspace.coarnotify.COARNotifyConfigurationService;
|
import org.dspace.coarnotify.COARNotifyConfigurationService;
|
||||||
|
import org.dspace.coarnotify.LDNPattern;
|
||||||
import org.dspace.content.InProgressSubmission;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.logic.LogicalStatement;
|
import org.dspace.content.logic.LogicalStatement;
|
||||||
@@ -51,7 +52,10 @@ public class COARNotifyValidation extends AbstractValidation {
|
|||||||
Item item = obj.getItem();
|
Item item = obj.getItem();
|
||||||
|
|
||||||
List<String> patterns =
|
List<String> patterns =
|
||||||
coarNotifyConfigurationService.getPatterns().getOrDefault(config.getId(), List.of());
|
coarNotifyConfigurationService.getPatterns().getOrDefault(config.getId(), List.of())
|
||||||
|
.stream()
|
||||||
|
.map(LDNPattern::getPattern)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
patterns.forEach(pattern -> {
|
patterns.forEach(pattern -> {
|
||||||
List<NotifyServiceEntity> services = findByItemAndPattern(context, item, pattern);
|
List<NotifyServiceEntity> services = findByItemAndPattern(context, item, pattern);
|
||||||
|
@@ -17,6 +17,7 @@ import java.util.List;
|
|||||||
import org.dspace.app.rest.matcher.SubmissionCOARNotifyMatcher;
|
import org.dspace.app.rest.matcher.SubmissionCOARNotifyMatcher;
|
||||||
import org.dspace.app.rest.repository.SubmissionCoarNotifyRestRepository;
|
import org.dspace.app.rest.repository.SubmissionCoarNotifyRestRepository;
|
||||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||||
|
import org.dspace.coarnotify.LDNPattern;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -41,8 +42,10 @@ public class SubmissionCOARNotifyRestRepositoryIT extends AbstractControllerInte
|
|||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(contentType))
|
.andExpect(content().contentType(contentType))
|
||||||
.andExpect(jsonPath("$._embedded.submissioncoarnotifyconfigs", Matchers.containsInAnyOrder(
|
.andExpect(jsonPath("$._embedded.submissioncoarnotifyconfigs", Matchers.containsInAnyOrder(
|
||||||
SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("coarnotify",
|
SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("coarnotify", List.of(
|
||||||
List.of("request-review", "request-endorsement", "request-ingest"))
|
new LDNPattern("request-review", true),
|
||||||
|
new LDNPattern("request-endorsement", true),
|
||||||
|
new LDNPattern("request-ingest", false)))
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,8 +71,10 @@ public class SubmissionCOARNotifyRestRepositoryIT extends AbstractControllerInte
|
|||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(contentType))
|
.andExpect(content().contentType(contentType))
|
||||||
.andExpect(jsonPath("$", Matchers.is(
|
.andExpect(jsonPath("$", Matchers.is(
|
||||||
SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("coarnotify",
|
SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("coarnotify", List.of(
|
||||||
List.of("request-review", "request-endorsement", "request-ingest"))
|
new LDNPattern("request-review", true),
|
||||||
|
new LDNPattern("request-endorsement", true),
|
||||||
|
new LDNPattern("request-ingest", false)))
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,10 +9,12 @@ package org.dspace.app.rest.matcher;
|
|||||||
|
|
||||||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dspace.coarnotify.LDNPattern;
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,11 +28,18 @@ public class SubmissionCOARNotifyMatcher {
|
|||||||
private SubmissionCOARNotifyMatcher() {
|
private SubmissionCOARNotifyMatcher() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Matcher<? super Object> matchCOARNotifyEntry(String id, List<String> patterns) {
|
public static Matcher<? super Object> matchCOARNotifyEntry(String id, List<LDNPattern> patterns) {
|
||||||
return allOf(
|
return allOf(
|
||||||
hasJsonPath("$.id", is(id)),
|
hasJsonPath("$.id", is(id)),
|
||||||
hasJsonPath("$.patterns", is(patterns))
|
hasJsonPath(
|
||||||
);
|
"$.patterns", contains(
|
||||||
|
patterns.stream()
|
||||||
|
.map(ldnPattern ->
|
||||||
|
allOf(
|
||||||
|
hasJsonPath("pattern", is(ldnPattern.getPattern())),
|
||||||
|
hasJsonPath("multipleRequest", is(ldnPattern.isMultipleRequest()))
|
||||||
|
))
|
||||||
|
.toArray(Matcher[]::new))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -10,13 +10,28 @@
|
|||||||
<map>
|
<map>
|
||||||
<entry key="coarnotify">
|
<entry key="coarnotify">
|
||||||
<list>
|
<list>
|
||||||
<value>request-review</value>
|
<ref bean="requestReview"/>
|
||||||
<value>request-endorsement</value>
|
<ref bean="requestEndorsement"/>
|
||||||
<value>request-ingest</value>
|
<ref bean="requestIngest" />
|
||||||
</list>
|
</list>
|
||||||
</entry>
|
</entry>
|
||||||
</map>
|
</map>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="requestReview" class="org.dspace.coarnotify.LDNPattern">
|
||||||
|
<property name="pattern" value="request-review"/>
|
||||||
|
<property name="multipleRequest" value="true"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="requestEndorsement" class="org.dspace.coarnotify.LDNPattern">
|
||||||
|
<property name="pattern" value="request-endorsement"/>
|
||||||
|
<property name="multipleRequest" value="true"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="requestIngest" class="org.dspace.coarnotify.LDNPattern">
|
||||||
|
<property name="pattern" value="request-ingest"/>
|
||||||
|
<property name="multipleRequest" value="false"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
Reference in New Issue
Block a user