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
Modifier and TypeClassDescriptionprotected static class
Iterates on aState
to find the blob keys.static class
Logic to get the conditions to use to match and update a change token.protected static class
Iterates on a state diff to find the paths corresponding to dirty values.static class
Deprecated.static class
Deprecated.since 2021.11 useUpdateReadAclsAction
instead -
Field Summary
Modifier and TypeFieldDescriptionprotected final DBSConnection
protected Boolean
For test purpose only.protected final boolean
static final String
static final String
static final String
static final String
Keys used when computing Read ACLs.protected final DBSRepository
protected final DBSSession
Ids 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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
begin()
Called when created in a transaction.protected void
void
close()
void
commit()
Saves and flushes to database.protected void
computeBlobKeys
(DBSDocumentState docState, DBSTransactionState.BlobKeysFinder blobKeysFinder) Copies the document into a newly-created object.boolean
Returns whether or not the document with givenid
exists in the storage.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.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.ConditionalUpdates
getDescendants
(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 int
Returns 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).boolean
boolean
hasChildren
(String parentId) protected boolean
For test purpose only.protected boolean
isProxySpecific
(String key, SchemaManager schemaManager) Things that we don't touch on a proxy when updating it.protected boolean
isUnderSyncLimit
(int limit, Set<String> ids) protected void
markIndexingInProgress
(Set<String> ids) void
markUserChange
(String id) protected State
materializedKeys
(State state) Returns materialized keys for a state: - Read ACL (flat list of users having browse permission, including inheritance) on a document - Ancestor idsprotected DBSDocumentState
newTransientState
(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.void
removeStates
(Set<String> ids) Removes a list of documents.void
rollback()
Rolls back the save state by applying the undo log.void
save()
Writes transient state to database.protected void
scheduleWork
(List<Work> works) scroll
(DBSExpressionEvaluator evaluator, int batchSize, int keepAliveSeconds) Sets a lock on a document.void
updateAncestors
(String id, int ndel, Object[] ancestorIds) Updates ancestors recursively after a move.protected static Long
updateChangeToken
(Long changeToken) protected void
protected void
Updates the Read ACLs on a document (not recursively)protected void
Updates the Read ACLs on a document, without polluting caches.protected void
Checks if the changed documents are proxy targets, and updates the proxies if that's the case.protected void
updateProxies
(DBSDocumentState target) protected void
updateProxy
(DBSDocumentState target, String proxyId) Updates the state of a proxy based on its target.void
updateReadACLs
(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).void
Updates the Read ACLs recursively on a document.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.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_CREATE
then 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:
close
in 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 givenid
exists 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:LockManager
Gets the lock on a document.If the document does not exist,
null
is returned.- Specified by:
getLock
in interfaceLockManager
- Parameters:
id
- the document id- Returns:
- the existing lock, or
null
when there is no lock - Since:
- 11.1
-
setLock
Description copied from interface:LockManager
Sets 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:
setLock
in interfaceLockManager
- Parameters:
id
- the document idlock
- the lock to set- Returns:
null
if locking succeeded, or the existing lock if locking failed- Since:
- 11.1
-
removeLock
Description copied from interface:LockManager
Removes the lock from a document.The previous lock is returned.
If
owner
isnull
then the lock is unconditionally removed.If
owner
is notnull
, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will returntrue
forLock.getFailed()
.- Specified by:
removeLock
in interfaceLockManager
- Parameters:
id
- the document idowner
- the owner to check, ornull
for 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
Work
instances 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
-
UpdateReadAclsAction
instead