Package com.adaptris.core.json.jsonpatch
Class ApplyPatchService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.json.jsonpatch.JsonPatchService
-
- com.adaptris.core.json.jsonpatch.ApplyPatchService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Apply a JSON patch diff to a document", tag="service,json,jsonpatch", since="3.9.0") public class ApplyPatchService extends JsonPatchService
Apply a JSON patch diff.JSON Patch defines a JSON document structure for expressing a sequence of operations to apply to a JavaScript Object Notation (JSON) document.
For a given
source
of{"a": 0,"b": [1,2]}
and apatch-source
of[{"op":"move","from":"/a","path":"/b/2"}]
then when executing this service you would expect to get{"b": [1,2,0]}
to be stored against the configuredoutput
parameter.Note that zjsonpatch operates on JsonNode objects; this means keeping the node trees in memory, so behaviour will be size/memory dependent.
In the adapter configuration file this class is aliased as json-patch-apply which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.json.jsonpatch.JsonPatchService
mapper
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description ApplyPatchService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doService(AdaptrisMessage msg)
java.util.List<PatchApplyFlag>
getFlags()
MessageWrapper<java.io.InputStream>
getPatchSource()
MessageWrapper<java.io.InputStream>
getSource()
void
prepare()
void
setFlags(java.util.List<PatchApplyFlag> flags)
Specify any additional flags for the patch operation.void
setPatchSource(MessageWrapper<java.io.InputStream> patchSource)
Set the source of the JSON patch transformation.void
setSource(MessageWrapper<java.io.InputStream> source)
Set the source document that will have the JSON Patch applied to it.ApplyPatchService
withFlags(PatchApplyFlag... flags)
ApplyPatchService
withFlags(java.util.List<PatchApplyFlag> flags)
ApplyPatchService
withPatchSource(MessageWrapper<java.io.InputStream> source)
ApplyPatchService
withSource(MessageWrapper<java.io.InputStream> source)
-
Methods inherited from class com.adaptris.core.json.jsonpatch.JsonPatchService
closeService, getOutput, initService, output, readAndClose, setOutput, withOutput, writeAndClose
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
-
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
- Throws:
ServiceException
-
prepare
public void prepare() throws CoreException
- Throws:
CoreException
-
getPatchSource
public MessageWrapper<java.io.InputStream> getPatchSource()
-
setPatchSource
public void setPatchSource(MessageWrapper<java.io.InputStream> patchSource)
Set the source of the JSON patch transformation.- Parameters:
patchSource
- the patch source.
-
getSource
public MessageWrapper<java.io.InputStream> getSource()
-
setSource
public void setSource(MessageWrapper<java.io.InputStream> source)
Set the source document that will have the JSON Patch applied to it.- Parameters:
source
- the source; default isPayloadStreamInputParameter
.
-
withPatchSource
public ApplyPatchService withPatchSource(MessageWrapper<java.io.InputStream> source)
-
withSource
public ApplyPatchService withSource(MessageWrapper<java.io.InputStream> source)
-
getFlags
public java.util.List<PatchApplyFlag> getFlags()
-
setFlags
public void setFlags(java.util.List<PatchApplyFlag> flags)
Specify any additional flags for the patch operation.- Parameters:
flags
- the flags.
-
withFlags
public ApplyPatchService withFlags(java.util.List<PatchApplyFlag> flags)
-
withFlags
public ApplyPatchService withFlags(PatchApplyFlag... flags)
-
-