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 TypeMethodDescriptionvoidcommit()Commits theReadWriteTransactionto persistent storage.voidcreateTask(TaskId taskId, long timestamp) Schedules the suppliedTaskIdto the supplied timestamp.voiddeleteTask(TaskId taskId) Deletes theTaskIdfrom the datastore.voidlinkExistingResource(ResourceId sourceResourceId, Path destination) Links an existingResourceIdto a newPath, throwing an instance ofResourceNotFoundExceptionif theResourceIdis not known or throwing an instance ofDuplicateExceptionif the suppliedPathexists.voidlinkNewResource(ResourceId resourceId, Path path) Creates a link betweeen aPathandResourceId, provided that neither already exist.voidremoveResource(ResourceId resourceId) Removes theResourcewith the suppliedResourceIdand automatically removes anyPathinstances that point to thatResourceId.removeResources(Path path, int max) Removes multipleResourceIds associated with the suppliedPath, if the associatedResourceIdis linked by no otherPaths, then this method will also delete theResourceIds associated with thsPath.voidrollback()Rolls back the transaction, releasing any temporary resources associated with theReadWriteTransaction.saveNewResource(Path path, ResourceId resourceId) unlinkPath(Path path) Unlinks the suppliedPath, if the associatedResourceIdis linked by no otherPaths, then this method will also delete theResourceIdassociated with it.updateResource(ResourceId resourceId) Opens aWritableByteChannelto a newly definedResourcewith theResourceIdIf theResourceIdis not found, then this must throw an instance ofResourceNotFoundExceptionto 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 aWritableByteChannelto a newly definedResourcewith the followingPathandResourceId. If aPathis already occupied, or theResourceIdhas already been added, then this throws an instance ofDuplicateException.- Parameters:
path- the path to link with the newResourceIdresourceId- theResourceIdof the newly insertedResourceId- Returns:
- a
WritableByteChannelwhich must be closed by the calling code when finished. - Throws:
IOException- if anIOExceptionprevented opening theWritableByteChannel
-
updateResource
Opens aWritableByteChannelto a newly definedResourcewith theResourceIdIf theResourceIdis not found, then this must throw an instance ofResourceNotFoundExceptionto indicate that the operation is not possible. The suppliedWritableByteChannelis 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- theResourceIdof the existingResourceId- Returns:
- a
WritableByteChannelwhich must be closed by the calling code when finished. - Throws:
IOException- if anIOExceptionprevented opening theWritableByteChannelResourceNotFoundException- if noResourceIdmatches
-
linkNewResource
Creates a link betweeen aPathandResourceId, provided that neither already exist. If either exist, then this will throw an instance ofDuplicateException.- Parameters:
resourceId- theResourceIdof the newly addedResourcepath- thePathto link to theResourceId
-
linkExistingResource
Links an existingResourceIdto a newPath, throwing an instance ofResourceNotFoundExceptionif theResourceIdis not known or throwing an instance ofDuplicateExceptionif the suppliedPathexists.- Parameters:
sourceResourceId- theResourceIdwhich will be the source of the linkdestination- thePathindicating the destination of the link
-
unlinkPath
Unlinks the suppliedPath, if the associatedResourceIdis linked by no otherPaths, then this method will also delete theResourceIdassociated with it. If there is not a resource for the suppliedPath, then this method will throw an instance ofResourceNotFoundException. The suppliedPathmust not be a wildcard.- Parameters:
path- thePathto unlink- Returns:
- an instance of
ResourceService.Unlinkindicating the result of the operation.
-
removeResource
Removes theResourcewith the suppliedResourceIdand automatically removes anyPathinstances that point to thatResourceId. If no suchResourceIdexists, then this method must throw an instance ofResourceNotFoundException.- Parameters:
resourceId- theResourceIdto remove
-
removeResources
Removes multipleResourceIds associated with the suppliedPath, if the associatedResourceIdis linked by no otherPaths, then this method will also delete theResourceIds associated with thsPath. If thePathis not a wildcardPath, then the returnedStream<ResourceId>will have, at most, a single value. If thePathis 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 noPaths match.- Parameters:
path- thePathto unlink- Returns:
- an instance of
ResourceService.Unlinkindicating the result of the operation.
-
deleteTask
Deletes theTaskIdfrom the datastore.- Parameters:
taskId- theTaskId.
-
createTask
Schedules the suppliedTaskIdto the supplied timestamp.- Parameters:
taskId- theTaskIdtimestamp- the timestamp.
-
rollback
void rollback()Rolls back the transaction, releasing any temporary resources associated with theReadWriteTransaction. -
commit
void commit()Commits theReadWriteTransactionto persistent storage. Once this method returns then all staged changes will persist and can be visible to all new transactions.
-