Package org.nuxeo.ecm.automation
Interface AutomationService
- All Known Implementing Classes:
OperationServiceImpl
public interface AutomationService
Service providing an operation registry and operation execution methods. The operation registry is thread-safe and
optimized for lookups. Progress monitor for asynchronous executions is not yet implemented.
- Author:
- Bogdan Stefanescu, Guillaume
-
Method Summary
Modifier and TypeMethodDescriptioncompileChain(Class<?> inputType, OperationChain chain) Builds the operation chain given a context.compileChain(Class<?> inputType, OperationParameters... chain) Same as previous but takes an array of operation parameters<T> TgetAdaptedValue(OperationContext ctx, Object toAdapt, Class<?> targetType) Adapts an object to a target type if possible otherwise throws an exception.getChainException(String onChainId) Generates a documentation model for all registered operations.getOperation(String id) Gets an operation type given its ID.Gets all operation types that was registered.getTypeAdapter(Class<?> accept, Class<?> produce) Gets a type adapter for the input type accept and the output type produce.booleanhasChainException(String onChainId) booleanhasOperation(String id) booleanisTypeAdaptable(Class<?> typeToAdapt, Class<?> targetType) Checks whether or not the given type is adaptable into the target type.voidputAutomationFilter(AutomationFilter automationFilter) voidputChainException(ChainException exceptionChain) voidputOperation(Class<?> type) Registers an operation given its class.voidputOperation(Class<?> type, boolean replace) Registers an operation given its class.voidputOperation(Class<?> type, boolean replace, String contributingComponent) Registers an operation given its class.voidputOperation(Class<?> type, boolean replace, String contributingComponent, List<WidgetDefinition> widgetDefinitionList) voidputOperation(OperationType op, boolean replace) Registers an operation given it's type.voidputTypeAdapter(Class<?> accept, Class<?> produce, TypeAdapter adapter) Registers a new type adapter that can adapt an instance of the accepted type into one of the produced type.voidremoveAutomationFilter(AutomationFilter automationFilter) voidremoveExceptionChain(ChainException exceptionChain) voidremoveOperation(Class<?> key) Removes an operation given its class.voidremoveOperation(OperationType type) Removes an operation given it's type.voidremoveTypeAdapter(Class<?> accept, Class<?> produce) Removes a type adapterrun(OperationContext ctx, String chainId) Same as previous but for managed chains identified by an ID.run(OperationContext ctx, String id, Map<String, ?> params) Shortcut to execute a single operation described by the given ID and map of parametersrun(OperationContext ctx, OperationChain chain) Builds and runs the operation chain given a context.runInNewTx(OperationContext ctx, String chainId, Map<String, ?> chainParameters, Integer timeout, boolean rollbackGlobalOnError) This running method execute operation process through a new transaction.
-
Method Details
-
putOperation
Registers an operation given its class. The operation class MUST be annotated usingOperationannotation. If an operation having the same ID exists an exception will be thrown.- Throws:
OperationException
-
putOperation
Registers an operation given its class. The operation class MUST be annotated usingOperationannotation. If thereplaceargument is true then any existing operation having the same ID will replaced with this one.- Throws:
OperationException
-
putOperation
void putOperation(Class<?> type, boolean replace, String contributingComponent) throws OperationException Registers an operation given its class. The operation class MUST be annotated usingOperationannotation. If thereplaceargument is true then any existing operation having the same ID will replaced with this one. Third argument represents the name of the component registring the operation- Throws:
OperationException
-
putOperation
Registers an operation given it's type.- Throws:
OperationException- Since:
- 5.9.2
-
removeOperation
Removes an operation given its class. If the operation was not registered does nothing. -
removeOperation
Removes an operation given it's type. If the operation was not registered does nothing.- Since:
- 5.9.2
-
getOperations
OperationType[] getOperations()Gets all operation types that was registered. -
getOperation
Gets an operation type given its ID. Throws an exception if the operation is not found.- Throws:
OperationNotFoundException
-
compileChain
Builds the operation chain given a context. If the context input object or the chain cannot be resolved (no path can be found through all the operation in the chain) thenInvalidChainExceptionis thrown. The returned object can be used to run the chain.- Throws:
OperationException
-
compileChain
CompiledChain compileChain(Class<?> inputType, OperationParameters... chain) throws OperationException Same as previous but takes an array of operation parameters- Throws:
OperationException
-
run
Builds and runs the operation chain given a context. If the context input object or the chain cannot be resolved (no path can be found through all the operation in the chain) thenInvalidChainExceptionis thrown.- Throws:
OperationException
-
run
Same as previous but for managed chains identified by an ID. For managed chains always use this method since the compiled chain is cached and run will be faster- Throws:
OperationException
-
run
Shortcut to execute a single operation described by the given ID and map of parameters- Throws:
OperationException
-
putTypeAdapter
Registers a new type adapter that can adapt an instance of the accepted type into one of the produced type. -
removeTypeAdapter
Removes a type adapter -
getTypeAdapter
Gets a type adapter for the input type accept and the output type produce. Returns null if no adapter was registered for these types. -
getAdaptedValue
<T> T getAdaptedValue(OperationContext ctx, Object toAdapt, Class<?> targetType) throws OperationException Adapts an object to a target type if possible otherwise throws an exception. The method must be called in an operation execution with a valid operation context.- Throws:
OperationException
-
isTypeAdaptable
Checks whether or not the given type is adaptable into the target type. An instance of an adaptable type can be converted into an instance of the target type.This is a shortcut to
getTypeAdapter(typeToAdapt, targetType) != null -
getDocumentation
Generates a documentation model for all registered operations. The documentation model is generated from operation annotations and can be used in UI tools to describe operations. The returned list is sorted using operation ID. Optional method.- Throws:
OperationException
-
hasOperation
- Parameters:
id- operation ID- Returns:
- true if operation registry contains the given operation
- Since:
- 5.7.2
-
putChainException
- Since:
- 5.7.3
-
removeExceptionChain
- Since:
- 5.7.3
-
getChainExceptions
ChainException[] getChainExceptions()- Since:
- 5.7.3
-
getChainException
- Since:
- 5.7.3
-
putAutomationFilter
- Since:
- 5.7.3
-
removeAutomationFilter
- Since:
- 5.7.3
-
getAutomationFilter
- Since:
- 5.7.3
-
getAutomationFilters
AutomationFilter[] getAutomationFilters()- Since:
- 5.7.3
-
hasChainException
- Since:
- 5.7.3
-
putOperation
void putOperation(Class<?> type, boolean replace, String contributingComponent, List<WidgetDefinition> widgetDefinitionList) throws OperationException - Throws:
OperationException- Since:
- 5.9.5
-
runInNewTx
Object runInNewTx(OperationContext ctx, String chainId, Map<String, ?> chainParameters, Integer timeout, boolean rollbackGlobalOnError) throws OperationExceptionThis running method execute operation process through a new transaction.- Parameters:
ctx- the operation context.chainId- the chain Id.chainParameters- chain parameters.timeout- Transaction timeout.rollbackGlobalOnError- Rollback or not transaction after failing.- Throws:
OperationException- Since:
- 6.0
-