public abstract class BaseDocument<T extends StateAccessor> extends Object implements 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.
Modifier and Type | Class and Description |
---|---|
protected static class |
BaseDocument.BlobWriteContext<T extends StateAccessor> |
protected static class |
BaseDocument.BlobWriteInfo<T extends StateAccessor> |
protected class |
BaseDocument.StateBlobAccessor |
protected class |
BaseDocument.Visit |
Document.BlobAccessor, Document.WriteContext
Modifier and Type | Field and Description |
---|---|
static String |
BLOB_DATA |
static String |
BLOB_DIGEST |
static String |
BLOB_ENCODING |
static String |
BLOB_LENGTH |
static String |
BLOB_MIME_TYPE |
static String |
BLOB_NAME |
static String |
DC_ISSUED |
static String |
DC_MODIFIED |
static String |
DC_PREFIX |
static String[] |
EMPTY_STRING_ARRAY |
static String |
FULLTEXT_BINARYTEXT_PROP |
static String |
FULLTEXT_JOBID_PROP |
static String |
FULLTEXT_SIMPLETEXT_PROP |
static String |
LOCK_CREATED_PROP |
static String |
LOCK_OWNER_PROP |
static String |
MISC_LIFECYCLE_STATE_PROP |
protected static Runnable |
NO_DIRTY |
protected static Pattern |
NON_CANONICAL_INDEX |
static String |
RELATED_TEXT |
static String |
RELATED_TEXT_ID |
static String |
RELATED_TEXT_RESOURCES |
static String |
TOKEN_SEP |
static Set<String> |
VERSION_WRITABLE_PROPS |
Constructor and Description |
---|
BaseDocument() |
Modifier and Type | Method and Description |
---|---|
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 |
getChild(T state,
String name,
Type type)
Gets a child state.
|
protected abstract List<T> |
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 |
getDocumentLock()
Gets the lock from this recently created and unsaved document.
|
protected String |
getLegacyChangeToken(Calendar modified)
Gets the legacy change token for the given timestamp.
|
Lock |
getLock()
Gets the lock if one set on this document.
|
protected abstract List<Schema> |
getProxySchemas()
Gets the list of proxy schemas, if this is a proxy.
|
protected Schema |
getTopLevelSchema(Property property)
|
protected Blob |
getValueBlob(T state) |
protected Object |
getValueComplex(T state,
ComplexType complexType) |
protected Object |
getValueField(T state,
Field field) |
protected Object |
getValueObject(T state,
String xpath)
Gets a value (may be complex/list) from the document at the given xpath.
|
Document.WriteContext |
getWriteContext()
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.
|
protected static boolean |
isVersionWritableProperty(String name) |
protected void |
readComplexProperty(T state,
ComplexProperty complexProperty)
Reads state into a complex property.
|
protected Map<String,Serializable> |
readPrefetch(T state,
ComplexType complexType,
Set<String> xpaths)
Reads prefetched values.
|
protected void |
readPrefetch(T state,
ComplexType complexType,
String xpathGeneric,
String xpath,
Set<String> prefixes,
Map<String,Serializable> prefetch) |
protected void |
readPrefetchField(T state,
Field field,
String xpathGeneric,
String xpath,
Set<String> prefixes,
Map<String,Serializable> prefetch) |
protected abstract Lock |
removeDocumentLock(String owner)
Removes a lock from this recently created and unsaved document.
|
Lock |
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.
|
Lock |
setLock(Lock lock)
Sets a lock on this document.
|
protected void |
setValueBlob(T state,
Blob blob,
String xpath) |
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.
|
protected abstract void |
updateList(T state,
String name,
Field field,
String xpath,
List<Object> values)
Update a list.
|
protected abstract List<T> |
updateList(T state,
String name,
Property property)
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,
Document.WriteContext writeContext)
Writes state from a complex property.
|
protected boolean |
writeComplexProperty(T state,
ComplexProperty complexProperty,
String xpath,
boolean writeAll,
Document.WriteContext wc)
Writes state from a complex property.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addChild, addFacet, checkIn, checkOut, followTransition, getAllFacets, getAllowedStateTransitions, getBaseVersion, getChangeToken, getCheckinComment, getChild, getChildren, getChildrenIds, getFacets, getLastVersion, getLifeCyclePolicy, getLifeCycleState, getName, getParent, getPath, getPos, getPropertyValue, getRepositoryName, getSession, getSourceDocument, getSystemProp, getTargetDocument, getType, getUUID, getValue, getVersion, getVersionCreationDate, getVersionLabel, getVersions, getVersionSeriesId, getVersionsIds, getWorkingCopy, hasChild, hasChildren, hasFacet, isCheckedOut, isFolder, isLatestMajorVersion, isLatestVersion, isMajorVersion, isProxy, isReadOnly, isRetentionActive, isVersion, isVersionSeriesCheckedOut, markUserChange, orderBefore, readDocumentPart, readPrefetch, remove, removeFacet, restore, setCurrentLifeCycleState, setLifeCyclePolicy, setPropertyValue, setReadOnly, setRetentionActive, setSystemProp, setTargetDocument, setValue, validateUserVisibleChangeToken, visitBlobs, writeDocumentPart
public static final String[] EMPTY_STRING_ARRAY
public static final String BLOB_NAME
public static final String BLOB_MIME_TYPE
public static final String BLOB_ENCODING
public static final String BLOB_DIGEST
public static final String BLOB_LENGTH
public static final String BLOB_DATA
public static final String DC_PREFIX
public static final String DC_ISSUED
public static final String DC_MODIFIED
public static final String RELATED_TEXT_RESOURCES
public static final String RELATED_TEXT_ID
public static final String RELATED_TEXT
public static final String FULLTEXT_JOBID_PROP
public static final String FULLTEXT_SIMPLETEXT_PROP
public static final String FULLTEXT_BINARYTEXT_PROP
public static final String MISC_LIFECYCLE_STATE_PROP
public static final String LOCK_OWNER_PROP
public static final String LOCK_CREATED_PROP
public static final Set<String> VERSION_WRITABLE_PROPS
protected static final Pattern NON_CANONICAL_INDEX
public static final String TOKEN_SEP
public BaseDocument()
protected abstract List<Schema> getProxySchemas()
null
protected abstract T getChild(T state, String name, Type type) throws PropertyException
state
- the parent statename
- the child nametype
- the child's typenull
if it doesn't existPropertyException
protected abstract T getChildForWrite(T state, String name, Type type) throws PropertyException
Creates it if needed.
state
- the parent statename
- the child nametype
- the child's typenull
PropertyException
protected abstract List<T> getChildAsList(T state, String name) throws PropertyException
state
- the parent statename
- the child namenull
PropertyException
protected abstract void updateList(T state, String name, Field field, String xpath, List<Object> values) throws PropertyException
state
- the parent statename
- the child namefield
- the list element typexpath
- the xpath of this listvalues
- the valuesPropertyException
protected abstract List<T> updateList(T state, String name, Property property) throws PropertyException
state
- the parent statename
- the child nameproperty
- the propertyPropertyException
protected abstract String internalName(String name)
protected static String canonicalXPath(String xpath)
Replaces a/foo[123]/b
with a/123/b
xpath
- the xpathprotected static Object[] typedArray(Type type, Object[] array)
protected static boolean isVersionWritableProperty(String name)
protected static void clearDirtyFlags(Property property)
protected boolean checkReadOnlyIgnoredWrite(Property property, T state) throws PropertyException
PropertyException
protected Schema getTopLevelSchema(Property property)
protected BlobInfo getBlobInfo(T state) throws PropertyException
PropertyException
protected void setBlobInfo(T state, BlobInfo blobInfo) throws PropertyException
PropertyException
protected Object getValueObject(T state, String xpath) throws PropertyException
PropertyException
protected Object getValueField(T state, Field field) throws PropertyException
PropertyException
protected Object getValueComplex(T state, ComplexType complexType) throws PropertyException
PropertyException
protected Blob getValueBlob(T state) throws PropertyException
PropertyException
protected void setValueObject(T state, String xpath, Object value) throws PropertyException
PropertyException
protected void setValueField(T state, Field field, String xpath, Object value) throws PropertyException
PropertyException
protected void setValueComplex(T state, Field field, String xpath, Object value) throws PropertyException
PropertyException
protected void setValueBlob(T state, Blob blob, String xpath) throws PropertyException
PropertyException
protected void readComplexProperty(T state, ComplexProperty complexProperty) throws PropertyException
PropertyException
public Document.WriteContext getWriteContext()
Document
getWriteContext
in interface Document
protected boolean writeComplexProperty(T state, ComplexProperty complexProperty, Document.WriteContext writeContext) throws PropertyException
true
if something changedPropertyException
protected boolean writeComplexProperty(T state, ComplexProperty complexProperty, String xpath, boolean writeAll, Document.WriteContext wc) throws PropertyException
Writes only properties that are dirty, unless writeAll is true in which case everything is written.
true
if something changedPropertyException
protected Map<String,Serializable> readPrefetch(T state, ComplexType complexType, Set<String> xpaths) throws PropertyException
PropertyException
protected void readPrefetch(T state, ComplexType complexType, String xpathGeneric, String xpath, Set<String> prefixes, Map<String,Serializable> prefetch) throws PropertyException
PropertyException
protected void readPrefetchField(T state, Field field, String xpathGeneric, String xpath, Set<String> prefixes, Map<String,Serializable> prefetch)
protected void visitBlobs(T state, Consumer<Document.BlobAccessor> blobVisitor, Runnable markDirty) throws PropertyException
PropertyException
public Lock getLock()
Document
public Lock setLock(Lock lock)
Document
public Lock removeLock(String owner)
Document
removeLock
in interface Document
null
if there was no lock or if removal succeeded, or a lock if it blocks removal due to owner
mismatchprotected abstract Lock getDocumentLock()
null
if no lock is setprotected abstract Lock setDocumentLock(Lock lock)
lock
- the lock to setnull
if locking succeeded, or the existing lock if locking failedprotected abstract Lock removeDocumentLock(String 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
mismatchpublic static String buildUserVisibleChangeToken(Long sysChangeToken, Long changeToken)
sysChangeToken
- the system change tokenchangeToken
- the change tokenpublic static boolean validateUserVisibleChangeToken(Long sysChangeToken, Long changeToken, String userVisibleChangeToken)
sysChangeToken
- the system change tokenchangeToken
- the change tokenuserVisibleChangeToken
- the user-visible change tokenfalse
if the change token is not validprotected boolean validateLegacyChangeToken(Calendar modified, String userVisibleChangeToken)
modified
- the dc:modified
timestampuserVisibleChangeToken
- the user-visible change tokenfalse
if the change token is not validprotected String getLegacyChangeToken(Calendar modified)
modified
- the dc:modified
timestamppublic static Long updateChangeToken(Long changeToken)
changeToken
- the change token (not null
)Copyright © 2018 Nuxeo. All rights reserved.