public class JsonPatchClientSynchronizer extends Object implements ClientSynchronizer<com.fasterxml.jackson.databind.JsonNode,JsonPatchEdit>
ServerSynchronizer implementation that can handle text documents.| Constructor and Description |
|---|
JsonPatchClientSynchronizer() |
| Modifier and Type | Method and Description |
|---|---|
void |
addContent(com.fasterxml.jackson.databind.JsonNode content,
com.fasterxml.jackson.databind.node.ObjectNode objectNode,
String fieldName)
Adds the content of the passed in
content to the ObjectNode. |
static String |
checksum(com.fasterxml.jackson.databind.JsonNode content) |
JsonPatchEdit |
clientDiff(ShadowDocument<com.fasterxml.jackson.databind.JsonNode> shadowDocument,
ClientDocument<com.fasterxml.jackson.databind.JsonNode> document)
|
PatchMessage<JsonPatchEdit> |
createPatchMessage(String documentId,
String clientId,
Queue<JsonPatchEdit> edits)
Creates a new
PatchMessage with the with the type of Edit that this
synchronizer can handle. |
ClientDocument<com.fasterxml.jackson.databind.JsonNode> |
patchDocument(JsonPatchEdit edit,
ClientDocument<com.fasterxml.jackson.databind.JsonNode> document)
Called when the document should be patched.
|
PatchMessage<JsonPatchEdit> |
patchMessageFromJson(String json)
Creates a {link PatchMessage} by parsing the passed-in json.
|
ShadowDocument<com.fasterxml.jackson.databind.JsonNode> |
patchShadow(JsonPatchEdit edit,
ShadowDocument<com.fasterxml.jackson.databind.JsonNode> shadowDocument)
Called when the shadow should be patched.
|
JsonPatchEdit |
serverDiff(ClientDocument<com.fasterxml.jackson.databind.JsonNode> document,
ShadowDocument<com.fasterxml.jackson.databind.JsonNode> shadowDocument)
|
public JsonPatchEdit clientDiff(ShadowDocument<com.fasterxml.jackson.databind.JsonNode> shadowDocument, ClientDocument<com.fasterxml.jackson.databind.JsonNode> document)
ClientSynchronizerEdit containing the changes between updated ShadowDocument
and the ClientDocument.
This method would be called when the client receives an update from the server and need
to produce an Edit to be able to patch the ClientDocument.clientDiff in interface ClientSynchronizer<com.fasterxml.jackson.databind.JsonNode,JsonPatchEdit>shadowDocument - the ShadowDocument patched with updates from the serverdocument - the ClientDocumentEdit the edit representing the diff between the shadow document and the client document.public JsonPatchEdit serverDiff(ClientDocument<com.fasterxml.jackson.databind.JsonNode> document, ShadowDocument<com.fasterxml.jackson.databind.JsonNode> shadowDocument)
ClientSynchronizerEdit containing the changes between the updated ClientDocument
and the ShadowDocument.
Calling the method is the first step in when starting a client side synchronization. We need to
gather the changes between the updates made by the client and the shadow document.
The produced Edit can then be passed to the server side.
serverDiff in interface ClientSynchronizer<com.fasterxml.jackson.databind.JsonNode,JsonPatchEdit>document - the ClientDocument containing updates made by the clientshadowDocument - the ShadowDocument for the ClientDocumentEdit the edit representing the diff between the client document and it's shadow document.public ShadowDocument<com.fasterxml.jackson.databind.JsonNode> patchShadow(JsonPatchEdit edit, ShadowDocument<com.fasterxml.jackson.databind.JsonNode> shadowDocument)
ClientSynchronizerpatchShadow in interface ClientSynchronizer<com.fasterxml.jackson.databind.JsonNode,JsonPatchEdit>edit - the Edit containing the diffs/patchesshadowDocument - the ShadowDocument to be patchedShadowDocument a new patched shadow documentpublic ClientDocument<com.fasterxml.jackson.databind.JsonNode> patchDocument(JsonPatchEdit edit, ClientDocument<com.fasterxml.jackson.databind.JsonNode> document)
ClientSynchronizerpatchDocument in interface ClientSynchronizer<com.fasterxml.jackson.databind.JsonNode,JsonPatchEdit>edit - the Edit containing the diffs/patchesdocument - the ClientDocument to be patchedClientDocument a new patched document.public PatchMessage<JsonPatchEdit> createPatchMessage(String documentId, String clientId, Queue<JsonPatchEdit> edits)
ClientSynchronizerPatchMessage with the with the type of Edit that this
synchronizer can handle.createPatchMessage in interface ClientSynchronizer<com.fasterxml.jackson.databind.JsonNode,JsonPatchEdit>documentId - the document identifier for the PatchMessageclientId - the client identifier for the PatchMessageedits - the Edits for the PatchMessagePatchMessage the created {code PatchMessage}public PatchMessage<JsonPatchEdit> patchMessageFromJson(String json)
ClientSynchronizerpatchMessageFromJson in interface ClientSynchronizer<com.fasterxml.jackson.databind.JsonNode,JsonPatchEdit>json - the json representation of a PatchMessagePatchMessage the created {code PatchMessage}public void addContent(com.fasterxml.jackson.databind.JsonNode content,
com.fasterxml.jackson.databind.node.ObjectNode objectNode,
String fieldName)
ClientSynchronizercontent to the ObjectNode.
When a client initially adds a document to the engine it will also be sent across the
wire to the server. Before sending, the content of the document has to be added to the
JSON message payload. Different implementation will require different content types that
the engine can handle and this give them control over how the content is added to the JSON
ObjectNode.
For example, a ClientEngine that stores simple text will just add the contents as a String,
but one that stores JsonNode object will want to add its content as an object.
addContent in interface ClientSynchronizer<com.fasterxml.jackson.databind.JsonNode,JsonPatchEdit>content - the content to be addedobjectNode - the ObjectNode to add the content tofieldName - the name of the fieldpublic static String checksum(com.fasterxml.jackson.databind.JsonNode content)
Copyright © 2015 JBoss by Red Hat. All Rights Reserved.