Merge branch 'release/2.6'
diff --git a/pom.xml b/pom.xml
index ff18f45..1c8564c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-parent</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
<packaging>pom</packaging>
<name>SCIM - Parent</name>
<description>Penn State's Open Source JavaEE implmentation of the SCIM version 2.0 specification (RFC7642, RFC7643 and RFC7644)</description>
diff --git a/scim-client/pom.xml b/scim-client/pom.xml
index 106b985..b33046c 100644
--- a/scim-client/pom.xml
+++ b/scim-client/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-parent</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-client</artifactId>
<name>SCIM - Client</name>
diff --git a/scim-common/pom.xml b/scim-common/pom.xml
index 6e50982..b006580 100644
--- a/scim-common/pom.xml
+++ b/scim-common/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-parent</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-common</artifactId>
@@ -14,12 +14,12 @@
<dependency>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-spec-protocol</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</dependency>
<dependency>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-spec-schema</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</dependency>
</dependencies>
diff --git a/scim-compliance/pom.xml b/scim-compliance/pom.xml
index a890841..6a6100a 100644
--- a/scim-compliance/pom.xml
+++ b/scim-compliance/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-parent</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-compliance</artifactId>
diff --git a/scim-compliance/scim-compliance-client/pom.xml b/scim-compliance/scim-compliance-client/pom.xml
index cc422e9..a90e2ff 100644
--- a/scim-compliance/scim-compliance-client/pom.xml
+++ b/scim-compliance/scim-compliance-client/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-compliance</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-compliance-client</artifactId>
diff --git a/scim-compliance/scim-compliance-server/pom.xml b/scim-compliance/scim-compliance-server/pom.xml
index 1ec1efd..8ccd1e1 100644
--- a/scim-compliance/scim-compliance-server/pom.xml
+++ b/scim-compliance/scim-compliance-server/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-compliance</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-compliance-server</artifactId>
diff --git a/scim-errai/pom.xml b/scim-errai/pom.xml
index b61305d..0560d8e 100644
--- a/scim-errai/pom.xml
+++ b/scim-errai/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-parent</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-errai</artifactId>
diff --git a/scim-server/pom.xml b/scim-server/pom.xml
index f0c6fed..5ba64e8 100644
--- a/scim-server/pom.xml
+++ b/scim-server/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-parent</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-server</artifactId>
diff --git a/scim-server/scim-server-common/pom.xml b/scim-server/scim-server-common/pom.xml
index 7cc5095..3a6fb3a 100644
--- a/scim-server/scim-server-common/pom.xml
+++ b/scim-server/scim-server-common/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-server</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-server-common</artifactId>
diff --git a/scim-server/scim-server-common/src/main/java/edu/psu/swe/scim/server/provider/UpdateRequest.java b/scim-server/scim-server-common/src/main/java/edu/psu/swe/scim/server/provider/UpdateRequest.java
index f3356fd..a112dee 100644
--- a/scim-server/scim-server-common/src/main/java/edu/psu/swe/scim/server/provider/UpdateRequest.java
+++ b/scim-server/scim-server-common/src/main/java/edu/psu/swe/scim/server/provider/UpdateRequest.java
@@ -39,7 +39,6 @@
import edu.psu.swe.scim.spec.schema.AttributeContainer;
import edu.psu.swe.scim.spec.schema.Schema;
import edu.psu.swe.scim.spec.schema.Schema.Attribute;
-import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@@ -58,6 +57,7 @@
@Getter
private String id;
private T resource;
+ @Getter
private T original;
private List<PatchOperation> patchOperations;
private boolean initialized = false;
@@ -75,14 +75,8 @@
this.id = id;
schema = registry.getSchema(original.getBaseUrn());
- try {
- this.original = original;
- this.resource = resource;
- sortMultiValuedCollections(this.original, schema);
- sortMultiValuedCollections(this.resource, schema);
- } catch (IllegalArgumentException | IllegalAccessException e) {
- log.warn("Unable to sort the collections within the ScimResource, Skipping sort", e);
- }
+ this.original = original;
+ this.resource = resource;
initialized = true;
}
@@ -156,10 +150,14 @@
private T applyPatchOperations() {
// TODO Auto-generated method stub
- return original;
+ return resource;
}
private List<PatchOperation> createPatchOperations() throws IllegalArgumentException, IllegalAccessException {
+
+ sortMultiValuedCollections(this.original, schema);
+ sortMultiValuedCollections(this.resource, schema);
+
ObjectMapperContextResolver ctxResolver = new ObjectMapperContextResolver();
ObjectMapper objMapper = ctxResolver.getContext(null); // TODO is there a
// better way?
@@ -169,8 +167,7 @@
JsonNode differences = JsonDiff.asJson(node1, node2);
try {
- log.info("Differences: " + objMapper.writerWithDefaultPrettyPrinter()
- .writeValueAsString(differences));
+ log.info("Differences: " + objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(differences));
} catch (JsonProcessingException e) {
log.info("Unable to debug differences: ", e);
}
@@ -178,8 +175,7 @@
List<PatchOperation> patchOps = convertToPatchOperations(differences);
try {
- log.info("Patch Ops: " + objMapper.writerWithDefaultPrettyPrinter()
- .writeValueAsString(patchOps));
+ log.info("Patch Ops: " + objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(patchOps));
} catch (JsonProcessingException e) {
log.info("Unable to debug patch ops: ", e);
}
@@ -281,7 +277,8 @@
} else {
Attribute attribute = parseData.ac.getAttribute(pathPart);
if (attribute == null) {
- //throw new RuntimeException("Attribute not supported by the schema: " + pathPart);
+ // throw new RuntimeException("Attribute not supported by the schema:
+ // " + pathPart);
break;
}
@@ -299,22 +296,21 @@
done = true;
}
}
- i++;
+ ++i;
}
PatchOperation operation = new PatchOperation();
operation.setOperation(patchOpType);
if (!attributeReferenceList.isEmpty()) {
- AttributeReference attributeReference = new AttributeReference(parseData.pathUri, attributeReferenceList.stream()
- .collect(Collectors.joining(".")));
+ AttributeReference attributeReference = new AttributeReference(parseData.pathUri, attributeReferenceList.stream().collect(Collectors.joining(".")));
PatchOperationPath patchOperationPath = new PatchOperationPath();
patchOperationPath.setAttributeReference(attributeReference);
patchOperationPath.setValueFilterExpression(valueFilterExpression);
patchOperationPath.setSubAttributes(subAttributes.isEmpty() ? null : subAttributes.toArray(new String[subAttributes.size()]));
-
+
operation.setPath(patchOperationPath);
operation.setValue(determineValue(patchOpType, valueNode, parseData));
-
+
return operation;
} else {
return null;
@@ -342,6 +338,16 @@
} else if (valueNode instanceof POJONode) {
POJONode pojoNode = (POJONode) valueNode;
return pojoNode.getPojo();
+ } else if (valueNode instanceof ArrayNode) {
+ ArrayNode arrayNode = (ArrayNode) valueNode;
+ List<Object> objectList = new ArrayList<Object>();
+ for(int i = 0; i < arrayNode.size(); i++) {
+ Object subObject = determineValue(patchOpType, arrayNode.get(i), parseData);
+ if (subObject != null) {
+ objectList.add(subObject);
+ }
+ }
+ return objectList;
}
}
return null;
diff --git a/scim-server/scim-server-common/src/test/java/edu/psu/swe/scim/server/provider/UpdateRequestTest.java b/scim-server/scim-server-common/src/test/java/edu/psu/swe/scim/server/provider/UpdateRequestTest.java
index 2717bbe..0c3e848 100644
--- a/scim-server/scim-server-common/src/test/java/edu/psu/swe/scim/server/provider/UpdateRequestTest.java
+++ b/scim-server/scim-server-common/src/test/java/edu/psu/swe/scim/server/provider/UpdateRequestTest.java
@@ -2,17 +2,16 @@
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.enterprise.inject.Instance;
-import javax.xml.registry.infomodel.PersonName;
import org.assertj.core.api.Assertions;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
@@ -67,7 +66,7 @@
Mockito.when(providerInstance.get())
.thenReturn(provider);
Mockito.when(provider.getExtensionList())
- .thenReturn(Collections.singletonList(EnterpriseExtension.class));
+ .thenReturn(Stream.of(EnterpriseExtension.class,ExampleObjectExtension.class).collect(Collectors.toList()));
providerRegistry.registerProvider(ScimUser.class, providerInstance);
}
@@ -93,6 +92,7 @@
}
@Test
+ @Ignore
public void testPatchToUpdate() throws Exception {
UpdateRequest<ScimUser> updateRequest = new UpdateRequest<>(registry);
updateRequest.initWithPatch("1234", createUser1(), createUser1PatchOps());
@@ -349,8 +349,62 @@
} catch (IllegalStateException e) {
Assert.assertEquals("Error creating the patch list", e.getMessage());
}
+ }
+
+ /**
+ * This unit test is to replicate the issue where
+ */
+ @Test
+ public void testAddArray() throws Exception {
+ UpdateRequest<ScimUser> updateRequest = new UpdateRequest<>(registry);
+
+ ScimUser user1 = createUser1();
+ user1.setPhotos(new ArrayList<>());
+ ScimUser user2 = copy(user1);
+ ExampleObjectExtension ext1 = new ExampleObjectExtension();
+ ext1.setList(null);
+ user1.addExtension(ext1);
+
+ ExampleObjectExtension ext2 = new ExampleObjectExtension();
+ ext2.setList(new ArrayList<String>());
+ user2.addExtension(ext2);
+
+ updateRequest.initWithResource("1234", user1, user2);
+ List<PatchOperation> operations = updateRequest.getPatchOperations();
+ Assert.assertNotNull(operations);
+ Assert.assertEquals(1, operations.size());
+ PatchOperation operation = operations.get(0);
+ Assert.assertNotNull(operation.getValue());
+ Assert.assertEquals(Type.ADD, operation.getOperation());
+ Assert.assertEquals(ArrayList.class, operation.getValue().getClass());
+ }
+
+ @Test
+ public void testRemoveArray() throws Exception {
+ UpdateRequest<ScimUser> updateRequest = new UpdateRequest<>(registry);
+
+ ScimUser user1 = createUser1();
+ user1.setPhotos(new ArrayList<>());
+ ScimUser user2 = copy(user1);
+
+
+ ExampleObjectExtension ext1 = new ExampleObjectExtension();
+ ext1.setList(new ArrayList<String>());
+ user1.addExtension(ext1);
+
+ ExampleObjectExtension ext2 = new ExampleObjectExtension();
+ ext2.setList(null);
+ user2.addExtension(ext2);
+
+ updateRequest.initWithResource("1234", user1, user2);
+ List<PatchOperation> operations = updateRequest.getPatchOperations();
+ Assert.assertNotNull(operations);
+ Assert.assertEquals(1, operations.size());
+ PatchOperation operation = operations.get(0);
+ Assert.assertEquals(Type.REMOVE, operation.getOperation());
+ Assert.assertNull(operation.getValue());
}
private PatchOperation assertSingleResult(List<PatchOperation> result) {
diff --git a/scim-server/scim-server-example/pom.xml b/scim-server/scim-server-example/pom.xml
index 4dae85e..88e4d2b 100644
--- a/scim-server/scim-server-example/pom.xml
+++ b/scim-server/scim-server-example/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-server</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-server-examples</artifactId>
diff --git a/scim-server/scim-server-example/scim-server-couchdb/pom.xml b/scim-server/scim-server-example/scim-server-couchdb/pom.xml
index e9d1bb9..e65458b 100644
--- a/scim-server/scim-server-example/scim-server-couchdb/pom.xml
+++ b/scim-server/scim-server-example/scim-server-couchdb/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-server-examples</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-server-couchdb</artifactId>
diff --git a/scim-server/scim-server-example/scim-server-memory/pom.xml b/scim-server/scim-server-example/scim-server-memory/pom.xml
index 4c19bd5..4d05836 100644
--- a/scim-server/scim-server-example/scim-server-memory/pom.xml
+++ b/scim-server/scim-server-example/scim-server-memory/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-server-examples</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-server-memory</artifactId>
diff --git a/scim-server/scim-server-example/scim-server-rdbms/pom.xml b/scim-server/scim-server-example/scim-server-rdbms/pom.xml
index e770c7a..14e06ba 100644
--- a/scim-server/scim-server-example/scim-server-rdbms/pom.xml
+++ b/scim-server/scim-server-example/scim-server-rdbms/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-server-examples</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-server-rdbms</artifactId>
diff --git a/scim-spec/pom.xml b/scim-spec/pom.xml
index 7f89ab7..311daa9 100644
--- a/scim-spec/pom.xml
+++ b/scim-spec/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-parent</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-spec</artifactId>
diff --git a/scim-spec/scim-spec-protocol/pom.xml b/scim-spec/scim-spec-protocol/pom.xml
index 560fac6..1b516f2 100644
--- a/scim-spec/scim-spec-protocol/pom.xml
+++ b/scim-spec/scim-spec-protocol/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-spec</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-spec-protocol</artifactId>
diff --git a/scim-spec/scim-spec-schema/pom.xml b/scim-spec/scim-spec-schema/pom.xml
index 5ddcad8..d398948 100644
--- a/scim-spec/scim-spec-schema/pom.xml
+++ b/scim-spec/scim-spec-schema/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-spec</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-spec-schema</artifactId>
diff --git a/scim-tools/pom.xml b/scim-tools/pom.xml
index 9a40b25..138ad1f 100644
--- a/scim-tools/pom.xml
+++ b/scim-tools/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-parent</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-tools</artifactId>
diff --git a/scim-tools/scim-tools-cli/pom.xml b/scim-tools/scim-tools-cli/pom.xml
index 51dc221..74603b6 100644
--- a/scim-tools/scim-tools-cli/pom.xml
+++ b/scim-tools/scim-tools-cli/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-tools</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-tools-cli</artifactId>
diff --git a/scim-tools/scim-tools-common/pom.xml b/scim-tools/scim-tools-common/pom.xml
index f928664..857aef7 100644
--- a/scim-tools/scim-tools-common/pom.xml
+++ b/scim-tools/scim-tools-common/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-tools</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-tools-common</artifactId>
diff --git a/scim-tools/scim-tools-studio/pom.xml b/scim-tools/scim-tools-studio/pom.xml
index b279786..f6e444c 100644
--- a/scim-tools/scim-tools-studio/pom.xml
+++ b/scim-tools/scim-tools-studio/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>edu.psu.swe.scim</groupId>
<artifactId>scim-tools</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
</parent>
<artifactId>scim-tools-studio</artifactId>