Merge branch 'CST-12126-deal-with-untrusted-service' of bitbucket.org:4Science/dspace-cris into CST-12126-deal-with-untrusted-service

This commit is contained in:
frabacche
2023-10-06 14:40:13 +02:00
35 changed files with 498 additions and 163 deletions

View File

@@ -53,6 +53,9 @@ public class NotifyServiceEntity implements ReloadableEntity<Integer> {
@OneToMany(mappedBy = "notifyService")
private List<NotifyServiceOutboundPattern> outboundPatterns;
@Column(name = "enabled")
private boolean enabled = false;
public void setId(Integer id) {
this.id = id;
}
@@ -118,4 +121,12 @@ public class NotifyServiceEntity implements ReloadableEntity<Integer> {
public Integer getID() {
return id;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}

View File

@@ -0,0 +1,13 @@
--
-- 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/
--
-----------------------------------------------------------------------------------
-- edit notifyservice table add enabled column
-----------------------------------------------------------------------------------
ALTER TABLE notifyservice ADD COLUMN enabled BOOLEAN NOT NULL;

View File

@@ -0,0 +1,13 @@
--
-- 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/
--
-----------------------------------------------------------------------------------
-- edit notifyservice table add enabled column
-----------------------------------------------------------------------------------
ALTER TABLE notifyservice ADD COLUMN enabled BOOLEAN NOT NULL;

View File

@@ -125,4 +125,9 @@ public class NotifyServiceBuilder extends AbstractBuilder<NotifyServiceEntity, N
return this;
}
public NotifyServiceBuilder isEnabled(boolean enabled) {
notifyServiceEntity.setEnabled(enabled);
return this;
}
}

View File

@@ -19,7 +19,6 @@ import org.dspace.services.ConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@AuthorizationFeatureDocumentation(name = CoarNotifyLdnEnabled.NAME,
description = "It can be used to verify if the user can see the coar notify protocol is enabled")

View File

@@ -37,6 +37,7 @@ public class NotifyServiceConverter implements DSpaceConverter<NotifyServiceEnti
notifyServiceRest.setDescription(obj.getDescription());
notifyServiceRest.setUrl(obj.getUrl());
notifyServiceRest.setLdnUrl(obj.getLdnUrl());
notifyServiceRest.setEnabled(obj.isEnabled());
if (obj.getInboundPatterns() != null) {
notifyServiceRest.setNotifyServiceInboundPatterns(

View File

@@ -26,6 +26,7 @@ public class NotifyServiceRest extends BaseObjectRest<Integer> {
private String description;
private String url;
private String ldnUrl;
private boolean enabled;
private List<NotifyServiceInboundPatternRest> notifyServiceInboundPatterns;
private List<NotifyServiceOutboundPatternRest> notifyServiceOutboundPatterns;
@@ -77,6 +78,13 @@ public class NotifyServiceRest extends BaseObjectRest<Integer> {
this.ldnUrl = ldnUrl;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public List<NotifyServiceInboundPatternRest> getNotifyServiceInboundPatterns() {
return notifyServiceInboundPatterns;
}

View File

@@ -9,15 +9,23 @@ package org.dspace.app.rest.repository;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.dspace.app.ldn.NotifyServiceEntity;
import org.dspace.app.ldn.NotifyServiceInboundPattern;
import org.dspace.app.ldn.NotifyServiceOutboundPattern;
import org.dspace.app.ldn.service.NotifyService;
import org.dspace.app.ldn.service.NotifyServiceInboundPatternService;
import org.dspace.app.ldn.service.NotifyServiceOutboundPatternService;
import org.dspace.app.rest.Parameter;
import org.dspace.app.rest.SearchRestMethod;
import org.dspace.app.rest.exception.UnprocessableEntityException;
import org.dspace.app.rest.model.NotifyServiceInboundPatternRest;
import org.dspace.app.rest.model.NotifyServiceOutboundPatternRest;
import org.dspace.app.rest.model.NotifyServiceRest;
import org.dspace.app.rest.model.patch.Patch;
import org.dspace.app.rest.repository.patch.ResourcePatch;
@@ -42,6 +50,12 @@ public class NotifyServiceRestRepository extends DSpaceRestRepository<NotifyServ
@Autowired
private NotifyService notifyService;
@Autowired
private NotifyServiceInboundPatternService inboundPatternService;
@Autowired
private NotifyServiceOutboundPatternService outboundPatternService;
@Autowired
ResourcePatch<NotifyServiceEntity> resourcePatch;
@@ -87,10 +101,56 @@ public class NotifyServiceRestRepository extends DSpaceRestRepository<NotifyServ
notifyServiceEntity.setDescription(notifyServiceRest.getDescription());
notifyServiceEntity.setUrl(notifyServiceRest.getUrl());
notifyServiceEntity.setLdnUrl(notifyServiceRest.getLdnUrl());
if (notifyServiceRest.getNotifyServiceInboundPatterns() != null) {
appendNotifyServiceInboundPatterns(context, notifyServiceEntity,
notifyServiceRest.getNotifyServiceInboundPatterns());
}
if (notifyServiceRest.getNotifyServiceOutboundPatterns() != null) {
appendNotifyServiceOutboundPatterns(context, notifyServiceEntity,
notifyServiceRest.getNotifyServiceOutboundPatterns());
}
notifyServiceEntity.setEnabled(notifyServiceRest.isEnabled());
notifyService.update(context, notifyServiceEntity);
return converter.toRest(notifyServiceEntity, utils.obtainProjection());
}
private void appendNotifyServiceInboundPatterns(Context context, NotifyServiceEntity notifyServiceEntity,
List<NotifyServiceInboundPatternRest> inboundPatternRests) throws SQLException {
List<NotifyServiceInboundPattern> inboundPatterns = new ArrayList<>();
for (NotifyServiceInboundPatternRest inboundPatternRest : inboundPatternRests) {
NotifyServiceInboundPattern inboundPattern = inboundPatternService.create(context, notifyServiceEntity);
inboundPattern.setPattern(inboundPatternRest.getPattern());
inboundPattern.setConstraint(inboundPatternRest.getConstraint());
inboundPattern.setAutomatic(inboundPatternRest.isAutomatic());
inboundPatterns.add(inboundPattern);
}
notifyServiceEntity.setInboundPatterns(inboundPatterns);
}
private void appendNotifyServiceOutboundPatterns(Context context, NotifyServiceEntity notifyServiceEntity,
List<NotifyServiceOutboundPatternRest> outboundPatternRests) throws SQLException {
List<NotifyServiceOutboundPattern> outboundPatterns = new ArrayList<>();
for (NotifyServiceOutboundPatternRest outboundPatternRest : outboundPatternRests) {
NotifyServiceOutboundPattern outboundPattern = outboundPatternService.create(context, notifyServiceEntity);
outboundPattern.setPattern(outboundPatternRest.getPattern());
outboundPattern.setConstraint(outboundPatternRest.getConstraint());
outboundPatterns.add(outboundPattern);
}
notifyServiceEntity.setOutboundPatterns(outboundPatterns);
}
@Override
@PreAuthorize("hasAuthority('ADMIN')")
protected void patch(Context context, HttpServletRequest request, String apiCategory, String model, Integer id,

View File

@@ -0,0 +1,66 @@
/**
* 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.app.rest.repository.patch.operation.ldn;
import java.sql.SQLException;
import org.dspace.app.ldn.NotifyServiceEntity;
import org.dspace.app.ldn.service.NotifyService;
import org.dspace.app.rest.exception.DSpaceBadRequestException;
import org.dspace.app.rest.model.patch.Operation;
import org.dspace.app.rest.repository.patch.operation.PatchOperation;
import org.dspace.core.Context;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Implementation for NotifyService Enabled Replace patches.
*
* Example: <code>
* curl -X PATCH http://${dspace.server.url}/api/ldn/ldnservices/<:id-notifyService> -H "
* Content-Type: application/json" -d '
* [{
* "op": "replace",
* "path": "/enabled"
* }]'
* </code>
*/
@Component
public class NotifyServiceEnabledReplaceOperation extends PatchOperation<NotifyServiceEntity> {
@Autowired
private NotifyService notifyService;
@Autowired
private NotifyServicePatchUtils notifyServicePatchUtils;
private static final String OPERATION_PATH = "/enabled";
@Override
public NotifyServiceEntity perform(Context context, NotifyServiceEntity notifyServiceEntity, Operation operation)
throws SQLException {
checkOperationValue(operation.getValue());
Boolean enabled = getBooleanOperationValue(operation.getValue());
if (supports(notifyServiceEntity, operation)) {
notifyServiceEntity.setEnabled(enabled);
notifyService.update(context, notifyServiceEntity);
return notifyServiceEntity;
} else {
throw new DSpaceBadRequestException(
"NotifyServiceEnabledReplaceOperation does not support this operation");
}
}
@Override
public boolean supports(Object objectToMatch, Operation operation) {
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REPLACE) &&
operation.getPath().trim().toLowerCase().equalsIgnoreCase(OPERATION_PATH));
}
}

View File

@@ -30,7 +30,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "replace",
* "path": "notifyservices_inbound_patterns[index]/automatic"
* "path": "notifyServiceInboundPatterns[index]/automatic"
* }]'
* </code>
*/
@@ -74,7 +74,7 @@ public class NotifyServiceInboundPatternAutomaticReplaceOperation extends PatchO
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REPLACE) &&
path.startsWith(NOTIFY_SERVICE_INBOUND_PATTERNS + "[") &&

View File

@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "add",
* "path": "notifyservices_inbound_patterns[index]/constraint"
* "path": "notifyServiceInboundPatterns[index]/constraint"
* }]'
* </code>
*/
@@ -86,7 +86,7 @@ public class NotifyServiceInboundPatternConstraintAddOperation extends PatchOper
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_ADD) &&
path.startsWith(NOTIFY_SERVICE_INBOUND_PATTERNS + "[") &&

View File

@@ -30,7 +30,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "remove",
* "path": "notifyservices_inbound_patterns[index]/constraint"
* "path": "notifyServiceInboundPatterns[index]/constraint"
* }]'
* </code>
*/
@@ -72,7 +72,7 @@ public class NotifyServiceInboundPatternConstraintRemoveOperation extends PatchO
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REMOVE) &&
path.startsWith(NOTIFY_SERVICE_INBOUND_PATTERNS + "[") &&

View File

@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "replace",
* "path": "notifyservices_inbound_patterns[index]/constraint"
* "path": "notifyServiceInboundPatterns[index]/constraint"
* }]'
* </code>
*/
@@ -86,7 +86,7 @@ public class NotifyServiceInboundPatternConstraintReplaceOperation extends Patch
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REPLACE) &&
path.startsWith(NOTIFY_SERVICE_INBOUND_PATTERNS + "[") &&

View File

@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "add",
* "path": "notifyservices_inbound_patterns[index]/pattern"
* "path": "notifyServiceInboundPatterns[index]/pattern"
* }]'
* </code>
*/
@@ -86,7 +86,7 @@ public class NotifyServiceInboundPatternPatternAddOperation extends PatchOperati
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_ADD) &&
path.startsWith(NOTIFY_SERVICE_INBOUND_PATTERNS + "[") &&

View File

@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "replace",
* "path": "notifyservices_inbound_patterns[index]/pattern"
* "path": "notifyServiceInboundPatterns[index]/pattern"
* }]'
* </code>
*/
@@ -86,7 +86,7 @@ public class NotifyServiceInboundPatternPatternReplaceOperation extends PatchOpe
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REPLACE) &&
path.startsWith(NOTIFY_SERVICE_INBOUND_PATTERNS + "[") &&

View File

@@ -30,7 +30,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "remove",
* "path": "notifyservices_inbound_patterns[index]"
* "path": "notifyServiceInboundPatterns[index]"
* }]'
* </code>
*/
@@ -70,7 +70,7 @@ public class NotifyServiceInboundPatternRemoveOperation extends PatchOperation<N
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REMOVE) &&
path.startsWith(OPERATION_PATH) &&

View File

@@ -30,7 +30,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "replace",
* "path": "notifyservices_inbound_patterns[index]",
* "path": "notifyServiceInboundPatterns[index]",
* "value": {"pattern":"patternA","constraint":"itemFilterA","automatic":"false"}
* }]'
* </code>
@@ -80,7 +80,7 @@ public class NotifyServiceInboundPatternReplaceOperation extends PatchOperation<
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REPLACE) &&
path.startsWith(OPERATION_PATH) &&

View File

@@ -29,7 +29,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "add",
* "path": "notifyservices_inbound_patterns/-",
* "path": "notifyServiceInboundPatterns/-",
* "value": {"pattern":"patternA","constraint":"itemFilterA","automatic":"false"}
* }]'
* </code>

View File

@@ -29,7 +29,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "remove",
* "path": "notifyservices_inbound_patterns"
* "path": "notifyServiceInboundPatterns"
* }]'
* </code>
*/
@@ -63,7 +63,7 @@ public class NotifyServiceInboundPatternsRemoveOperation extends PatchOperation<
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REMOVE) &&
path.startsWith(OPERATION_PATH));

View File

@@ -30,7 +30,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "replace",
* "path": "notifyservices_inbound_patterns",
* "path": "notifyServiceInboundPatterns",
* "value": [{"pattern":"patternA","constraint":"itemFilterA","automatic":"false"}]
* }]'
* </code>

View File

@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "add",
* "path": "notifyservices_outbound_patterns[index]/constraint"
* "path": "notifyServiceOutboundPatterns[index]/constraint"
* }]'
* </code>
*/
@@ -86,7 +86,7 @@ public class NotifyServiceOutboundPatternConstraintAddOperation extends PatchOpe
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_ADD) &&
path.startsWith(NOTIFY_SERVICE_OUTBOUND_PATTERNS + "[") &&

View File

@@ -30,7 +30,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "remove",
* "path": "notifyservices_outbound_patterns[index]/constraint"
* "path": "notifyServiceOutboundPatterns[index]/constraint"
* }]'
* </code>
*/
@@ -72,7 +72,7 @@ public class NotifyServiceOutboundPatternConstraintRemoveOperation extends Patch
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REMOVE) &&
path.startsWith(NOTIFY_SERVICE_OUTBOUND_PATTERNS + "[") &&

View File

@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "replace",
* "path": "notifyservices_outbound_patterns[index]/constraint"
* "path": "notifyServiceOutboundPatterns[index]/constraint"
* }]'
* </code>
*/
@@ -86,7 +86,7 @@ public class NotifyServiceOutboundPatternConstraintReplaceOperation extends Patc
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REPLACE) &&
path.startsWith(NOTIFY_SERVICE_OUTBOUND_PATTERNS + "[") &&

View File

@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "add",
* "path": "notifyservices_outbound_patterns[index]/pattern"
* "path": "notifyServiceOutboundPatterns[index]/pattern"
* }]'
* </code>
*/
@@ -86,7 +86,7 @@ public class NotifyServiceOutboundPatternPatternAddOperation extends PatchOperat
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_ADD) &&
path.startsWith(NOTIFY_SERVICE_OUTBOUND_PATTERNS + "[") &&

View File

@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "replace",
* "path": "notifyservices_outbound_patterns[index]/pattern"
* "path": "notifyServiceOutboundPatterns[index]/pattern"
* }]'
* </code>
*/
@@ -86,7 +86,7 @@ public class NotifyServiceOutboundPatternPatternReplaceOperation extends PatchOp
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REPLACE) &&
path.startsWith(NOTIFY_SERVICE_OUTBOUND_PATTERNS + "[") &&

View File

@@ -30,7 +30,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "remove",
* "path": "notifyservices_outbound_patterns[index]"
* "path": "notifyServiceOutboundPatterns[index]"
* }]'
* </code>
*/
@@ -70,7 +70,7 @@ public class NotifyServiceOutboundPatternRemoveOperation extends PatchOperation<
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REMOVE) &&
path.startsWith(OPERATION_PATH) &&

View File

@@ -30,7 +30,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "replace",
* "path": "notifyservices_outbound_patterns[index]",
* "path": "notifyServiceOutboundPatterns[index]",
* "value": {"pattern":"patternA","constraint":"itemFilterA"}
* }]'
* </code>
@@ -79,7 +79,7 @@ public class NotifyServiceOutboundPatternReplaceOperation extends PatchOperation
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REPLACE) &&
path.startsWith(OPERATION_PATH) &&

View File

@@ -29,7 +29,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "add",
* "path": "notifyservices_outbound_patterns/-",
* "path": "notifyServiceOutboundPatterns/-",
* "value": {"pattern":"patternA","constraint":"itemFilterA"}
* }]'
* </code>

View File

@@ -29,7 +29,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "remove",
* "path": "notifyservices_outbound_patterns"
* "path": "notifyServiceOutboundPatterns"
* }]'
* </code>
*/
@@ -63,7 +63,7 @@ public class NotifyServiceOutboundPatternsRemoveOperation extends PatchOperation
@Override
public boolean supports(Object objectToMatch, Operation operation) {
String path = operation.getPath().trim().toLowerCase();
String path = operation.getPath().trim();
return (objectToMatch instanceof NotifyServiceEntity &&
operation.getOp().trim().equalsIgnoreCase(OPERATION_REMOVE) &&
path.startsWith(OPERATION_PATH));

View File

@@ -30,7 +30,7 @@ import org.springframework.stereotype.Component;
* Content-Type: application/json" -d '
* [{
* "op": "replace",
* "path": "notifyservices_outbound_patterns",
* "path": "notifyServiceOutboundPatterns",
* "value": [{"pattern":"patternA","constraint":"itemFilterA"}]
* }]'
* </code>

View File

@@ -28,8 +28,8 @@ import org.springframework.stereotype.Component;
@Component
public final class NotifyServicePatchUtils {
public static final String NOTIFY_SERVICE_OUTBOUND_PATTERNS = "notifyservices_outbound_patterns";
public static final String NOTIFY_SERVICE_INBOUND_PATTERNS = "notifyservices_inbound_patterns";
public static final String NOTIFY_SERVICE_OUTBOUND_PATTERNS = "notifyServiceOutboundPatterns";
public static final String NOTIFY_SERVICE_INBOUND_PATTERNS = "notifyServiceInboundPatterns";
private ObjectMapper objectMapper = new ObjectMapper();

View File

@@ -10,6 +10,8 @@ package org.dspace.app.rest;
import static org.dspace.content.QAEvent.OPENAIRE_SOURCE;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -18,7 +20,9 @@ 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.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;
@@ -40,6 +44,9 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
@Autowired
private ConfigurationService configurationService;
@Autowired
private LDNMessageService ldnMessageService;
private QAEventService qaEventService = new DSpace().getSingletonService(QAEventService.class);
@Test
@@ -52,6 +59,7 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
String object = configurationService.getProperty("dspace.ui.url") + "/handle/" + item.getHandle();
context.restoreAuthSystemState();
InputStream offerEndorsementStream = getClass().getResourceAsStream("ldn_offer_endorsement_object.json");
String offerEndorsementJson = IOUtils.toString(offerEndorsementStream, Charset.defaultCharset());
offerEndorsementStream.close();
@@ -64,14 +72,27 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
.contentType("application/ld+json")
.content(message))
.andExpect(status().isAccepted());
LDNMessageEntity ldnMessage = ldnMessageService.find(context, notification.getId());
checkStoredLDNMessage(notification, ldnMessage, object);
}
@Test
public void ldnInboxAnnounceEndorsementTest() throws Exception {
context.turnOffAuthorisationSystem();
Community community = CommunityBuilder.createCommunity(context).withName("community").build();
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 announceEndorsementStream = getClass().getResourceAsStream("ldn_announce_endorsement.json");
String message = IOUtils.toString(announceEndorsementStream, Charset.defaultCharset());
String announceEndorsement = IOUtils.toString(announceEndorsementStream, Charset.defaultCharset());
announceEndorsementStream.close();
String message = announceEndorsement.replace("<<object>>", object);
ObjectMapper mapper = new ObjectMapper();
Notification notification = mapper.readValue(message, Notification.class);
getClient(getAuthToken(admin.getEmail(), password))
@@ -79,6 +100,9 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
.contentType("application/ld+json")
.content(message))
.andExpect(status().isAccepted());
LDNMessageEntity ldnMessage = ldnMessageService.find(context, notification.getId());
checkStoredLDNMessage(notification, ldnMessage, object);
}
@@ -115,4 +139,28 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
.content(message))
.andExpect(status().isBadRequest());
}
private void checkStoredLDNMessage(Notification notification, LDNMessageEntity ldnMessage, String object)
throws Exception {
ObjectMapper mapper = new ObjectMapper();
Notification storedMessage = mapper.readValue(ldnMessage.getMessage(), Notification.class);
assertNotNull(ldnMessage);
assertNotNull(ldnMessage.getObject());
assertEquals(ldnMessage.getObject()
.getMetadata()
.stream()
.filter(metadataValue ->
metadataValue.getMetadataField().toString('.').equals("dc.identifier.uri"))
.map(metadataValue -> metadataValue.getValue())
.findFirst().get(), object);
assertEquals(notification.getId(), storedMessage.getId());
assertEquals(notification.getOrigin().getInbox(), storedMessage.getOrigin().getInbox());
assertEquals(notification.getTarget().getInbox(), storedMessage.getTarget().getInbox());
assertEquals(notification.getObject().getId(), storedMessage.getObject().getId());
assertEquals(notification.getType(), storedMessage.getType());
}
}

View File

@@ -32,6 +32,8 @@ import javax.ws.rs.core.MediaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.RandomUtils;
import org.dspace.app.ldn.NotifyServiceEntity;
import org.dspace.app.rest.model.NotifyServiceInboundPatternRest;
import org.dspace.app.rest.model.NotifyServiceOutboundPatternRest;
import org.dspace.app.rest.model.NotifyServiceRest;
import org.dspace.app.rest.model.patch.AddOperation;
import org.dspace.app.rest.model.patch.Operation;
@@ -148,11 +150,27 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
public void createTest() throws Exception {
ObjectMapper mapper = new ObjectMapper();
NotifyServiceInboundPatternRest inboundPatternRestOne = new NotifyServiceInboundPatternRest();
inboundPatternRestOne.setPattern("patternA");
inboundPatternRestOne.setConstraint("itemFilterA");
inboundPatternRestOne.setAutomatic(true);
NotifyServiceInboundPatternRest inboundPatternRestTwo = new NotifyServiceInboundPatternRest();
inboundPatternRestTwo.setPattern("patternB");
inboundPatternRestTwo.setAutomatic(false);
NotifyServiceOutboundPatternRest outboundPatternRest = new NotifyServiceOutboundPatternRest();
outboundPatternRest.setPattern("patternC");
outboundPatternRest.setConstraint("itemFilterC");
NotifyServiceRest notifyServiceRest = new NotifyServiceRest();
notifyServiceRest.setName("service name");
notifyServiceRest.setDescription("service description");
notifyServiceRest.setUrl("service url");
notifyServiceRest.setLdnUrl("service ldn url");
notifyServiceRest.setNotifyServiceInboundPatterns(List.of(inboundPatternRestOne, inboundPatternRestTwo));
notifyServiceRest.setNotifyServiceOutboundPatterns(List.of(outboundPatternRest));
notifyServiceRest.setEnabled(false);
AtomicReference<Integer> idRef = new AtomicReference<Integer>();
String authToken = getAuthToken(admin.getEmail(), password);
@@ -161,16 +179,26 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.contentType(contentType))
.andExpect(status().isCreated())
.andExpect(jsonPath("$", matchNotifyService("service name", "service description",
"service url", "service ldn url")))
"service url", "service ldn url", false)))
.andDo(result ->
idRef.set((read(result.getResponse().getContentAsString(), "$.id"))));
getClient(authToken)
.perform(get("/api/ldn/ldnservices/" + idRef.get()))
.andExpect(status().isOk())
.andExpect(jsonPath("$",
.andExpect(jsonPath("$.notifyServiceInboundPatterns", hasSize(2)))
.andExpect(jsonPath("$.notifyServiceOutboundPatterns", hasSize(1)))
.andExpect(jsonPath("$", allOf(
matchNotifyService(idRef.get(), "service name", "service description",
"service url", "service ldn url")));
"service url", "service ldn url", false),
hasJsonPath("$.notifyServiceInboundPatterns", containsInAnyOrder(
matchNotifyServicePattern("patternA", "itemFilterA", true),
matchNotifyServicePattern("patternB", null, false)
)),
hasJsonPath("$.notifyServiceOutboundPatterns", contains(
matchNotifyServicePattern("patternC", "itemFilterC")
)))
));
}
@Test
@@ -239,6 +267,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.withName("service name")
.withUrl("service url")
.withLdnUrl("service ldn url")
.isEnabled(false)
.build();
context.restoreAuthSystemState();
@@ -255,7 +284,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.contentType(MediaType.APPLICATION_JSON_PATCH_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$", matchNotifyService(notifyServiceEntity.getID(), "service name",
"add service description", "service url", "service ldn url"))
"add service description", "service url", "service ldn url", false))
);
}
@@ -313,7 +342,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.contentType(MediaType.APPLICATION_JSON_PATCH_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$", matchNotifyService(notifyServiceEntity.getID(), "service name",
"service description replaced", "service url", "service ldn url"))
"service description replaced", "service url", "service ldn url", false))
);
}
@@ -328,6 +357,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.withDescription("service description")
.withUrl("service url")
.withLdnUrl("service ldn url")
.isEnabled(false)
.build();
context.restoreAuthSystemState();
@@ -344,7 +374,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.contentType(MediaType.APPLICATION_JSON_PATCH_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$", matchNotifyService(notifyServiceEntity.getID(), "service name",
null, "service url", "service ldn url"))
null, "service url", "service ldn url", false))
);
}
@@ -402,7 +432,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.contentType(MediaType.APPLICATION_JSON_PATCH_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$", matchNotifyService(notifyServiceEntity.getID(), "service name",
"service description", "add service url", "service ldn url"))
"service description", "add service url", "service ldn url", false))
);
}
@@ -444,6 +474,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.withDescription("service description")
.withUrl("service url")
.withLdnUrl("service ldn url")
.isEnabled(true)
.build();
context.restoreAuthSystemState();
@@ -460,7 +491,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.contentType(MediaType.APPLICATION_JSON_PATCH_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$", matchNotifyService(notifyServiceEntity.getID(), "service name",
"service description", "service url replaced", "service ldn url"))
"service description", "service url replaced", "service ldn url", true))
);
}
@@ -776,10 +807,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -821,10 +852,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -873,10 +904,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -918,10 +949,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -970,10 +1001,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -998,7 +1029,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
RemoveOperation inboundRemoveOperation = new RemoveOperation("notifyservices_inbound_patterns[0]");
RemoveOperation inboundRemoveOperation = new RemoveOperation("notifyServiceInboundPatterns[0]");
ops.clear();
ops.add(inboundRemoveOperation);
patchBody = getPatchContent(ops);
@@ -1036,7 +1067,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperation = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperation = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
ops.add(inboundAddOperation);
@@ -1060,7 +1091,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
)));
// index out of the range
RemoveOperation inboundRemoveOperation = new RemoveOperation("notifyservices_inbound_patterns[1]");
RemoveOperation inboundRemoveOperation = new RemoveOperation("notifyServiceInboundPatterns[1]");
ops.clear();
ops.add(inboundRemoveOperation);
patchBody = getPatchContent(ops);
@@ -1088,10 +1119,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -1116,7 +1147,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
RemoveOperation outboundRemoveOperation = new RemoveOperation("notifyservices_outbound_patterns[0]");
RemoveOperation outboundRemoveOperation = new RemoveOperation("notifyServiceOutboundPatterns[0]");
ops.clear();
ops.add(outboundRemoveOperation);
patchBody = getPatchContent(ops);
@@ -1154,7 +1185,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperation = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperation = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
ops.add(outboundAddOperation);
@@ -1178,7 +1209,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
)));
// index out of the range
RemoveOperation outboundRemoveOperation = new RemoveOperation("notifyservices_outbound_patterns[1]");
RemoveOperation outboundRemoveOperation = new RemoveOperation("notifyServiceOutboundPatterns[1]");
ops.clear();
ops.add(outboundRemoveOperation);
patchBody = getPatchContent(ops);
@@ -1206,10 +1237,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":null,\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -1234,7 +1265,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
AddOperation inboundAddOperation = new AddOperation("notifyservices_inbound_patterns[0]/constraint",
AddOperation inboundAddOperation = new AddOperation("notifyServiceInboundPatterns[0]/constraint",
"itemFilterA");
ops.clear();
ops.add(inboundAddOperation);
@@ -1274,10 +1305,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -1302,7 +1333,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
AddOperation inboundAddOperation = new AddOperation("notifyservices_inbound_patterns[0]/constraint",
AddOperation inboundAddOperation = new AddOperation("notifyServiceInboundPatterns[0]/constraint",
"itemFilterA");
ops.clear();
ops.add(inboundAddOperation);
@@ -1332,10 +1363,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -1360,7 +1391,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyservices_inbound_patterns[0]/constraint",
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyServiceInboundPatterns[0]/constraint",
"itemFilterC");
ops.clear();
ops.add(inboundReplaceOperation);
@@ -1400,10 +1431,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":null,\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -1428,7 +1459,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyservices_inbound_patterns[0]/constraint",
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyServiceInboundPatterns[0]/constraint",
"itemFilterA");
ops.clear();
ops.add(inboundReplaceOperation);
@@ -1458,10 +1489,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -1486,7 +1517,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
RemoveOperation inboundRemoveOperation = new RemoveOperation("notifyservices_inbound_patterns[1]/constraint");
RemoveOperation inboundRemoveOperation = new RemoveOperation("notifyServiceInboundPatterns[1]/constraint");
ops.clear();
ops.add(inboundRemoveOperation);
patchBody = getPatchContent(ops);
@@ -1525,7 +1556,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperation = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperation = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
ops.add(inboundAddOperation);
@@ -1549,7 +1580,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
)));
// index out of the range
RemoveOperation inboundRemoveOperation = new RemoveOperation("notifyservices_inbound_patterns[1]/constraint");
RemoveOperation inboundRemoveOperation = new RemoveOperation("notifyServiceInboundPatterns[1]/constraint");
ops.clear();
ops.add(inboundRemoveOperation);
patchBody = getPatchContent(ops);
@@ -1577,10 +1608,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":null}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":null}");
ops.add(outboundAddOperationOne);
@@ -1605,7 +1636,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
AddOperation outboundAddOperation = new AddOperation("notifyservices_outbound_patterns[1]/constraint",
AddOperation outboundAddOperation = new AddOperation("notifyServiceOutboundPatterns[1]/constraint",
"itemFilterB");
ops.clear();
ops.add(outboundAddOperation);
@@ -1645,10 +1676,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -1673,7 +1704,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
AddOperation outboundAddOperation = new AddOperation("notifyservices_outbound_patterns[1]/constraint",
AddOperation outboundAddOperation = new AddOperation("notifyServiceOutboundPatterns[1]/constraint",
"itemFilterB");
ops.clear();
ops.add(outboundAddOperation);
@@ -1703,10 +1734,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -1732,7 +1763,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
)));
ReplaceOperation outboundReplaceOperation = new ReplaceOperation(
"notifyservices_outbound_patterns[1]/constraint", "itemFilterD");
"notifyServiceOutboundPatterns[1]/constraint", "itemFilterD");
ops.clear();
ops.add(outboundReplaceOperation);
patchBody = getPatchContent(ops);
@@ -1771,10 +1802,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":null}");
ops.add(outboundAddOperationOne);
@@ -1800,7 +1831,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
)));
ReplaceOperation outboundReplaceOperation = new ReplaceOperation(
"notifyservices_outbound_patterns[1]/constraint", "itemFilterB");
"notifyServiceOutboundPatterns[1]/constraint", "itemFilterB");
ops.clear();
ops.add(outboundReplaceOperation);
patchBody = getPatchContent(ops);
@@ -1829,10 +1860,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -1857,7 +1888,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
RemoveOperation outboundRemoveOperation = new RemoveOperation("notifyservices_outbound_patterns[0]/constraint");
RemoveOperation outboundRemoveOperation = new RemoveOperation("notifyServiceOutboundPatterns[0]/constraint");
ops.clear();
ops.add(outboundRemoveOperation);
patchBody = getPatchContent(ops);
@@ -1896,7 +1927,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperation = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperation = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
ops.add(outboundAddOperation);
@@ -1920,7 +1951,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
)));
// index out of the range
RemoveOperation outboundRemoveOperation = new RemoveOperation("notifyservices_outbound_patterns[1]/constraint");
RemoveOperation outboundRemoveOperation = new RemoveOperation("notifyServiceOutboundPatterns[1]/constraint");
ops.clear();
ops.add(outboundRemoveOperation);
patchBody = getPatchContent(ops);
@@ -1948,10 +1979,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":null,\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -1976,7 +2007,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
AddOperation inboundAddOperation = new AddOperation("notifyservices_inbound_patterns[0]/pattern",
AddOperation inboundAddOperation = new AddOperation("notifyServiceInboundPatterns[0]/pattern",
"patternA");
ops.clear();
ops.add(inboundAddOperation);
@@ -2016,10 +2047,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -2044,7 +2075,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
AddOperation inboundAddOperation = new AddOperation("notifyservices_inbound_patterns[0]/pattern",
AddOperation inboundAddOperation = new AddOperation("notifyServiceInboundPatterns[0]/pattern",
"patternA");
ops.clear();
ops.add(inboundAddOperation);
@@ -2074,10 +2105,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -2102,7 +2133,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyservices_inbound_patterns[0]/pattern",
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyServiceInboundPatterns[0]/pattern",
"patternC");
ops.clear();
ops.add(inboundReplaceOperation);
@@ -2142,10 +2173,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":null,\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -2170,7 +2201,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyservices_inbound_patterns[0]/pattern",
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyServiceInboundPatterns[0]/pattern",
"patternA");
ops.clear();
ops.add(inboundReplaceOperation);
@@ -2200,10 +2231,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -2228,7 +2259,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyservices_inbound_patterns[0]/automatic",
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyServiceInboundPatterns[0]/automatic",
"true");
ops.clear();
ops.add(inboundReplaceOperation);
@@ -2268,10 +2299,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -2296,7 +2327,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyservices_inbound_patterns[0]/automatic",
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyServiceInboundPatterns[0]/automatic",
"test");
ops.clear();
ops.add(inboundReplaceOperation);
@@ -2326,10 +2357,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":null,\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -2354,7 +2385,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
AddOperation outboundAddOperation = new AddOperation("notifyservices_outbound_patterns[1]/pattern",
AddOperation outboundAddOperation = new AddOperation("notifyServiceOutboundPatterns[1]/pattern",
"patternB");
ops.clear();
ops.add(outboundAddOperation);
@@ -2394,10 +2425,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -2422,7 +2453,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
AddOperation outboundAddOperation = new AddOperation("notifyservices_outbound_patterns[1]/pattern",
AddOperation outboundAddOperation = new AddOperation("notifyServiceOutboundPatterns[1]/pattern",
"patternB");
ops.clear();
ops.add(outboundAddOperation);
@@ -2452,10 +2483,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -2480,7 +2511,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyservices_outbound_patterns[1]/pattern",
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyServiceOutboundPatterns[1]/pattern",
"patternD");
ops.clear();
ops.add(outboundReplaceOperation);
@@ -2520,10 +2551,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":null,\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -2548,7 +2579,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyservices_outbound_patterns[1]/pattern",
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyServiceOutboundPatterns[1]/pattern",
"patternB");
ops.clear();
ops.add(outboundReplaceOperation);
@@ -2578,10 +2609,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -2606,7 +2637,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyservices_inbound_patterns",
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyServiceInboundPatterns",
"[{\"pattern\":\"patternC\",\"constraint\":\"itemFilterC\",\"automatic\":\"true\"}," +
"{\"pattern\":\"patternD\",\"constraint\":\"itemFilterD\",\"automatic\":\"true\"}]");
ops.clear();
@@ -2647,10 +2678,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -2676,7 +2707,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
)));
// empty array will only remove all old patterns
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyservices_inbound_patterns", "[]");
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyServiceInboundPatterns", "[]");
ops.clear();
ops.add(inboundReplaceOperation);
patchBody = getPatchContent(ops);
@@ -2706,10 +2737,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -2735,7 +2766,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
)));
// value must be an array not object
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyservices_inbound_patterns",
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyServiceInboundPatterns",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.clear();
ops.add(inboundReplaceOperation);
@@ -2764,10 +2795,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -2792,7 +2823,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyservices_outbound_patterns",
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyServiceOutboundPatterns",
"[{\"pattern\":\"patternC\",\"constraint\":\"itemFilterC\"}," +
"{\"pattern\":\"patternD\",\"constraint\":\"itemFilterD\"}]");
ops.clear();
@@ -2833,10 +2864,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -2862,7 +2893,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
)));
// empty array will only remove all old patterns
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyservices_outbound_patterns", "[]");
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyServiceOutboundPatterns", "[]");
ops.clear();
ops.add(outboundReplaceOperation);
patchBody = getPatchContent(ops);
@@ -2892,10 +2923,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -2921,7 +2952,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
)));
// value must be an array not object
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyservices_outbound_patterns",
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyServiceOutboundPatterns",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.clear();
ops.add(outboundReplaceOperation);
@@ -2950,10 +2981,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -2978,7 +3009,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
RemoveOperation inboundRemoveOperation = new RemoveOperation("notifyservices_inbound_patterns");
RemoveOperation inboundRemoveOperation = new RemoveOperation("notifyServiceInboundPatterns");
ops.clear();
ops.add(inboundRemoveOperation);
patchBody = getPatchContent(ops);
@@ -3008,10 +3039,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -3036,7 +3067,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
RemoveOperation outboundRemoveOperation = new RemoveOperation("notifyservices_outbound_patterns");
RemoveOperation outboundRemoveOperation = new RemoveOperation("notifyServiceOutboundPatterns");
ops.clear();
ops.add(outboundRemoveOperation);
patchBody = getPatchContent(ops);
@@ -3066,10 +3097,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation inboundAddOperationOne = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationOne = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\",\"automatic\":\"false\"}");
AddOperation inboundAddOperationTwo = new AddOperation("notifyservices_inbound_patterns/-",
AddOperation inboundAddOperationTwo = new AddOperation("notifyServiceInboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\",\"automatic\":\"true\"}");
ops.add(inboundAddOperationOne);
@@ -3094,7 +3125,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyservices_inbound_patterns[1]",
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("notifyServiceInboundPatterns[1]",
"{\"pattern\":\"patternC\",\"constraint\":\"itemFilterC\",\"automatic\":\"false\"}");
ops.clear();
ops.add(inboundReplaceOperation);
@@ -3134,10 +3165,10 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
AddOperation outboundAddOperationOne = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationOne = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternA\",\"constraint\":\"itemFilterA\"}");
AddOperation outboundAddOperationTwo = new AddOperation("notifyservices_outbound_patterns/-",
AddOperation outboundAddOperationTwo = new AddOperation("notifyServiceOutboundPatterns/-",
"{\"pattern\":\"patternB\",\"constraint\":\"itemFilterB\"}");
ops.add(outboundAddOperationOne);
@@ -3162,7 +3193,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
))
)));
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyservices_outbound_patterns[0]",
ReplaceOperation outboundReplaceOperation = new ReplaceOperation("notifyServiceOutboundPatterns[0]",
"{\"pattern\":\"patternC\",\"constraint\":\"itemFilterC\"}");
ops.clear();
ops.add(outboundReplaceOperation);
@@ -3186,4 +3217,62 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
)));
}
@Test
public void NotifyServiceStatusReplaceOperationTest() throws Exception {
context.turnOffAuthorisationSystem();
NotifyServiceEntity notifyServiceEntity =
NotifyServiceBuilder.createNotifyServiceBuilder(context)
.withName("service name")
.withDescription("service description")
.withUrl("service url")
.withLdnUrl("service ldn url")
.isEnabled(true)
.build();
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("/enabled", "false");
ops.add(inboundReplaceOperation);
String patchBody = getPatchContent(ops);
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken)
.perform(patch("/api/ldn/ldnservices/" + notifyServiceEntity.getID())
.content(patchBody)
.contentType(MediaType.APPLICATION_JSON_PATCH_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.notifyServiceInboundPatterns", empty()))
.andExpect(jsonPath("$.notifyServiceOutboundPatterns", empty()))
.andExpect(jsonPath("$", matchNotifyService(notifyServiceEntity.getID(), "service name",
"service description", "service url", "service ldn url", false)));
}
@Test
public void NotifyServiceStatusReplaceOperationTestBadRequestTest() throws Exception {
context.turnOffAuthorisationSystem();
NotifyServiceEntity notifyServiceEntity =
NotifyServiceBuilder.createNotifyServiceBuilder(context)
.withName("service name")
.withDescription("service description")
.withUrl("service url")
.withLdnUrl("service ldn url")
.build();
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("/enabled", "test");
ops.add(inboundReplaceOperation);
String patchBody = getPatchContent(ops);
String authToken = getAuthToken(admin.getEmail(), password);
// patch not boolean value
getClient(authToken)
.perform(patch("/api/ldn/ldnservices/" + notifyServiceEntity.getID())
.content(patchBody)
.contentType(MediaType.APPLICATION_JSON_PATCH_JSON))
.andExpect(status().isBadRequest());
}
}

View File

@@ -37,6 +37,18 @@ public class NotifyServiceMatcher {
);
}
public static Matcher<? super Object> matchNotifyService(String name, String description, String url,
String ldnUrl, boolean enabled) {
return allOf(
hasJsonPath("$.name", is(name)),
hasJsonPath("$.description", is(description)),
hasJsonPath("$.url", is(url)),
hasJsonPath("$.ldnUrl", is(ldnUrl)),
hasJsonPath("$.enabled", is(enabled)),
hasJsonPath("$._links.self.href", containsString("/api/ldn/ldnservices/"))
);
}
public static Matcher<? super Object> matchNotifyService(int id, String name, String description,
String url, String ldnUrl) {
return allOf(
@@ -47,6 +59,16 @@ public class NotifyServiceMatcher {
);
}
public static Matcher<? super Object> matchNotifyService(int id, String name, String description,
String url, String ldnUrl, boolean enabled) {
return allOf(
hasJsonPath("$.id", is(id)),
matchNotifyService(name, description, url, ldnUrl, enabled),
hasJsonPath("$._links.self.href", startsWith(REST_SERVER_URL)),
hasJsonPath("$._links.self.href", endsWith("/api/ldn/ldnservices/" + id))
);
}
public static Matcher<? super Object> matchNotifyServicePattern(String pattern, String constraint) {
return allOf(
hasJsonPath("$.pattern", is(pattern)),

View File

@@ -24,7 +24,7 @@
"id": "urn:uuid:94ecae35-dcfd-4182-8550-22c7164fe23f",
"inReplyTo": "urn:uuid:0370c0fb-bb78-4a9b-87f5-bed307a509dd",
"object": {
"id": "https://overlay-journal.com/articles/00001/",
"id": "<<object>>",
"ietf:cite-as": "https://overlay-journal.com/articles/00001/",
"type": [
"Page",