Class ImmutableRoot
- java.lang.Object
-
- org.apache.jackrabbit.oak.core.ImmutableRoot
-
public final class ImmutableRoot extends Object implements Root, ReadOnly
Simple implementation of the Root interface that only supports simple read operations based on theNodeState(orImmutableTree) passed to the constructor. This root implementation provides a query engine with index support limited to thePropertyIndexProvider.
-
-
Field Summary
-
Fields inherited from interface org.apache.jackrabbit.oak.api.Root
COMMIT_PATH
-
-
Constructor Summary
Constructors Constructor Description ImmutableRoot(@NotNull Root root)ImmutableRoot(@NotNull ImmutableTree rootTree)ImmutableRoot(@NotNull NodeState rootState)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommit()Atomically persists all changes made to the tree attached to this root.voidcommit(@NotNull Map<String,Object> info)Atomically persists all changes made to the tree attached to this root.@NotNull BlobcreateBlob(@NotNull InputStream stream)Reads (and closes) the given stream and returns aBlobthat contains that binary.BlobgetBlob(@NotNull String reference)Get a blob by its reference.@NotNull ContentSessiongetContentSession()Get theContentSessionfrom which this root was acquiredstatic ImmutableRootgetInstance(@NotNull Root root)@NotNull QueryEnginegetQueryEngine()Get the query engine.@NotNull ImmutableTreegetTree(@NotNull String path)Retrieve the possible non existingTreeat the given absolutepath.booleanhasPendingChanges()Determine whether there are changes on this treebooleanmove(String sourcePath, 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.
-
-
-
Constructor Detail
-
ImmutableRoot
public ImmutableRoot(@NotNull @NotNull NodeState rootState)
-
ImmutableRoot
public ImmutableRoot(@NotNull @NotNull Root root)
-
ImmutableRoot
public ImmutableRoot(@NotNull @NotNull ImmutableTree rootTree)
-
-
Method Detail
-
getInstance
public static ImmutableRoot getInstance(@NotNull @NotNull Root root)
-
getTree
@NotNull public @NotNull ImmutableTree getTree(@NotNull @NotNull String path)
Description copied from interface:RootRetrieve the possible non existingTreeat the given absolutepath. The path must resolve to a tree in this root.
-
move
public boolean move(String sourcePath, String destPath)
Description copied from interface:RootMove 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 subsequentRoot.commit()will detect the violation and fail. - the tree at
-
rebase
public void rebase()
Description copied from interface:RootRebase this root instance to the latest revision. After a call to this method, trees obtained throughRoot.getTree(String)may become non existing.
-
refresh
public void refresh()
Description copied from interface:RootReverts all changes made to this root and refreshed to the latest trunk. After a call to this method, trees obtained throughRoot.getTree(String)may become non existing.
-
commit
public void commit(@NotNull @NotNull Map<String,Object> info)Description copied from interface:RootAtomically persists all changes made to the tree attached to this root.If
infocontains a mapping forRoot.COMMIT_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 throughRoot.getTree(String)may become non existing.
-
commit
public void commit()
Description copied from interface:RootAtomically persists all changes made to the tree attached to this root. Calling this method is equivalent to calling theRoot.commit(Map info)method with an empty info map.
-
hasPendingChanges
public boolean hasPendingChanges()
Description copied from interface:RootDetermine whether there are changes on this tree- Specified by:
hasPendingChangesin interfaceRoot- Returns:
trueiff this tree was modified
-
getQueryEngine
@NotNull public @NotNull QueryEngine getQueryEngine()
Description copied from interface:RootGet the query engine.- Specified by:
getQueryEnginein interfaceRoot- Returns:
- the query engine
-
createBlob
@NotNull public @NotNull Blob createBlob(@NotNull @NotNull InputStream stream)
Description copied from interface:RootReads (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
Root.commit()that includes the blob, but the blob will become visible to other sessions only after such a commit.- Specified by:
createBlobin interfaceRoot- Parameters:
stream- the stream for reading the binary- Returns:
- the blob that was created
-
getBlob
public Blob getBlob(@NotNull @NotNull String reference)
Description copied from interface:RootGet a blob by its reference.- Specified by:
getBlobin interfaceRoot- Parameters:
reference- reference to the blob- Returns:
- blob or
nullif the reference does not resolve to a blob. - See Also:
Blob.getReference()
-
getContentSession
@NotNull public @NotNull ContentSession getContentSession()
Description copied from interface:RootGet theContentSessionfrom which this root was acquired- Specified by:
getContentSessionin interfaceRoot- Returns:
- the associated ContentSession
-
-