Package org.nuxeo.ecm.core.storage
Class BaseDocument<T extends StateAccessor>
java.lang.Object
org.nuxeo.ecm.core.storage.BaseDocument<T>
- All Implemented Interfaces:
Document
- Direct Known Subclasses:
DBSDocument
,SQLDocumentLive
Base implementation for a Document.
Knows how to read and write values. It is generic in terms of a base State class from which one can read and write values.
- Since:
- 7.3
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
BaseDocument.BlobWriteContext<T extends StateAccessor>
protected static class
BaseDocument.BlobWriteInfo<T extends StateAccessor>
protected class
protected class
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.model.Document
Document.BlobAccessor, Document.WriteContext
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String[]
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected static final Pattern
static final String
static final String
static final String
protected static final Runnable
protected static final Pattern
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
allowNewRetention
(Calendar current, Calendar retainUntil) static String
buildUserVisibleChangeToken
(Long sysChangeToken, Long changeToken) Builds the user-visible change token from low-level change token and system change token information.protected static String
canonicalXPath
(String xpath) Canonicalizes a Nuxeo xpath.protected boolean
checkReadOnlyIgnoredWrite
(Property property, T state) Checks for ignored writes.protected static void
clearDirtyFlags
(Property property) protected BlobInfo
getBlobInfo
(T state) protected abstract T
Gets a child state.getChildAsList
(T state, String name) Gets a child state which is a list.protected abstract T
getChildForWrite
(T state, String name, Type type) Gets a child state into which we will want to write data.protected abstract Lock
Gets the lock from this recently created and unsaved document.protected String
getLegacyChangeToken
(Calendar modified) Gets the legacy change token for the given timestamp.getLock()
Gets the lock if one set on this document.Gets the list of proxy schemas, if this is a proxy.protected Schema
getTopLevelSchema
(Property property) protected Blob
getValueBlob
(T state, String xpath) protected Object
getValueComplex
(T state, ComplexType complexType, String xpath) protected Object
getValueField
(T state, Field field, String xpath) protected Object
getValueObject
(T state, String xpath) Gets a value (may be complex/list) from the document at the given xpath.Gets a write context for the current document.protected abstract String
internalName
(String name) Finds the internal name to use to refer to this property.boolean
isRetainable
(String xp) Can the property be put under retention or legal hold.boolean
isRetained
(String xp) Is the property under retention or legal hold.boolean
Checks if the document has a retention date in the future or has a legal hold.protected static boolean
protected void
readComplexProperty
(T state, ComplexProperty complexProperty) Reads state into a complex property.protected void
readComplexProperty
(T state, ComplexProperty complexProperty, String xpath) protected abstract Lock
removeDocumentLock
(String owner) Removes a lock from this recently created and unsaved document.removeLock
(String owner) Removes a lock from this document.protected void
setBlobInfo
(T state, BlobInfo blobInfo) protected abstract Lock
setDocumentLock
(Lock lock) Sets a lock on this recently created and unsaved document.Sets a lock on this document.protected void
setPropertyBlobData
(String xpath, String string) protected void
setValueBlob
(T state, Blob blob, String xpath) protected void
setValueBlob
(T state, Blob blob, String xpath, boolean gcOldBlob) protected void
setValueComplex
(T state, Field field, String xpath, Object value) protected void
setValueField
(T state, Field field, String xpath, Object value) protected void
setValueObject
(T state, String xpath, Object value) Sets a value (may be complex/list) into the document at the given xpath.protected static Object[]
typedArray
(Type type, Object[] array) Copies the array with an appropriate class depending on the type.static Long
updateChangeToken
(Long changeToken) Updates a change token to its new value.updateList
(T state, String name, Property property) Update a list.protected abstract void
Update a list.protected boolean
validateLegacyChangeToken
(Calendar modified, String userVisibleChangeToken) Validates that the passed user-visible change token is compatible with the current legacy change token.static boolean
validateUserVisibleChangeToken
(Long sysChangeToken, Long changeToken, String userVisibleChangeToken) Validates that the passed user-visible change token is compatible with the current change token.protected void
visitBlobs
(T state, Consumer<Document.BlobAccessor> blobVisitor, Runnable markDirty) Visits all the blobs of this document and calls the passed blob visitor on each one.protected boolean
writeComplexProperty
(T state, ComplexProperty complexProperty, String xpath, boolean writeAll, boolean writeAllChildren, Document.WriteContext wc) Writes state from a complex property.protected boolean
writeComplexProperty
(T state, ComplexProperty complexProperty, Document.WriteContext writeContext) Deprecated.protected boolean
writeDocumentPart
(T state, DocumentPart dp, Document.WriteContext writeContext, boolean create) Writes state from a document part.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.nuxeo.ecm.core.model.Document
addChild, addFacet, checkIn, checkOut, followTransition, getAllFacets, getAllowedStateTransitions, getBaseVersion, getBlobKeys, getChangeToken, getCheckinComment, getChild, getChildren, getChildrenIds, getFacets, getLastVersion, getLifeCyclePolicy, getLifeCycleState, getName, getParent, getPath, getPos, getPropertyValue, getRepositoryName, getRetainedProperties, getRetainUntil, getSession, getSourceDocument, getSystemProp, getTargetDocument, getType, getUUID, getValue, getVersion, getVersionCreationDate, getVersionLabel, getVersions, getVersionSeriesId, getVersionsIds, getWorkingCopy, hasChild, hasChildren, hasFacet, hasLegalHold, isCheckedOut, isEnforcedRecord, isFlexibleRecord, isFolder, isLatestMajorVersion, isLatestVersion, isMajorVersion, isProxy, isReadOnly, isRecord, isRetentionActive, isVersion, isVersionSeriesCheckedOut, makeFlexibleRecord, makeRecord, markUserChange, orderBefore, readDocumentPart, remove, remove, removeFacet, removeSingleton, replaceBlobDigest, restore, setCurrentLifeCycleState, setLegalHold, setLifeCyclePolicy, setPropertyValue, setReadOnly, setRetainUntil, setRetentionActive, setSystemProp, setTargetDocument, setValue, validateUserVisibleChangeToken, visitBlobs, writeDocumentPart, writeDocumentPart
-
Field Details
-
LIST_INDEX_PATTERN
-
EMPTY_STRING_ARRAY
-
BLOB_NAME
- See Also:
-
BLOB_MIME_TYPE
- See Also:
-
BLOB_ENCODING
- See Also:
-
BLOB_DIGEST
- See Also:
-
BLOB_LENGTH
- See Also:
-
BLOB_DATA
- See Also:
-
DC_PREFIX
- See Also:
-
DC_ISSUED
- See Also:
-
DC_MODIFIED
- See Also:
-
RELATED_TEXT_RESOURCES
- See Also:
-
RELATED_TEXT_ID
- See Also:
-
RELATED_TEXT
- See Also:
-
FULLTEXT_JOBID_PROP
- See Also:
-
FULLTEXT_SIMPLETEXT_PROP
- See Also:
-
FULLTEXT_BINARYTEXT_PROP
- See Also:
-
IS_TRASHED_PROP
- See Also:
-
MISC_LIFECYCLE_STATE_PROP
- See Also:
-
LOCK_OWNER_PROP
- See Also:
-
LOCK_CREATED_PROP
- See Also:
-
IS_RECORD_PROP
- Since:
- 11.1
- See Also:
-
IS_FLEXIBLE_RECORD_PROP
- Since:
- 2023.1
- See Also:
-
RETAIN_UNTIL_PROP
- Since:
- 11.1
- See Also:
-
HAS_LEGAL_HOLD_PROP
- Since:
- 11.1
- See Also:
-
RETAINED_PROPERTIES_PROP
- Since:
- 2021.32
- See Also:
-
VERSION_WRITABLE_PROPS
-
NON_CANONICAL_INDEX
-
NO_DIRTY
-
TOKEN_SEP
- See Also:
-
-
Constructor Details
-
BaseDocument
public BaseDocument()
-
-
Method Details
-
getProxySchemas
Gets the list of proxy schemas, if this is a proxy.- Returns:
- the proxy schemas, or
null
-
getChild
Gets a child state.- Parameters:
state
- the parent statename
- the child nametype
- the child's type- Returns:
- the child state, or
null
if it doesn't exist - Throws:
PropertyException
-
getChildForWrite
Gets a child state into which we will want to write data.Creates it if needed.
- Parameters:
state
- the parent statename
- the child nametype
- the child's type- Returns:
- the child state, never
null
- Throws:
PropertyException
- Since:
- 7.4
-
getChildAsList
Gets a child state which is a list.- Parameters:
state
- the parent statename
- the child name- Returns:
- the child state, never
null
- Throws:
PropertyException
-
updateList
protected abstract void updateList(T state, String name, Field field, String xpath, List<Object> values) throws PropertyException Update a list.- Parameters:
state
- the parent statename
- the child namefield
- the list element typexpath
- the xpath of this listvalues
- the values- Throws:
PropertyException
-
updateList
protected abstract List<T> updateList(T state, String name, Property property) throws PropertyException Update a list.- Parameters:
state
- the parent statename
- the child nameproperty
- the property- Returns:
- the list of states to write
- Throws:
PropertyException
-
internalName
Finds the internal name to use to refer to this property. -
canonicalXPath
Canonicalizes a Nuxeo xpath.Replaces
a/foo[123]/b
witha/123/b
- Parameters:
xpath
- the xpath- Returns:
- the canonicalized xpath.
-
typedArray
Copies the array with an appropriate class depending on the type. -
isVersionWritableProperty
-
clearDirtyFlags
-
checkReadOnlyIgnoredWrite
Checks for ignored writes. May throw.- Throws:
PropertyException
-
getTopLevelSchema
- Since:
- 9.3
-
getBlobInfo
- Throws:
PropertyException
-
setBlobInfo
- Throws:
PropertyException
-
getValueObject
Gets a value (may be complex/list) from the document at the given xpath.- Throws:
PropertyException
-
getValueField
- Throws:
PropertyException
-
getValueComplex
protected Object getValueComplex(T state, ComplexType complexType, String xpath) throws PropertyException - Throws:
PropertyException
-
getValueBlob
- Throws:
PropertyException
-
setValueObject
Sets a value (may be complex/list) into the document at the given xpath.- Throws:
PropertyException
-
setValueField
protected void setValueField(T state, Field field, String xpath, Object value) throws PropertyException - Throws:
PropertyException
-
setValueComplex
protected void setValueComplex(T state, Field field, String xpath, Object value) throws PropertyException - Throws:
PropertyException
-
setValueBlob
- Throws:
PropertyException
-
setValueBlob
protected void setValueBlob(T state, Blob blob, String xpath, boolean gcOldBlob) throws PropertyException - Throws:
PropertyException
-
setPropertyBlobData
-
readComplexProperty
protected void readComplexProperty(T state, ComplexProperty complexProperty) throws PropertyException Reads state into a complex property.- Throws:
PropertyException
-
readComplexProperty
protected void readComplexProperty(T state, ComplexProperty complexProperty, String xpath) throws PropertyException - Throws:
PropertyException
-
getWriteContext
Description copied from interface:Document
Gets a write context for the current document.- Specified by:
getWriteContext
in interfaceDocument
-
writeComplexProperty
@Deprecated protected boolean writeComplexProperty(T state, ComplexProperty complexProperty, Document.WriteContext writeContext) throws PropertyException Deprecated.Writes state from a complex property.- Throws:
PropertyException
-
writeDocumentPart
protected boolean writeDocumentPart(T state, DocumentPart dp, Document.WriteContext writeContext, boolean create) throws PropertyException Writes state from a document part.- Returns:
true
if something changed- Throws:
PropertyException
-
isRetainable
Description copied from interface:Document
Can the property be put under retention or legal hold.- Specified by:
isRetainable
in interfaceDocument
- Parameters:
xp
- the xpath- Returns:
- true if the property is retainable
-
isRetained
Description copied from interface:Document
Is the property under retention or legal hold.- Specified by:
isRetained
in interfaceDocument
- Parameters:
xp
- the xpath- Returns:
- true if the property is retained and cannot be deleted/edited
-
writeComplexProperty
protected boolean writeComplexProperty(T state, ComplexProperty complexProperty, String xpath, boolean writeAll, boolean writeAllChildren, Document.WriteContext wc) throws PropertyException Writes state from a complex property.Writes only properties that are dirty, unless writeAll is true in which case everything is written.
- Returns:
true
if something changed- Throws:
PropertyException
-
visitBlobs
protected void visitBlobs(T state, Consumer<Document.BlobAccessor> blobVisitor, Runnable markDirty) throws PropertyException Visits all the blobs of this document and calls the passed blob visitor on each one.- Throws:
PropertyException
-
getLock
Description copied from interface:Document
Gets the lock if one set on this document. -
setLock
Description copied from interface:Document
Sets a lock on this document. -
removeLock
Description copied from interface:Document
Removes a lock from this document.- Specified by:
removeLock
in interfaceDocument
- Parameters:
owner
- the owner to check, ornull
for no check- Returns:
null
if there was no lock or if removal succeeded, or a lock if it blocks removal due to owner mismatch
-
getDocumentLock
Gets the lock from this recently created and unsaved document.- Returns:
- the lock, or
null
if no lock is set - Since:
- 7.4
-
setDocumentLock
Sets a lock on this recently created and unsaved document.- Parameters:
lock
- the lock to set- Returns:
null
if locking succeeded, or the existing lock if locking failed- Since:
- 7.4
-
removeDocumentLock
Removes a lock from this recently created and unsaved document.- Parameters:
owner
- the owner to check, ornull
for no check- Returns:
null
if there was no lock or if removal succeeded, or a lock if it blocks removal due to owner mismatch- Since:
- 7.4
-
buildUserVisibleChangeToken
Builds the user-visible change token from low-level change token and system change token information.- Parameters:
sysChangeToken
- the system change tokenchangeToken
- the change token- Returns:
- the user-visible change token
- Since:
- 9.2
-
validateUserVisibleChangeToken
public static boolean validateUserVisibleChangeToken(Long sysChangeToken, Long changeToken, String userVisibleChangeToken) Validates that the passed user-visible change token is compatible with the current change token.- Parameters:
sysChangeToken
- the system change tokenchangeToken
- the change tokenuserVisibleChangeToken
- the user-visible change token- Returns:
false
if the change token is not valid- Since:
- 9.2
-
validateLegacyChangeToken
Validates that the passed user-visible change token is compatible with the current legacy change token.- Parameters:
modified
- thedc:modified
timestampuserVisibleChangeToken
- the user-visible change token- Returns:
false
if the change token is not valid- Since:
- 9.2
-
getLegacyChangeToken
Gets the legacy change token for the given timestamp.- Parameters:
modified
- thedc:modified
timestamp- Returns:
- the legacy change token
- Since:
- 9.2
-
updateChangeToken
Updates a change token to its new value.- Parameters:
changeToken
- the change token (notnull
)- Returns:
- the updated change token
- Since:
- 9.2
-
isUnderRetentionOrLegalHold
public boolean isUnderRetentionOrLegalHold()Description copied from interface:Document
Checks if the document has a retention date in the future or has a legal hold.- Specified by:
isUnderRetentionOrLegalHold
in interfaceDocument
- Returns:
true
if the document has a retention date in the future or if it has a legal hold,false
otherwise- See Also:
-
allowNewRetention
-
writeDocumentPart(StateAccessor, DocumentPart, org.nuxeo.ecm.core.model.Document.WriteContext, boolean)
instead