public class DBSDocument extends BaseDocument<State>
Document for Document-Based Storage. The document is stored as a JSON-like Map. The keys
 of the Map are the property names (including special names for system properties), and the values Map are
 Serializable values, either:
 BaseDocument.BlobWriteContext<T extends StateAccessor>, BaseDocument.BlobWriteInfo<T extends StateAccessor>, BaseDocument.StateBlobAccessor, BaseDocument.VisitDocument.BlobAccessor, Document.WriteContextBLOB_DATA, BLOB_DIGEST, BLOB_ENCODING, BLOB_LENGTH, BLOB_MIME_TYPE, BLOB_NAME, DC_ISSUED, DC_MODIFIED, DC_PREFIX, EMPTY_STRING_ARRAY, FULLTEXT_BINARYTEXT_PROP, FULLTEXT_JOBID_PROP, FULLTEXT_SIMPLETEXT_PROP, IS_TRASHED_PROP, LOCK_CREATED_PROP, LOCK_OWNER_PROP, MISC_LIFECYCLE_STATE_PROP, NO_DIRTY, NON_CANONICAL_INDEX, RELATED_TEXT, RELATED_TEXT_ID, RELATED_TEXT_RESOURCES, TOKEN_SEP, VERSION_WRITABLE_PROPS| Constructor and Description | 
|---|
DBSDocument(DBSDocumentState docState,
           DocumentType type,
           DBSSession session,
           boolean readonly)  | 
| Modifier and Type | Method and Description | 
|---|---|
Document | 
addChild(String name,
        String typeName)
Creates a new child document of the given type. 
 | 
boolean | 
addFacet(String facet)
Adds a facet to this document. 
 | 
Document | 
checkIn(String label,
       String checkinComment)
Creates a new version. 
 | 
void | 
checkOut()  | 
boolean | 
equals(Object other)  | 
void | 
followTransition(String transition)
Follows a given life cycle transition. 
 | 
Set<String> | 
getAllFacets()
Gets the facets available on this document (from the type and the instance facets). 
 | 
Collection<String> | 
getAllowedStateTransitions()
Returns the allowed state transitions for this document. 
 | 
Document | 
getBaseVersion()
Gets the version to which a checked in document is linked. 
 | 
String | 
getChangeToken()
Gets the current change token for this document. 
 | 
String | 
getCheckinComment()
Gets the version check in comment of this document if it's a version or a proxy. 
 | 
protected State | 
getChild(State state,
        String name,
        Type type)
Gets a child state. 
 | 
Document | 
getChild(String name)
Gets a child document given its name. 
 | 
protected List<State> | 
getChildAsList(State state,
              String name)
Gets a child state which is a list. 
 | 
protected State | 
getChildForWrite(State state,
                String name,
                Type type)
Gets a child state into which we will want to write data. 
 | 
List<Document> | 
getChildren()
Gets the children of the document. 
 | 
List<String> | 
getChildrenIds()
Gets a list of the children ids. 
 | 
protected Lock | 
getDocumentLock()
Gets the lock from this recently created and unsaved document. 
 | 
String[] | 
getFacets()
Gets the facets defined on this document instance. 
 | 
Document | 
getLastVersion()
Gets the last version of this document. 
 | 
String | 
getLifeCyclePolicy()
Gets the life cycle policy of this document. 
 | 
String | 
getLifeCycleState()
Gets the life cycle state of this document. 
 | 
String | 
getName()
Gets the name of this document. 
 | 
Document | 
getParent()
Gets the parent document, or  
null if this is the root document. | 
String | 
getPath()
Gets the path of this document. 
 | 
Long | 
getPos()
Gets the document's position in its containing folder (if ordered). 
 | 
Serializable | 
getPropertyValue(String name)
Gets a simple property value. 
 | 
protected List<Schema> | 
getProxySchemas()
Gets the list of proxy schemas, if this is a proxy. 
 | 
protected static String | 
getProxyUserVisibleChangeToken(String proxyToken,
                              String targetToken)  | 
String | 
getRepositoryName()
Gets the repository in which the document lives. 
 | 
protected String | 
getSchema(String xpath)  | 
protected static Set<String> | 
getSchemas(DocumentType type,
          List<Object> facets)  | 
Session | 
getSession()
Gets the session that owns this document. 
 | 
Document | 
getSourceDocument()
Gets the source for this document. 
 | 
protected DBSDocumentState | 
getStateOrTarget()
Gets the target state if this is a proxy, or the regular state otherwise. 
 | 
protected DBSDocumentState | 
getStateOrTarget(String xpath)  | 
protected DBSDocumentState | 
getStateOrTarget(Type type)  | 
protected DBSDocumentState | 
getStateOrTargetForSchema(String schema)
Checks if the given schema should be resolved on the proxy or the target. 
 | 
<T extends Serializable> | 
getSystemProp(String name,
             Class<T> type)
Gets a system property. 
 | 
DBSDocument | 
getTargetDocument()
Gets the document (version or live document) to which this proxy points. 
 | 
protected String | 
getTargetDocumentId()  | 
DocumentType | 
getType()
Gets the type of this document. 
 | 
String | 
getUUID()
Gets this document's UUID. 
 | 
Object | 
getValue(String xpath)
Gets a property value. 
 | 
Document | 
getVersion(String label)
Gets a version of this document, given its label. 
 | 
Calendar | 
getVersionCreationDate()
Gets the version creation date of this document if it's a version or a proxy. 
 | 
String | 
getVersionLabel()
Gets the version label. 
 | 
List<Document> | 
getVersions()
Gets the versions for this document. 
 | 
String | 
getVersionSeriesId()
Gets the version series id. 
 | 
List<String> | 
getVersionsIds()
Gets the list of version ids for this document. 
 | 
Document | 
getWorkingCopy()
Gets the working copy for this document. 
 | 
boolean | 
hasChild(String name)
Checks whether this document has a child of the given name. 
 | 
boolean | 
hasChildren()
Tests if the document has any children. 
 | 
boolean | 
hasFacet(String facet)
Checks whether this document has a given facet, either from its type or added on the instance. 
 | 
int | 
hashCode()  | 
protected String | 
internalName(String name)
Finds the internal name to use to refer to this property. 
 | 
boolean | 
isCheckedOut()
Checks whether this document is checked out. 
 | 
protected boolean | 
isEqualOnVersion(Object ob,
                String key)  | 
boolean | 
isFolder()
Checks whether this document is a folder. 
 | 
boolean | 
isLatestMajorVersion()
Checks whether this document is the latest major version. 
 | 
boolean | 
isLatestVersion()
Checks whether this document is the latest version. 
 | 
boolean | 
isMajorVersion()
Checks whether this document is a major version. 
 | 
boolean | 
isProxy()
Checks whether or not this document is a proxy. 
 | 
boolean | 
isReadOnly()
Checks whether this document is readonly or not. 
 | 
boolean | 
isRetentionActive()
Checks whether this document is under active retention. 
 | 
protected boolean | 
isSchemaForProxy(String schema)  | 
boolean | 
isVersion()
Checks whether this document is a version document. 
 | 
boolean | 
isVersionSeriesCheckedOut()
Checks if there is a checked out working copy for the version series of this document. 
 | 
void | 
markUserChange()
Marks the document as being modified by a user change. 
 | 
void | 
orderBefore(String src,
           String dest)
Orders the given source child before the destination child. 
 | 
void | 
readDocumentPart(DocumentPart dp)
Loads a  
DocumentPart from storage. | 
void | 
remove()
Removes this document and all its children, if any. 
 | 
protected Lock | 
removeDocumentLock(String owner)
Removes a lock from this recently created and unsaved document. 
 | 
boolean | 
removeFacet(String facet)
Removes a facet from this document. 
 | 
void | 
restore(Document version)
Replaces this document's content with the version specified. 
 | 
void | 
setCurrentLifeCycleState(String lifeCycleState)
Sets the life cycle state of this document. 
 | 
protected Lock | 
setDocumentLock(Lock lock)
Sets a lock on this recently created and unsaved document. 
 | 
void | 
setLifeCyclePolicy(String policy)
Sets the life cycle policy of this document. 
 | 
void | 
setPropertyValue(String name,
                Serializable value)
Sets a simple property value. 
 | 
void | 
setReadOnly(boolean readonly)
Sets this document as readonly or not. 
 | 
void | 
setRetentionActive(boolean retentionActive)
Sets or unsets this document as under active retention. 
 | 
void | 
setSystemProp(String name,
             Serializable value)
Sets a system property. 
 | 
void | 
setTargetDocument(Document target)
Sets the document (version or live document) to which this proxy points. 
 | 
void | 
setValue(String xpath,
        Object value)
Sets a property value. 
 | 
String | 
toString()  | 
protected void | 
updateList(State state,
          String name,
          Field field,
          String xpath,
          List<Object> values)
Update a list. 
 | 
protected List<State> | 
updateList(State state,
          String name,
          Property property)
Update a list. 
 | 
protected static boolean | 
validateProxyChangeToken(String userVisibleChangeToken,
                        DBSDocumentState proxyState,
                        DBSDocumentState targetState)  | 
boolean | 
validateUserVisibleChangeToken(String userVisibleChangeToken)
Validates that the passed user-visible change token is compatible with the one for this document. 
 | 
void | 
visitBlobs(Consumer<Document.BlobAccessor> blobVisitor)
Visits all the blobs of this document and calls the passed blob visitor on each one. 
 | 
boolean | 
writeDocumentPart(DocumentPart dp,
                 Document.WriteContext writeContext)
Writes a  
DocumentPart to storage. | 
buildUserVisibleChangeToken, canonicalXPath, checkReadOnlyIgnoredWrite, clearDirtyFlags, getBlobInfo, getLegacyChangeToken, getLock, getTopLevelSchema, getValueBlob, getValueComplex, getValueField, getValueObject, getWriteContext, isVersionWritableProperty, readComplexProperty, removeLock, setBlobInfo, setLock, setValueBlob, setValueComplex, setValueField, setValueObject, typedArray, updateChangeToken, validateLegacyChangeToken, validateUserVisibleChangeToken, visitBlobs, writeComplexProperty, writeComplexPropertypublic static final String SYSPROP_FULLTEXT_SIMPLE
public static final String SYSPROP_FULLTEXT_BINARY
public static final String SYSPROP_FULLTEXT_JOBID
public static final String SYSPROP_IS_TRASHED
public static final String KEY_PREFIX
public static final String KEY_ID
public static final String KEY_PARENT_ID
public static final String KEY_ANCESTOR_IDS
public static final String KEY_PRIMARY_TYPE
public static final String KEY_MIXIN_TYPES
public static final String KEY_NAME
public static final String KEY_POS
public static final String KEY_ACP
public static final String KEY_ACL_NAME
public static final String KEY_PATH_INTERNAL
public static final String KEY_ACL
public static final String KEY_ACE_USER
public static final String KEY_ACE_PERMISSION
public static final String KEY_ACE_GRANT
public static final String KEY_ACE_CREATOR
public static final String KEY_ACE_BEGIN
public static final String KEY_ACE_END
public static final String KEY_ACE_STATUS
public static final String KEY_READ_ACL
public static final String KEY_IS_RETENTION_ACTIVE
public static final String KEY_IS_CHECKED_IN
public static final String KEY_IS_VERSION
public static final String KEY_IS_LATEST_VERSION
public static final String KEY_IS_LATEST_MAJOR_VERSION
public static final String KEY_MAJOR_VERSION
public static final String KEY_MINOR_VERSION
public static final String KEY_VERSION_SERIES_ID
public static final String KEY_VERSION_CREATED
public static final String KEY_VERSION_LABEL
public static final String KEY_VERSION_DESCRIPTION
public static final String KEY_BASE_VERSION_ID
public static final String KEY_IS_PROXY
public static final String KEY_PROXY_TARGET_ID
public static final String KEY_PROXY_VERSION_SERIES_ID
public static final String KEY_PROXY_IDS
public static final String KEY_LIFECYCLE_POLICY
public static final String KEY_LIFECYCLE_STATE
public static final String KEY_IS_TRASHED
public static final String KEY_LOCK_OWNER
public static final String KEY_LOCK_CREATED
public static final String KEY_SYS_CHANGE_TOKEN
public static final String KEY_CHANGE_TOKEN
public static final String KEY_DC_MODIFIED
public static final String KEY_BLOB_NAME
public static final String KEY_BLOB_MIME_TYPE
public static final String KEY_BLOB_ENCODING
public static final String KEY_BLOB_DIGEST
public static final String KEY_BLOB_LENGTH
public static final String KEY_BLOB_DATA
public static final String KEY_FULLTEXT_SIMPLE
public static final String KEY_FULLTEXT_BINARY
public static final String KEY_FULLTEXT_JOBID
public static final String KEY_FULLTEXT_SCORE
public static final String APPLICATION_OCTET_STREAM
public static final String PROP_UID_MAJOR_VERSION
public static final String PROP_UID_MINOR_VERSION
public static final String PROP_MAJOR_VERSION
public static final String PROP_MINOR_VERSION
public static final String FACETED_TAG
public static final String FACETED_TAG_LABEL
public static final Long INITIAL_SYS_CHANGE_TOKEN
public static final Long INITIAL_CHANGE_TOKEN
protected final DBSDocumentState docState
protected final DocumentType type
protected final List<Schema> proxySchemas
protected final DBSSession session
protected boolean readonly
protected static final Map<String,String> systemPropNameMap
public static final String CHANGE_TOKEN_PROXY_SEP
public DBSDocument(DBSDocumentState docState, DocumentType type, DBSSession session, boolean readonly)
public DocumentType getType()
Documentpublic Session getSession()
Documentpublic String getRepositoryName()
Documentprotected List<Schema> getProxySchemas()
BaseDocumentgetProxySchemas in class BaseDocument<State>nullpublic String getUUID()
Documentpublic String getName()
Documentpublic Long getPos()
Documentpublic Document getParent()
Documentnull if this is the root document.nullpublic boolean isProxy()
Documenttrue if this document is a proxy, false otherwisepublic boolean isVersion()
Documenttrue if it's a version, false otherwisepublic String getPath()
Documentpublic Document getChild(String name)
Document
 Throws DocumentNotFoundException if the document could not be found.
name - the name of the child to retrievepublic List<Document> getChildren()
DocumentReturns an empty list for non-folder documents.
public List<String> getChildrenIds()
DocumentReturns an empty list for non-folder documents.
public boolean hasChild(String name)
Document
 Returns false for non-folder documents.
name - the name of the child to checktrue if the child exists, false otherwisepublic boolean hasChildren()
Document
 Returns false for non-folder documents.
true if the document has children, false otherwisepublic Document addChild(String name, String typeName)
DocumentThrows an error if this document is not a folder.
name - the name of the new child to createtypeName - the type of the child to createpublic void orderBefore(String src, String dest)
Document
 Both source and destination must be names that point to child documents of this document. The source document
 will be placed before the destination one. If destination is null, the source document will be appended
 at the end of the children list.
src - the document to movedest - the document before which to place the source documentpublic Serializable getPropertyValue(String name)
Document
 For more generic properties described by an xpath, use Document.getValue(java.lang.String) instead.
name - the name of the property to getnull if the property is not setDocument.getValue(java.lang.String)public void setPropertyValue(String name, Serializable value)
Document
 For more generic properties described by an xpath, use Document.setValue(java.lang.String, java.lang.Object) instead.
name - the name of the property to setvalue - the value to setDocument.setValue(java.lang.String, java.lang.Object)protected State getChild(State state, String name, Type type)
BaseDocumentgetChild in class BaseDocument<State>state - the parent statename - the child nametype - the child's typenull if it doesn't existprotected State getChildForWrite(State state, String name, Type type) throws PropertyException
BaseDocumentCreates it if needed.
getChildForWrite in class BaseDocument<State>state - the parent statename - the child nametype - the child's typenullPropertyExceptionprotected List<State> getChildAsList(State state, String name)
BaseDocumentgetChildAsList in class BaseDocument<State>state - the parent statename - the child namenullprotected void updateList(State state, String name, Field field, String xpath, List<Object> values)
BaseDocumentupdateList in class BaseDocument<State>state - the parent statename - the child namefield - the list element typexpath - the xpath of this listvalues - the valuesprotected List<State> updateList(State state, String name, Property property) throws PropertyException
BaseDocumentupdateList in class BaseDocument<State>state - the parent statename - the child nameproperty - the propertyPropertyExceptionpublic Object getValue(String xpath) throws PropertyException
Document
 The xpath may point to a partial path, in which case the value may be a complex List or Map.
xpath - the xpath of the property to setnull if the property is not setPropertyException - if the property does not existpublic void setValue(String xpath, Object value) throws PropertyException
Document
 The xpath may point to a partial path, in which case the value may be a complex List or Map.
xpath - the xpath of the property to setvalue - the value to setPropertyException - if the property does not exist or the value is of the wrong typepublic void visitBlobs(Consumer<Document.BlobAccessor> blobVisitor) throws PropertyException
DocumentPropertyExceptionpublic boolean isRetentionActive()
Documentpublic void setRetentionActive(boolean retentionActive)
Documentpublic Document checkIn(String label, String checkinComment)
Documentlabel - the version labelcheckinComment - the checkin commentpublic void checkOut()
public List<String> getVersionsIds()
Documentpublic List<Document> getVersions()
Documentpublic Document getLastVersion()
Document
 Returns null if there is no version at all.
null if there is no versionpublic Document getSourceDocument()
DocumentFor a version, it's the working copy.
For a proxy, it's the version the proxy points to.
public void restore(Document version)
Documentversion - the version to replace withpublic Document getVersion(String label)
Documentlabel - the version labelpublic Document getBaseVersion()
Document
 Returns null for a checked out document or a version or a proxy.
nullpublic boolean isCheckedOut()
Documenttrue if the document is checked out, or false otherwisepublic String getVersionSeriesId()
Documentpublic Calendar getVersionCreationDate()
Documentnull if it's not a version or a proxypublic String getVersionLabel()
Documentpublic String getCheckinComment()
Documentnull if it's not a version or a proxypublic boolean isLatestVersion()
Documenttrue if this is the latest version, or false otherwisepublic boolean isMajorVersion()
Documenttrue if this is a major version, or false otherwisepublic boolean isLatestMajorVersion()
Documenttrue if this is the latest major version, or false otherwiseprotected boolean isEqualOnVersion(Object ob, String key)
public boolean isVersionSeriesCheckedOut()
Documenttrue if there is a checked out working copypublic Document getWorkingCopy()
Documentpublic boolean isFolder()
Documenttrue if the document is a folder, false otherwisepublic void setReadOnly(boolean readonly)
Documentpublic boolean isReadOnly()
Documentpublic void remove()
Documentpublic String getLifeCycleState()
Documentpublic void setCurrentLifeCycleState(String lifeCycleState) throws LifeCycleException
DocumentlifeCycleState - the life cycle stateLifeCycleExceptionpublic String getLifeCyclePolicy()
Documentpublic void setLifeCyclePolicy(String policy) throws LifeCycleException
Documentpolicy - the life cycle policyLifeCycleExceptionpublic void followTransition(String transition) throws LifeCycleException
DocumentThis will update the life cycle state of the document.
transition - the name of the transition to followLifeCycleExceptionpublic Collection<String> getAllowedStateTransitions() throws LifeCycleException
DocumentLifeCycleExceptionpublic void setSystemProp(String name, Serializable value)
Documentpublic <T extends Serializable> T getSystemProp(String name, Class<T> type)
Documentpublic String getChangeToken()
Documentprotected static String getProxyUserVisibleChangeToken(String proxyToken, String targetToken)
public boolean validateUserVisibleChangeToken(String userVisibleChangeToken)
Documentfalse if the change token is not validprotected static boolean validateProxyChangeToken(String userVisibleChangeToken, DBSDocumentState proxyState, DBSDocumentState targetState)
public void markUserChange()
DocumentThis causes an additional change token increment and check during save.
protected DBSDocumentState getStateOrTarget(Type type) throws PropertyException
PropertyExceptionprotected DBSDocumentState getStateOrTarget(String xpath)
protected DBSDocumentState getStateOrTargetForSchema(String schema)
protected DBSDocumentState getStateOrTarget()
protected boolean isSchemaForProxy(String schema)
public void readDocumentPart(DocumentPart dp) throws PropertyException
DocumentDocumentPart from storage.
 
 Reading data is done by DocumentPart because of per-proxy schemas.
PropertyExceptionprotected String internalName(String name)
BaseDocumentinternalName in class BaseDocument<State>public boolean writeDocumentPart(DocumentPart dp, Document.WriteContext writeContext) throws PropertyException
DocumentDocumentPart to storage.
 
 Writing data is done by DocumentPart because of per-proxy schemas.
true if something changedPropertyExceptionpublic Set<String> getAllFacets()
Documentpublic String[] getFacets()
Documentpublic boolean hasFacet(String facet)
Documentfacet - the facet nametrue if the document has the facetpublic boolean addFacet(String facet)
DocumentDoes nothing if the facet was already present on the document.
facet - the facet nametrue if the facet was added, or false if it is already presentpublic boolean removeFacet(String facet)
DocumentIt's not possible to remove a facet coming from the document type.
facet - the facet nametrue if the facet was removed, or false if it isn't present or is present on the type or
         does not exitprotected static Set<String> getSchemas(DocumentType type, List<Object> facets)
public DBSDocument getTargetDocument()
Documentprotected String getTargetDocumentId()
public void setTargetDocument(Document target)
Documentprotected Lock getDocumentLock()
BaseDocumentgetDocumentLock in class BaseDocument<State>null if no lock is setprotected Lock setDocumentLock(Lock lock)
BaseDocumentsetDocumentLock in class BaseDocument<State>lock - the lock to setnull if locking succeeded, or the existing lock if locking failedprotected Lock removeDocumentLock(String owner)
BaseDocumentremoveDocumentLock in class BaseDocument<State>owner - the owner to check, or null for no checknull if there was no lock or if removal succeeded, or a lock if it blocks removal due to owner
         mismatchCopyright © 2019 Nuxeo. All rights reserved.