Class DocumentModelJsonWriter
java.lang.Object
org.nuxeo.ecm.core.io.marshallers.json.AbstractJsonWriter<EntityType>
org.nuxeo.ecm.core.io.marshallers.json.ExtensibleEntityJsonWriter<DocumentModel>
org.nuxeo.ecm.core.io.marshallers.json.document.DocumentModelJsonWriter
- All Implemented Interfaces:
Marshaller<DocumentModel>
,Writer<DocumentModel>
@Setup(mode=SINGLETON,
priority=2000)
public class DocumentModelJsonWriter
extends ExtensibleEntityJsonWriter<DocumentModel>
Convert
DocumentModel
to Json.
This marshaller is enrichable: register class implementing AbstractJsonEnricher
and managing
DocumentModel
.
This marshaller is also extensible: extend it and simply override
ExtensibleEntityJsonWriter.extend(Object, JsonGenerator)
.
Format is:
{
"entity-type":"document",
"repository": "REPOSITORY_NAME",
"uid": "DOCUMENT_UID",
"path": "DOCUMENT_PATH",
"type": "DOCUMENT_TYPE",
"facets": [ "FACET1", "FACET2", ... ],
"schemas": [ {"name": SCHEMA1", "prefix": "PREFIX1"}, {"name": SCHEMA2", "prefix": "PREFIX2"}, ... ],
"state": "DOCUMENT_STATE",
"parentRef": "PARENT_DOCUMENT_UID",
"isCheckedOut": true|false,
"isRecord": true|false,
"isFlexibleRecord": true|false,
"retainUntil": "RETAIN_UNTIL_DATE", <-- or null
"retainedProperties": [ "file:content", "files:files\/*\/file"],
"hasLegalHold": true|false,
"isUnderRetentionOrLegalHold": true|false,
"changeToken": null|"CHANGE_TOKEN",
"isCheckedOut": true|false,
"title": "DOCUMENT_TITLE",
"lastModified": "DATE_UPDATE", <-- if dublincore is present and if dc:modified is not null
"versionLabel": "DOCUMENT_VERSION", <-- only activated with parameter fetch.document=versionLabel or system property nuxeo.document.json.fetch.heavy=true
"lockOwner": "LOCK_OWNER", <-- only activated if locked and with parameter fetch.document=lock or system property nuxeo.document.json.fetch.heavy=true
"lockCreated": "LOCK_DATE", <-- only activated if locked and with parameter fetch.document=lock or system property nuxeo.document.json.fetch.heavy=true
"properties": { <-- only present with parameter properties=schema1,schema2,... see DocumentPropertyJsonWriter
for format
"schemaPrefix:stringProperty": "stringPropertyValue", <-- each property may be fetched if a resolver is associated with that property and if a parameter fetch.document=propXPath is present, in this case, an object will be marshalled as value
"schemaPrefix:booleanProperty": true|false,
"schemaPrefix:integerProperty": 123,
...
"schemaPrefix:complexProperty": {
"subProperty": ...,
...
},
"schemaPrefix:listProperty": [
...
]
}
<-- contextParameters if there are enrichers activated
<-- additional property provided by extend() method
}
- Since:
- 7.2
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
protected static Boolean
protected SchemaManager
Fields inherited from class org.nuxeo.ecm.core.io.marshallers.json.AbstractJsonWriter
ctx, registry
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static boolean
protected boolean
protected void
writeEntityBody
(DocumentModel doc, com.fasterxml.jackson.core.JsonGenerator jg) Implement this method to write the entity body.protected void
writeSchemaProperties
(com.fasterxml.jackson.core.JsonGenerator jg, DocumentModel doc, String schemaName) Methods inherited from class org.nuxeo.ecm.core.io.marshallers.json.ExtensibleEntityJsonWriter
extend, write
Methods inherited from class org.nuxeo.ecm.core.io.marshallers.json.AbstractJsonWriter
accept, getGenerator, write, writeEntity, writeEntity, writeEntityField, writeSerializable, writeSerializableField, writeSerializableListField, writeSerializableMapField
-
Field Details
-
ENTITY_TYPE
- See Also:
-
DOCUMENT_JSON_FETCH_HEAVY_KEY
- See Also:
-
FETCH_HEAVY_VALUES
-
schemaManager
-
-
Constructor Details
-
DocumentModelJsonWriter
public DocumentModelJsonWriter()
-
-
Method Details
-
fetchHeavy
protected static boolean fetchHeavy() -
mustFetch
-
writeEntityBody
protected void writeEntityBody(DocumentModel doc, com.fasterxml.jackson.core.JsonGenerator jg) throws IOException Description copied from class:ExtensibleEntityJsonWriter
Implement this method to write the entity body.- Specified by:
writeEntityBody
in classExtensibleEntityJsonWriter<DocumentModel>
- Parameters:
doc
- The Java entity.jg
- AJsonGenerator
ready to write your entity as Json.- Throws:
IOException
-
writeSchemaProperties
protected void writeSchemaProperties(com.fasterxml.jackson.core.JsonGenerator jg, DocumentModel doc, String schemaName) throws IOException - Throws:
IOException
-