public class DBSTransactionState extends Object
Until save()
is called, data lives in the transient map.
Upon save, data is written to the repository, even though it has not yet been committed (this means that other sessions can read uncommitted data). It's 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.
Modifier and Type | Class and Description |
---|---|
static class |
DBSTransactionState.ChangeTokenUpdater
Logic to get the conditions to use to match and update a change token.
|
protected static class |
DBSTransactionState.DirtyPathsFinder
Iterates on a state diff to find the paths corresponding to dirty values.
|
static class |
DBSTransactionState.FindReadAclsWork
Work to find the ids of documents for which Read ACLs must be recomputed, and launch the needed update works.
|
protected static class |
DBSTransactionState.FulltextFinder |
static class |
DBSTransactionState.UpdateReadAclsWork
Work to update the Read ACLs on a list of documents, without recursion.
|
Modifier and Type | Field and Description |
---|---|
protected Set<String> |
browsePermissions |
static String |
READ_ACL_ASYNC_ENABLED_DEFAULT |
static String |
READ_ACL_ASYNC_ENABLED_PROPERTY |
static String |
READ_ACL_ASYNC_THRESHOLD_DEFAULT |
static String |
READ_ACL_ASYNC_THRESHOLD_PROPERTY |
protected static Set<String> |
READ_ACL_RECURSION_KEYS
Keys used when computing Read ACLs.
|
protected DBSRepository |
repository |
protected DBSSession |
session |
protected Set<String> |
transientCreated
Ids of documents created but not yet saved.
|
protected Map<String,DBSDocumentState> |
transientStates
Retrieved and created document state.
|
protected Map<String,State> |
undoLog
Undo log.
|
protected Set<Serializable> |
userChangeIds
Document ids modified as "user changes", which means that a change token should be checked.
|
Constructor and Description |
---|
DBSTransactionState(DBSRepository repository,
DBSSession session) |
Modifier and Type | Method and Description |
---|---|
protected void |
applyUndoLog() |
void |
begin()
Called when created in a transaction.
|
protected void |
clearTransient() |
void |
commit()
Saves and flushes to database.
|
protected void |
commitSave()
Commits the saved state to the database.
|
DBSDocumentState |
copy(String id)
Copies the document into a newly-created object.
|
DBSDocumentState |
createChild(String id,
String parentId,
String name,
Long pos,
String typeName) |
protected void |
findDirtyDocuments(Set<String> docsWithDirtyStrings,
Set<String> docWithDirtyBinaries)
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.
|
List<String> |
getChildrenIds(String parentId) |
List<DBSDocumentState> |
getChildrenStates(String parentId) |
DBSDocumentState |
getChildState(String parentId,
String name) |
protected Stream<State> |
getDescendants(String id,
Set<String> keys,
int limit) |
protected void |
getFulltextBinariesWorks(List<Work> works,
Set<String> docWithDirtyBinaries) |
protected void |
getFulltextSimpleWorks(List<Work> works,
Set<String> docsWithDirtyStrings) |
protected List<Work> |
getFulltextWorks()
Gets the fulltext updates to do.
|
List<DBSDocumentState> |
getKeyValuedStates(String key,
Object value) |
List<DBSDocumentState> |
getKeyValuedStates(String key1,
Object value1,
String key2,
Object value2) |
protected String[] |
getReadACL(State state)
Gets the Read ACL (flat list of users having browse permission, including inheritance) on a document.
|
protected int |
getReadAclsAsyncThreshold() |
State |
getStateForRead(String id)
Returns a state which won't be modified.
|
DBSDocumentState |
getStateForUpdate(String id)
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).
|
List<DBSDocumentState> |
getStatesForUpdate(List<String> ids)
Returns states and marks them transient, because they're about to be returned to user code (where they may be
modified).
|
boolean |
hasChild(String parentId,
String name) |
boolean |
hasChildren(String parentId) |
protected boolean |
isProxySpecific(String key,
SchemaManager schemaManager)
Things that we don't touch on a proxy when updating it.
|
void |
markUserChange(String id) |
protected DBSDocumentState |
newTransientState(State state)
New transient state for something just read from the repository.
|
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) |
void |
updateAncestors(String id,
int ndel,
Object[] ancestorIds)
Updates ancestors recursively after a move.
|
protected void |
updateDocumentReadAcls(String id)
Updates the Read ACLs on a document (not recursively)
|
protected void |
updateDocumentReadAclsNoCache(String id)
Updates the Read ACLs on a document, without polluting caches.
|
protected void |
updateProxies()
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 |
updateTreeReadAcls(String id)
Updates the Read ACLs recursively on a document.
|
protected static final Set<String> READ_ACL_RECURSION_KEYS
public static final String READ_ACL_ASYNC_ENABLED_PROPERTY
public static final String READ_ACL_ASYNC_ENABLED_DEFAULT
public static final String READ_ACL_ASYNC_THRESHOLD_PROPERTY
public static final String READ_ACL_ASYNC_THRESHOLD_DEFAULT
protected final DBSRepository repository
protected final DBSSession session
protected Map<String,DBSDocumentState> transientStates
protected Set<String> transientCreated
protected final Set<Serializable> userChangeIds
protected Map<String,State> undoLog
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.
protected final Set<String> browsePermissions
public DBSTransactionState(DBSRepository repository, DBSSession session)
protected DBSDocumentState newTransientState(State state)
public DBSDocumentState getStateForUpdate(String id)
public State getStateForRead(String id)
public List<DBSDocumentState> getStatesForUpdate(List<String> ids)
public DBSDocumentState getChildState(String parentId, String name)
public List<DBSDocumentState> getChildrenStates(String parentId)
public List<String> getChildrenIds(String parentId)
public boolean hasChildren(String parentId)
public DBSDocumentState createChild(String id, String parentId, String name, Long pos, String typeName)
protected Object[] getAncestorIds(String id)
public DBSDocumentState copy(String id)
The copy is automatically saved.
public void updateAncestors(String id, int ndel, Object[] ancestorIds)
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.
protected int getReadAclsAsyncThreshold()
public void updateTreeReadAcls(String id)
public void updateReadACLs(Collection<String> docIds)
protected void updateDocumentReadAcls(String id)
protected void updateDocumentReadAclsNoCache(String id)
When fetching parents recursively to compute inheritance, the regular transient space and repository caching are used.
protected String[] getReadACL(State state)
public List<DBSDocumentState> getKeyValuedStates(String key, Object value)
public List<DBSDocumentState> getKeyValuedStates(String key1, Object value1, String key2, Object value2)
public void removeStates(Set<String> ids)
Called after a save()
has been done.
public void markUserChange(String id)
public void save()
An undo log is kept in order to rollback the transaction later if needed.
protected void applyUndoLog()
protected void updateProxies()
protected void updateProxies(DBSDocumentState target)
protected void updateProxy(DBSDocumentState target, String proxyId)
protected boolean isProxySpecific(String key, SchemaManager schemaManager)
public void begin()
public void commit()
protected void commitSave()
public void rollback()
protected void clearTransient()
protected List<Work> getFulltextWorks()
Work
instances to schedule post-commit.protected void findDirtyDocuments(Set<String> docsWithDirtyStrings, Set<String> docWithDirtyBinaries)
docsWithDirtyStrings
- set of ids, updated by this methoddocWithDirtyBinaries
- set of ids, updated by this methodprotected void getFulltextSimpleWorks(List<Work> works, Set<String> docsWithDirtyStrings)
protected void getFulltextBinariesWorks(List<Work> works, Set<String> docWithDirtyBinaries)
protected void scheduleWork(List<Work> works)
Copyright © 2018 Nuxeo. All rights reserved.