Interface ReadWriteTransaction
- All Superinterfaces:
AutoCloseable
,ReadOnlyTransaction
Defines a set of mutable transactional operations.
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.getelements.elements.rt.transact.ReadOnlyTransaction
ReadOnlyTransaction.Builder<TransactionT extends ReadOnlyTransaction>
-
Method Summary
Modifier and TypeMethodDescriptionvoid
commit()
Commits theReadWriteTransaction
to persistent storage.void
createTask
(TaskId taskId, long timestamp) Schedules the suppliedTaskId
to the supplied timestamp.void
deleteTask
(TaskId taskId) Deletes theTaskId
from the datastore.void
linkExistingResource
(ResourceId sourceResourceId, Path destination) Links an existingResourceId
to a newPath
, throwing an instance ofResourceNotFoundException
if theResourceId
is not known or throwing an instance ofDuplicateException
if the suppliedPath
exists.void
linkNewResource
(ResourceId resourceId, Path path) Creates a link betweeen aPath
andResourceId
, provided that neither already exist.void
removeResource
(ResourceId resourceId) Removes theResource
with the suppliedResourceId
and automatically removes anyPath
instances that point to thatResourceId
.removeResources
(Path path, int max) Removes multipleResourceId
s associated with the suppliedPath
, if the associatedResourceId
is linked by no otherPath
s, then this method will also delete theResourceId
s associated with thsPath
.void
rollback()
Rolls back the transaction, releasing any temporary resources associated with theReadWriteTransaction
.saveNewResource
(Path path, ResourceId resourceId) unlinkPath
(Path path) Unlinks the suppliedPath
, if the associatedResourceId
is linked by no otherPath
s, then this method will also delete theResourceId
associated with it.updateResource
(ResourceId resourceId) Opens aWritableByteChannel
to a newly definedResource
with theResourceId
If theResourceId
is not found, then this must throw an instance ofResourceNotFoundException
to indicate that the operation is not possible.Methods inherited from interface dev.getelements.elements.rt.transact.ReadOnlyTransaction
check, close, exists, getNodeId, getResourceId, list, loadResourceContents
-
Method Details
-
saveNewResource
Opens aWritableByteChannel
to a newly definedResource
with the followingPath
andResourceId
. If aPath
is already occupied, or theResourceId
has already been added, then this throws an instance ofDuplicateException
.- Parameters:
path
- the path to link with the newResourceId
resourceId
- theResourceId
of the newly insertedResourceId
- Returns:
- a
WritableByteChannel
which must be closed by the calling code when finished. - Throws:
IOException
- if anIOException
prevented opening theWritableByteChannel
-
updateResource
Opens aWritableByteChannel
to a newly definedResource
with theResourceId
If theResourceId
is not found, then this must throw an instance ofResourceNotFoundException
to indicate that the operation is not possible. The suppliedWritableByteChannel
is only guaranteed to be valid for the life of the transaction which created it. It may still be possible to write after the transaction is closed. However, the behavior of which is not defined.- Parameters:
resourceId
- theResourceId
of the existingResourceId
- Returns:
- a
WritableByteChannel
which must be closed by the calling code when finished. - Throws:
IOException
- if anIOException
prevented opening theWritableByteChannel
ResourceNotFoundException
- if noResourceId
matches
-
linkNewResource
Creates a link betweeen aPath
andResourceId
, provided that neither already exist. If either exist, then this will throw an instance ofDuplicateException
.- Parameters:
resourceId
- theResourceId
of the newly addedResource
path
- thePath
to link to theResourceId
-
linkExistingResource
Links an existingResourceId
to a newPath
, throwing an instance ofResourceNotFoundException
if theResourceId
is not known or throwing an instance ofDuplicateException
if the suppliedPath
exists.- Parameters:
sourceResourceId
- theResourceId
which will be the source of the linkdestination
- thePath
indicating the destination of the link
-
unlinkPath
Unlinks the suppliedPath
, if the associatedResourceId
is linked by no otherPath
s, then this method will also delete theResourceId
associated with it. If there is not a resource for the suppliedPath
, then this method will throw an instance ofResourceNotFoundException
. The suppliedPath
must not be a wildcard.- Parameters:
path
- thePath
to unlink- Returns:
- an instance of
ResourceService.Unlink
indicating the result of the operation.
-
removeResource
Removes theResource
with the suppliedResourceId
and automatically removes anyPath
instances that point to thatResourceId
. If no suchResourceId
exists, then this method must throw an instance ofResourceNotFoundException
.- Parameters:
resourceId
- theResourceId
to remove
-
removeResources
Removes multipleResourceId
s associated with the suppliedPath
, if the associatedResourceId
is linked by no otherPath
s, then this method will also delete theResourceId
s associated with thsPath
. If thePath
is not a wildcardPath
, then the returnedStream<ResourceId>
will have, at most, a single value. If thePath
is a wildcardPath
, then the returnedStream<ResourceId>
will have, at most, the value specified in this method. This method should never throw an instance ofResourceNotFoundException
, but rather return an empty result if noPath
s match.- Parameters:
path
- thePath
to unlink- Returns:
- an instance of
ResourceService.Unlink
indicating the result of the operation.
-
deleteTask
Deletes theTaskId
from the datastore.- Parameters:
taskId
- theTaskId
.
-
createTask
Schedules the suppliedTaskId
to the supplied timestamp.- Parameters:
taskId
- theTaskId
timestamp
- the timestamp.
-
rollback
void rollback()Rolls back the transaction, releasing any temporary resources associated with theReadWriteTransaction
. -
commit
void commit()Commits theReadWriteTransaction
to persistent storage. Once this method returns then all staged changes will persist and can be visible to all new transactions.
-