@Component public class CriticalPath extends Object implements CriticalRepositoryInteraction
CriticalRepositoryInteraction, and boilerplate for interacting with, and
modifying the state of, repository resources.
Note that the critical
methods may modify the state of a resource.
If the the critical method modifies resource state (tested according to PassEntity.hashCode()), the resource
will be persisted in the repository. Likewise, if the critical method does not modify resource state, it
will not attempt to persist the resource (since there are no changes to persist). Even though update
requests (e.g. implemented as PATCH HTTP requests) that do not change the state of the resource are
idempotent, Fedora issues a JMS message indicating that the resource has been modified. This happens despite the
"business" state of the resource having not been changed.
CriticalRepositoryInteraction.CriticalResult<R,T>| Constructor and Description |
|---|
CriticalPath(org.dataconservancy.pass.client.PassClient passClient,
ConflictHandler conflictHandler) |
| Modifier and Type | Method and Description |
|---|---|
<R,T extends org.dataconservancy.pass.model.PassEntity> |
performCritical(URI uri,
Class<T> clazz,
Predicate<T> precondition,
BiPredicate<T,R> postcondition,
Function<T,R> critical)
Execute a critical interaction with the repository, subject to
precondition. |
<R,T extends org.dataconservancy.pass.model.PassEntity> |
performCritical(URI uri,
Class<T> clazz,
Predicate<T> precondition,
Predicate<T> postcondition,
Function<T,R> critical)
Execute a critical interaction with the repository, subject to
precondition. |
public CriticalPath(org.dataconservancy.pass.client.PassClient passClient,
ConflictHandler conflictHandler)
public <R,T extends org.dataconservancy.pass.model.PassEntity> CriticalRepositoryInteraction.CriticalResult<R,T> performCritical(URI uri, Class<T> clazz, Predicate<T> precondition, Predicate<T> postcondition, Function<T,R> critical)
precondition. Success of the interaction
depends on the evaluation of postcondition.
See the other form of performCritical if the postcondition needs to evaluate both the PassEntity resource and the
return from the critical path.
uri, insuring no interference from other
threads executing in this JVMPassEntity identified by uri from the repository, short-circuiting the
interaction by returning a CriticalResult if an Exception is thrownPredicate, short-circuiting the interaction by returning a
CriticalResult if the condition failscritical interaction, short-circuiting the interaction by returning a
CriticalResult if an Exception is throwncritical interaction modifies the resource, update the resource in the repository. Read
the resource from the repository (even if no update is performed). If a ConflictUpdateException
is thrown during the update, it is supplied to the ConflictHandler for resolution. If any other
Exception is thrown, the interaction is short-circuited, and a CriticalResult
returned.Predicate and returns CriticalResult
All code that executes within this method is executed within try/catch blocks. Each lambda passed to
this method executes within a try/catch, and all supporting code within this method executes within
try/catch blocks. If an Exception is thrown, it will be caught, placed in the CriticalResult, and this method immediately returns. The caller is responsible for evaluating the CriticalResult and determining success or failure of this method.
performCritical in interface CriticalRepositoryInteractionT - the type of PassEntityR - the type of Object returned by criticaluri - the uri of the PassEntity which is the subject of the critical pathvclazz - the concrete Class of the PassEntity represented by uriprecondition - precondition that must evaluate to true for the critical path to executepostcondition - postcondition that must evaluate to true for the CriticalResult to be
considered successfulcritical - the critical interaction with the repository, which may return a result of type RCriticalResult encapsulating the PassEntity, the return from the critical path,
any exception thrown, and the overall success as determined by the post-conditionpublic <R,T extends org.dataconservancy.pass.model.PassEntity> CriticalRepositoryInteraction.CriticalResult<R,T> performCritical(URI uri, Class<T> clazz, Predicate<T> precondition, BiPredicate<T,R> postcondition, Function<T,R> critical)
precondition. Success of the interaction
depends on the evaluation of postcondition.
See the other form of performCritical if the postcondition only needs to evaluate the PassEntity resource.
uri, insuring no interference from other
threads executing in this JVMPassEntity identified by uri from the repository, short-circuiting the
interaction by returning a CriticalResult if an Exception is thrownPredicate, short-circuiting the interaction by returning a
CriticalResult if the condition failscritical interaction, short-circuiting the interaction by returning a
CriticalResult if an Exception is throwncritical interaction modifies the resource, update the resource in the repository. Read
the resource from the repository (even if no update is performed). If a ConflictUpdateException
is thrown during the update, it is supplied to the ConflictHandler for resolution. If any other
Exception is thrown, the interaction is short-circuited, and a CriticalResult
returned.BiPredicate and returns CriticalResult
All code that executes within this method is executed within try/catch blocks. Each lambda passed to
this method executes within a try/catch, and all supporting code within this method executes within
try/catch blocks. If an Exception is thrown, it will be caught, placed in the CriticalResult, and this method immediately returns. The caller is responsible for evaluating the CriticalResult and determining success or failure of this method.
performCritical in interface CriticalRepositoryInteractionT - the type of PassEntityR - the type of Object returned by criticaluri - the uri of the PassEntity which is the subject of the critical pathvclazz - the concrete Class of the PassEntity represented by uriprecondition - precondition that must evaluate to true for the critical path to executepostcondition - postcondition that must evaluate to true for the CriticalResult to be
considered successfulcritical - the critical interaction with the repository, which may return a result of type RCriticalResult encapsulating the PassEntity, the return from the critical path,
any exception thrown, and the overall success as determined by the post-conditionCopyright © 2019. All rights reserved.