Class ScimPatchApplier

java.lang.Object
org.mockserver.scim.ScimPatchApplier

public class ScimPatchApplier extends Object
Applies a SCIM 2.0 PatchOp (urn:ietf:params:scim:api:messages:2.0:PatchOp) to a stored resource. Supports the three operations — add, replace, remove — over a deliberately small path grammar: a top-level attribute (emails) or a one-level sub-attribute (name.familyName).

Semantics:

  • replace with a path — set the attribute to the supplied value.
  • replace without a path — shallow-merge the supplied value object into the resource.
  • add with a path — set a scalar/object, or append to an array attribute (e.g. emails, members).
  • add without a path — shallow-merge the supplied value object.
  • remove with a path — delete the attribute (or sub-attribute).

The SCIM-managed reserved attributes id, meta and schemas are readOnly (RFC 7644 §3.5.2). PatchOps that target them — whether by an explicit path (e.g. "path":"meta") or by a no-path merge — are silently ignored as no-ops so a client cannot overwrite the SCIM envelope or the server-managed metadata on the stored copy. Ignoring (rather than returning a 400 mutability error) keeps the mock non-breaking and consistent across add/replace/remove.

A malformed PatchOp throws ScimPatchApplier.ScimPatchException carrying the invalidSyntax SCIM error keyword so the caller can emit a 400 error envelope.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Signals a malformed PatchOp; carries the SCIM scimType keyword.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.fasterxml.jackson.databind.node.ObjectNode
    apply(com.fasterxml.jackson.databind.node.ObjectNode resource, com.fasterxml.jackson.databind.node.ObjectNode patchOp)
    Applies the patch document to a copy of the resource and returns the patched copy.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ScimPatchApplier

      public ScimPatchApplier()
  • Method Details

    • apply

      public com.fasterxml.jackson.databind.node.ObjectNode apply(com.fasterxml.jackson.databind.node.ObjectNode resource, com.fasterxml.jackson.databind.node.ObjectNode patchOp)
      Applies the patch document to a copy of the resource and returns the patched copy.
      Parameters:
      resource - the stored resource (not mutated)
      patchOp - the PatchOp document
      Throws:
      ScimPatchApplier.ScimPatchException - if the document is malformed