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 |
---|---|
protected static class |
DBSTransactionState.DirtyPathsFinder
Iterates on a state diff to find the paths corresponding to dirty values.
|
protected static class |
DBSTransactionState.FulltextFinder |
Modifier and Type | Field and Description |
---|---|
protected Set<String> |
browsePermissions |
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.
|
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 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(DBSDocumentState docState)
Gets the Read ACL (flat list of users having browse permission, including inheritance) on a document.
|
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).
|
protected Set<String> |
getSubTree(String id,
Map<String,String> proxyTargets,
Map<String,Object[]> targetProxies)
Gets all the ids under a given one, recursively.
|
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.
|
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 |
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 |
updateTreeReadAcls(String id)
Updates the Read ACLs recursively on a document.
|
protected final DBSRepository repository
protected final DBSSession session
protected Map<String,DBSDocumentState> transientStates
protected Set<String> transientCreated
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.
public void updateTreeReadAcls(String id)
protected void updateDocumentReadAcls(String id)
protected String[] getReadACL(DBSDocumentState docState)
protected Set<String> getSubTree(String id, Map<String,String> proxyTargets, Map<String,Object[]> targetProxies)
Doesn't check transient (assumes save is done).
id
- the root of the tree (not included in results)proxyTargets
- returns a map of proxy to target among the documents foundtargetProxies
- returns a map of target to proxies among the document foundpublic 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 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 © 2016 Nuxeo SA. All rights reserved.