Interface Root
-
public interface RootARootinstance serves as a container for aTree. It is obtained from aContentSession, which governs accessibility and visibility of theTreeand its sub trees.All root instances created by a content session become invalid after the content session is closed. Any method called on an invalid root instance will throw an
InvalidStateException.Treeinstances may become non existing after a call torefresh(),rebase()orcommit(). Any write access to non existingTreeinstances will cause anInvalidStateException.- See Also:
Existence and iterability of trees
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOMMIT_PATHName of the entry of the commit path in theinfomap incommit(java.util.Map)
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcommit()Atomically persists all changes made to the tree attached to this root.voidcommit(@NotNull java.util.Map<java.lang.String,java.lang.Object> info)Atomically persists all changes made to the tree attached to this root.@NotNull BlobcreateBlob(@NotNull java.io.InputStream stream)Reads (and closes) the given stream and returns aBlobthat contains that binary.@Nullable BlobgetBlob(@NotNull java.lang.String reference)Get a blob by its reference.@NotNull ContentSessiongetContentSession()Get theContentSessionfrom which this root was acquired@NotNull QueryEnginegetQueryEngine()Get the query engine.@NotNull TreegetTree(@NotNull java.lang.String path)Retrieve the possible non existingTreeat the given absolutepath.booleanhasPendingChanges()Determine whether there are changes on this treebooleanmove(java.lang.String sourcePath, java.lang.String destPath)Move the child located atsourcePathto a child atdestPath.voidrebase()Rebase this root instance to the latest revision.voidrefresh()Reverts all changes made to this root and refreshed to the latest trunk.
-
-
-
Field Detail
-
COMMIT_PATH
static final java.lang.String COMMIT_PATH
Name of the entry of the commit path in theinfomap incommit(java.util.Map)- See Also:
- Constant Field Values
-
-
Method Detail
-
move
boolean move(java.lang.String sourcePath, java.lang.String destPath)Move the child located atsourcePathto a child atdestPath. Both paths must be absolute and resolve to a child located beneath this root.
This method does nothing and returnsfalseif- the tree at
sourcePathdoes not exist or is not accessible, - the parent of the tree at
destinationPathdoes not exist or is not accessible, - a tree already exists at
destinationPath.
destinationPathexists but is not accessible to the editing content session this method succeeds but a subsequentcommit()will detect the violation and fail.- Parameters:
sourcePath- The source pathdestPath- The destination path- Returns:
trueon success,falseotherwise.
- the tree at
-
getTree
@NotNull @NotNull Tree getTree(@NotNull @NotNull java.lang.String path)
Retrieve the possible non existingTreeat the given absolutepath. The path must resolve to a tree in this root.- Parameters:
path- absolute path to the tree- Returns:
- tree at the given path.
-
rebase
void rebase()
Rebase this root instance to the latest revision. After a call to this method, trees obtained throughgetTree(String)may become non existing.
-
refresh
void refresh()
Reverts all changes made to this root and refreshed to the latest trunk. After a call to this method, trees obtained throughgetTree(String)may become non existing.
-
commit
void commit(@NotNull @NotNull java.util.Map<java.lang.String,java.lang.Object> info) throws CommitFailedExceptionAtomically persists all changes made to the tree attached to this root.If
infocontains a mapping forCOMMIT_PATHand the associated value is a string, implementations may throw aCommitFailedExceptionif there are changes outside of the subtree designated by that path and the implementation does not support such partial commits. However all implementation must handler the case where apathdesignates a subtree that contains all unpersisted changes.The
infomap is passed to the underlying storage as a part of the internal commit information attached to this commit. The commit information will be made available to local observers but will not be visible to observers on other cluster nodes.After a successful operation the root is automatically
refreshed, such that trees previously obtained throughgetTree(String)may become non existing.- Parameters:
info- commit information- Throws:
CommitFailedException- if the commit failed
-
commit
void commit() throws CommitFailedExceptionAtomically persists all changes made to the tree attached to this root. Calling this method is equivalent to calling thecommit(Map info)method with an empty info map.- Throws:
CommitFailedException- if the commit failed
-
hasPendingChanges
boolean hasPendingChanges()
Determine whether there are changes on this tree- Returns:
trueiff this tree was modified
-
getQueryEngine
@NotNull @NotNull QueryEngine getQueryEngine()
Get the query engine.- Returns:
- the query engine
-
createBlob
@NotNull @NotNull Blob createBlob(@NotNull @NotNull java.io.InputStream stream) throws java.io.IOException
Reads (and closes) the given stream and returns aBlobthat contains that binary. The returned blob will remain valid at least until theContentSessionof this root is closed, or longer if it has been committed as a part of a content update.The implementation may decide to persist the blob at any point during or between this method method call and a
commit()that includes the blob, but the blob will become visible to other sessions only after such a commit.- Parameters:
stream- the stream for reading the binary- Returns:
- the blob that was created
- Throws:
java.io.IOException- if the stream could not be read
-
getBlob
@Nullable @Nullable Blob getBlob(@NotNull @NotNull java.lang.String reference)
Get a blob by its reference.- Parameters:
reference- reference to the blob- Returns:
- blob or
nullif the reference does not resolve to a blob. - See Also:
Blob.getReference()
-
getContentSession
@NotNull @NotNull ContentSession getContentSession()
Get theContentSessionfrom which this root was acquired- Returns:
- the associated ContentSession
- Throws:
java.lang.UnsupportedOperationException
-
-