Skip to content

Commit

Permalink
Replaced zjsonpatch based resource diffing with Attribute based solut…
Browse files Browse the repository at this point in the history
…ion (#435)

The json patch solution required seralizing objects, then processing them with zjsonpatch, and finally some heavy post processing.

This new solution walks the tree schema attributes to calculate the diff directly.
Class was moved to scim-tools, as it's not directly used by scim-server or scim-client.
PatchGenerator could be used by a SCIM client to calculate diffs to send to a server
Or to generate patch requests when testing a server.

NOTE: There are some limitations, this implementation assumes any changes to an object in a collection modifies the whole object,
this will alwasy trigger a REMOVE and ADD operation (instead of a REPLACE).
  • Loading branch information
bdemers authored Dec 15, 2023
1 parent 677288a commit 03d4314
Show file tree
Hide file tree
Showing 8 changed files with 609 additions and 951 deletions.
5 changes: 0 additions & 5 deletions scim-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.flipkart.zjsonpatch</groupId>
<artifactId>zjsonpatch</artifactId>
<version>0.4.14</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
public final class Schemas {

private static final String STRING_TYPE_IDENTIFIER = "class java.lang.String";
private static final String STRING_TYPE = "java.lang.String"; // TODO this is ugly
private static final String CHARACTER_ARRAY_TYPE_IDENTIFIER = "class [C";
private static final String BIG_C_CHARACTER_ARRAY_TYPE_IDENTIFIER = "class [Ljava.lang.Character;";
private static final String INT_TYPE_IDENTIFIER = "int";
Expand Down Expand Up @@ -201,6 +202,7 @@ private static List<Schema.Attribute> createAttributes(String urn, List<Field> f
log.debug("Attempting to set the attribute type, raw value = " + typeName);
switch (typeName) {
case STRING_TYPE_IDENTIFIER:
case STRING_TYPE:
case CHARACTER_ARRAY_TYPE_IDENTIFIER:
case BIG_C_CHARACTER_ARRAY_TYPE_IDENTIFIER:
log.debug("Setting type to String");
Expand Down
31 changes: 28 additions & 3 deletions scim-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,40 @@
<artifactId>scim-spec-schema</artifactId>
</dependency>
<dependency>
<groupId>com.github.foodev</groupId>
<artifactId>jsondiff</artifactId>
<version>2.0.0</version>
<groupId>org.apache.directory.scimple</groupId>
<artifactId>scim-core</artifactId>
</dependency>

<dependency>
<groupId>org.apache.directory.scimple</groupId>
<artifactId>scim-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit 03d4314

Please sign in to comment.