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
,ConfigComment
,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 a patch-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 configured output
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
doService
(AdaptrisMessage msg) getFlags()
void
prepare()
void
setFlags
(List<PatchApplyFlag> flags) Specify any additional flags for the patch operation.void
setPatchSource
(MessageWrapper<InputStream> patchSource) Set the source of the JSON patch transformation.void
setSource
(MessageWrapper<InputStream> source) Set the source document that will have the JSON Patch applied to it.withFlags
(PatchApplyFlag... flags) withFlags
(List<PatchApplyFlag> flags) withPatchSource
(MessageWrapper<InputStream> source) withSource
(MessageWrapper<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, enabled, getComments, getContinueOnFail, getEnabled, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setComments, setContinueOnFail, setEnabled, setIsTrackingEndpoint, setUniqueId, start, stop
-
Constructor Details
-
ApplyPatchService
public ApplyPatchService()
-
-
Method Details
-
doService
- Throws:
ServiceException
-
prepare
- Throws:
CoreException
-
getPatchSource
-
setPatchSource
Set the source of the JSON patch transformation.- Parameters:
patchSource
- the patch source.
-
getSource
-
setSource
Set the source document that will have the JSON Patch applied to it.- Parameters:
source
- the source; default isPayloadStreamInputParameter
.
-
withPatchSource
-
withSource
-
getFlags
-
setFlags
Specify any additional flags for the patch operation.- Parameters:
flags
- the flags.
-
withFlags
-
withFlags
-