Class DBSTransactionState
- All Implemented Interfaces:
AutoCloseable,LockManager
Until save() is called, data lives in the transient map.
Upon save, data is written to the repository connection.
If the connection is transactional, usual behavior occurs.
If the connection is not transactional, then at this means that other sessions can read uncommitted data. To allow rollback, save data is also kept in an undo log in order for rollback to be possible. On commit, the undo log is forgotten. On rollback, the undo log is replayed.
- Since:
- 5.9.4
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classIterates on aStateto find the blob keys.static classLogic to get the conditions to use to match and update a change token.protected static classIterates on a state diff to find the paths corresponding to dirty values.static classDeprecated.static classDeprecated.since 2021.11 useUpdateReadAclsActioninstead -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DBSConnectionprotected BooleanFor test purpose only.protected final booleanstatic final Stringstatic final Stringstatic final Stringstatic final StringKeys used when computing Read ACLs.protected final DBSRepositoryprotected final DBSSessionIds of documents created but not yet saved.protected Map<String, DBSDocumentState> Retrieved and created document state.Undo log.protected final Set<Serializable> Document ids modified as "user changes", which means that a change token should be checked.protected final BaseSession.VersionAclMode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidbegin()Called when created in a transaction.protected voidvoidclose()voidcommit()Saves and flushes to database.protected voidcomputeBlobKeys(DBSDocumentState docState, DBSTransactionState.BlobKeysFinder blobKeysFinder) Copies the document into a newly-created object.booleanReturns whether or not the document with givenidexists in the storage.protected voidfindDirtyDocuments(Set<String> docsWithDirtyStrings, Set<String> docsWithDirtyBinaries) Finds the documents having dirty text or dirty binaries that have to be reindexed as fulltext.protected Object[]getAncestorIds(String id) Gets ancestors including id itself.getChildrenIds(String parentId) getChildrenIds(String parentId, boolean excludeSpecialChildren, boolean excludeRegularChildren) getChildrenStates(String parentId) getChildrenStates(String parentId, boolean excludeSpecialChildren, boolean excludeRegularChildren) getChildState(String parentId, String name) protected DBSTransactionState.ConditionalUpdatesgetDescendants(String id, Set<String> keys, int limit) Gets the fulltext updates to do.getKeyValuedStates(String key, Object value) getKeyValuedStates(String key1, Object value1, String key2, Object value2) Gets the lock on a document.protected String[]getReadACL(State state) Deprecated.since 2021.39 usematerializedKeys(State)insteadprotected intReturns a state which won't be modified.Returns a state and marks it as transient, because it's about to be modified or returned to user code (where it may be modified).Returns states and marks them transient, because they're about to be returned to user code (where they may be modified).booleanbooleanhasChildren(String parentId) protected booleanFor test purpose only.protected booleanisProxySpecific(String key, SchemaManager schemaManager) Things that we don't touch on a proxy when updating it.protected booleanisUnderSyncLimit(int limit, Set<String> ids) protected voidmarkIndexingInProgress(Set<String> ids) voidmarkUserChange(String id) protected StatematerializedKeys(State state) Returns materialized keys for a state: Read ACL (flat list of users having browse permission, including inheritance) on a document Ancestor idsprotected DBSDocumentStatenewTransientState(State state) New transient state for something just read from the repository.queryAndFetch(DBSExpressionEvaluator evaluator, OrderByClause orderByClause, boolean distinctDocuments, int limit, int offset, int countUpTo) removeLock(String id, String owner) Removes the lock from a document.voidremoveStates(Set<String> ids) Removes a list of documents.voidrollback()Rolls back the save state by applying the undo log.voidsave()Writes transient state to database.protected voidscheduleWork(List<Work> works) scroll(DBSExpressionEvaluator evaluator, int batchSize, int keepAliveSeconds) Sets a lock on a document.voidupdateAncestors(String id, int ndel, Object[] ancestorIds) Updates ancestors recursively after a move.protected static LongupdateChangeToken(Long changeToken) protected voidprotected voidUpdates the Read ACLs on a document (not recursively)protected voidUpdates the Read ACLs on a document, without polluting caches.protected voidChecks if the changed documents are proxy targets, and updates the proxies if that's the case.protected voidupdateProxies(DBSDocumentState target) protected voidupdateProxy(DBSDocumentState target, String proxyId) Updates the state of a proxy based on its target.voidupdateReadACLs(Collection<String> docIds) Updates the Read ACLs on a document (not recursively), bypassing transient space and caches for the document itself (not the ancestors, needed for ACL inheritance and for which caching is useful).voidUpdates the Read ACLs recursively on a document.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.ecm.core.api.lock.LockManager
clearLockManagerCaches, closeLockManager
-
Field Details
-
READ_ACL_RECURSION_KEYS
Keys used when computing Read ACLs. -
READ_ACL_ASYNC_ENABLED_PROPERTY
- See Also:
-
READ_ACL_ASYNC_ENABLED_DEFAULT
- See Also:
-
READ_ACL_ASYNC_THRESHOLD_PROPERTY
- See Also:
-
READ_ACL_ASYNC_THRESHOLD_DEFAULT
- See Also:
-
repository
-
connection
-
session
-
transientStates
Retrieved and created document state. -
transientCreated
Ids of documents created but not yet saved. -
userChangeIds
Document ids modified as "user changes", which means that a change token should be checked.- Since:
- 9.2
-
disabledForTestingPurpose
For test purpose only.- Since:
- 2023.0
-
undoLog
Undo log.A map of document ids to null or State. The value is null when the document has to be deleted when applying the undo log. Otherwise the value is a State. If the State contains the key
KEY_UNDOLOG_CREATEthen the state must be re-created completely when applying the undo log, otherwise just applied as an update.Null when there is no active transaction.
-
browsePermissions
-
versionAclMode
-
disableReadVersionPermission
protected final boolean disableReadVersionPermission
-
-
Constructor Details
-
DBSTransactionState
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Since:
- 11.1
-
getRootId
- Since:
- 11.1
-
newTransientState
New transient state for something just read from the repository. -
getStateForUpdate
Returns a state and marks it as transient, because it's about to be modified or returned to user code (where it may be modified). -
getStateForRead
Returns a state which won't be modified. -
exists
Returns whether or not the document with givenidexists in the storage.- Since:
- 2021.12
-
getStatesForUpdate
Returns states and marks them transient, because they're about to be returned to user code (where they may be modified). -
getChildState
-
hasChild
-
getChildrenStates
-
getChildrenStates
public List<DBSDocumentState> getChildrenStates(String parentId, boolean excludeSpecialChildren, boolean excludeRegularChildren) -
getChildrenIds
-
getChildrenIds
-
hasChildren
-
createChild
-
getAncestorIds
Gets ancestors including id itself. -
copy
Copies the document into a newly-created object.The copy is automatically saved.
-
updateAncestors
Updates ancestors recursively after a move.Recursing from given doc, replace the first ndel ancestors with those passed.
Doesn't check transient (assumes save is done). The modifications are automatically saved.
-
getReadAclsAsyncThreshold
protected int getReadAclsAsyncThreshold() -
updateTreeReadAcls
Updates the Read ACLs recursively on a document. -
isUnderSyncLimit
-
updateReadACLs
Updates the Read ACLs on a document (not recursively), bypassing transient space and caches for the document itself (not the ancestors, needed for ACL inheritance and for which caching is useful). -
updateDocumentReadAcls
Updates the Read ACLs on a document (not recursively) -
updateDocumentReadAclsNoCache
Updates the Read ACLs on a document, without polluting caches.When fetching parents recursively to compute inheritance, the regular transient space and repository caching are used.
-
getReadACL
Deprecated.since 2021.39 usematerializedKeys(State)insteadGets the Read ACL (flat list of users having browse permission, including inheritance) on a document. -
materializedKeys
Returns materialized keys for a state:- Read ACL (flat list of users having browse permission, including inheritance) on a document
- Ancestor ids
-
getDescendants
-
getKeyValuedStates
-
getKeyValuedStates
-
queryAndFetch
public PartialList<Map<String,Serializable>> queryAndFetch(DBSExpressionEvaluator evaluator, OrderByClause orderByClause, boolean distinctDocuments, int limit, int offset, int countUpTo) - Since:
- 11.1
-
scroll
public ScrollResult<String> scroll(DBSExpressionEvaluator evaluator, int batchSize, int keepAliveSeconds) - Since:
- 11.1
-
scroll
- Since:
- 11.1
-
getLock
Description copied from interface:LockManagerGets the lock on a document.If the document does not exist,
nullis returned.- Specified by:
getLockin interfaceLockManager- Parameters:
id- the document id- Returns:
- the existing lock, or
nullwhen there is no lock - Since:
- 11.1
-
setLock
Description copied from interface:LockManagerSets a lock on a document.If the document is already locked, returns its existing lock status (there is no re-locking,
LockManager.removeLock(java.lang.String, java.lang.String)must be called first).- Specified by:
setLockin interfaceLockManager- Parameters:
id- the document idlock- the lock to set- Returns:
nullif locking succeeded, or the existing lock if locking failed- Since:
- 11.1
-
removeLock
Description copied from interface:LockManagerRemoves the lock from a document.The previous lock is returned.
If
ownerisnullthen the lock is unconditionally removed.If
owneris notnull, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will returntrueforLock.getFailed().- Specified by:
removeLockin interfaceLockManager- Parameters:
id- the document idowner- the owner to check, ornullfor no check- Returns:
- the previous lock (may be
null), with a failed flag if locking failed - Since:
- 11.1
-
removeStates
Removes a list of documents.Called after a
save()has been done. -
markUserChange
-
save
public void save()Writes transient state to database.An undo log is kept in order to rollback the transaction later if needed.
-
getConditionalUpdateForChangeToken
protected DBSTransactionState.ConditionalUpdates getConditionalUpdateForChangeToken(DBSDocumentState docState) -
updateChangeToken
-
applyUndoLog
protected void applyUndoLog() -
updateProxies
protected void updateProxies()Checks if the changed documents are proxy targets, and updates the proxies if that's the case. -
updateProxies
-
updateProxy
Updates the state of a proxy based on its target. -
isProxySpecific
Things that we don't touch on a proxy when updating it. -
updateDenormalizedState
protected void updateDenormalizedState() -
isBlobKeysDisabledForTestingPurpose
protected boolean isBlobKeysDisabledForTestingPurpose()For test purpose only.- Since:
- 2023.0
-
computeBlobKeys
protected void computeBlobKeys(DBSDocumentState docState, DBSTransactionState.BlobKeysFinder blobKeysFinder) -
begin
public void begin()Called when created in a transaction.- Since:
- 7.4
-
commit
public void commit()Saves and flushes to database. -
rollback
public void rollback()Rolls back the save state by applying the undo log. -
clearTransient
protected void clearTransient() -
getFulltextWorks
Gets the fulltext updates to do. Called at save() time.- Returns:
- a list of
Workinstances to schedule post-commit.
-
markIndexingInProgress
-
findDirtyDocuments
protected void findDirtyDocuments(Set<String> docsWithDirtyStrings, Set<String> docsWithDirtyBinaries) Finds the documents having dirty text or dirty binaries that have to be reindexed as fulltext.- Parameters:
docsWithDirtyStrings- set of ids, updated by this methoddocsWithDirtyBinaries- set of ids, updated by this method
-
scheduleWork
-
UpdateReadAclsActioninstead