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>
ConvertDocumentModel
to Json.This marshaller is enrichable: register class implementing
AbstractJsonEnricher
and managingDocumentModel
.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, "retainUntil": "RETAIN_UNTIL_DATE", <-- or null "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
Fields Modifier and Type Field Description static String
DOCUMENT_JSON_FETCH_HEAVY_KEY
static String
ENTITY_TYPE
protected static Boolean
FETCH_HEAVY_VALUES
protected SchemaManager
schemaManager
-
Fields inherited from class org.nuxeo.ecm.core.io.marshallers.json.AbstractJsonWriter
ctx, registry
-
-
Constructor Summary
Constructors Constructor Description DocumentModelJsonWriter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static boolean
fetchHeavy()
protected boolean
mustFetch(String name)
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 Detail
-
ENTITY_TYPE
public static final String ENTITY_TYPE
- See Also:
- Constant Field Values
-
DOCUMENT_JSON_FETCH_HEAVY_KEY
public static final String DOCUMENT_JSON_FETCH_HEAVY_KEY
- See Also:
- Constant Field Values
-
FETCH_HEAVY_VALUES
protected static Boolean FETCH_HEAVY_VALUES
-
schemaManager
@Inject protected SchemaManager schemaManager
-
-
Constructor Detail
-
DocumentModelJsonWriter
public DocumentModelJsonWriter()
-
-
Method Detail
-
fetchHeavy
protected static boolean fetchHeavy()
-
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
-
-