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
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description CompiledChain
compileChain(Class<?> inputType, OperationChain chain)
Builds the operation chain given a context.CompiledChain
compileChain(Class<?> inputType, OperationParameters... chain)
Same as previous but takes an array of operation parameters<T> T
getAdaptedValue(OperationContext ctx, Object toAdapt, Class<?> targetType)
Adapts an object to a target type if possible otherwise throws an exception.AutomationFilter
getAutomationFilter(String id)
AutomationFilter[]
getAutomationFilters()
ChainException
getChainException(String onChainId)
ChainException[]
getChainExceptions()
List<OperationDocumentation>
getDocumentation()
Generates a documentation model for all registered operations.OperationType
getOperation(String id)
Gets an operation type given its ID.OperationChain
getOperationChain(String id)
Deprecated.since 5.9.2 no specific chain registry anymore: chains are now operations, usegetOperation(String)
method instead.List<OperationChain>
getOperationChains()
Deprecated.since 5.9.2 no specific chain registry anymore: chains are now operations, usegetOperations()
method instead.OperationType[]
getOperations()
Gets all operation types that was registered.TypeAdapter
getTypeAdapter(Class<?> accept, Class<?> produce)
Gets a type adapter for the input type accept and the output type produce.boolean
hasChainException(String onChainId)
boolean
hasOperation(String id)
boolean
isTypeAdaptable(Class<?> typeToAdapt, Class<?> targetType)
Checks whether or not the given type is adaptable into the target type.void
putAutomationFilter(AutomationFilter automationFilter)
void
putChainException(ChainException exceptionChain)
void
putOperation(Class<?> type)
Registers an operation given its class.void
putOperation(Class<?> type, boolean replace)
Registers an operation given its class.void
putOperation(Class<?> type, boolean replace, String contributingComponent)
Registers an operation given its class.void
putOperation(Class<?> type, boolean replace, String contributingComponent, List<WidgetDefinition> widgetDefinitionList)
void
putOperation(OperationType op, boolean replace)
Registers an operation given it's type.void
putOperationChain(OperationChain chain)
Deprecated.since 5.9.2 no specific chain registry anymore: chains are now operations, useputOperation(OperationType, boolean)
method instead.void
putOperationChain(OperationChain chain, boolean replace)
Deprecated.since 5.9.2 no specific chain registry anymore: chains are now operations, useputOperation(OperationType, boolean)
method instead.void
putTypeAdapter(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.void
removeAutomationFilter(AutomationFilter automationFilter)
void
removeExceptionChain(ChainException exceptionChain)
void
removeOperation(Class<?> key)
Removes an operation given its class.void
removeOperation(OperationType type)
Removes an operation given it's type.void
removeOperationChain(String id)
Deprecated.since 5.9.2 no specific chain registry anymore: chains are now operations, useremoveOperation(OperationType)
method instead.void
removeTypeAdapter(Class<?> accept, Class<?> produce)
Removes a type adapterObject
run(OperationContext ctx, String chainId)
Same as previous but for managed chains identified by an ID.Object
run(OperationContext ctx, String id, Map<String,?> params)
Shortcut to execute a single operation described by the given ID and map of parametersObject
run(OperationContext ctx, OperationChain chain)
Builds and runs the operation chain given a context.Object
runInNewTx(OperationContext ctx, String chainId, Map<String,?> chainParameters, Integer timeout, boolean rollbackGlobalOnError)
This running method execute operation process through a new transaction.
-
-
-
Method Detail
-
putOperation
void putOperation(Class<?> type) throws OperationException
Registers an operation given its class. The operation class MUST be annotated usingOperation
annotation. If an operation having the same ID exists an exception will be thrown.- Throws:
OperationException
-
putOperation
void putOperation(Class<?> type, boolean replace) throws OperationException
Registers an operation given its class. The operation class MUST be annotated usingOperation
annotation. If thereplace
argument 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 usingOperation
annotation. If thereplace
argument 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
void putOperation(OperationType op, boolean replace) throws OperationException
Registers an operation given it's type.- Throws:
OperationException
- Since:
- 5.9.2
-
removeOperation
void removeOperation(Class<?> key)
Removes an operation given its class. If the operation was not registered does nothing.
-
removeOperation
void removeOperation(OperationType type)
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
OperationType getOperation(String id) throws OperationNotFoundException
Gets an operation type given its ID. Throws an exception if the operation is not found.- Throws:
OperationNotFoundException
-
compileChain
CompiledChain compileChain(Class<?> inputType, OperationChain chain) throws OperationException
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) thenInvalidChainException
is 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
Object run(OperationContext ctx, OperationChain chain) throws OperationException
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) thenInvalidChainException
is thrown.- Throws:
OperationException
-
run
Object run(OperationContext ctx, String chainId) throws OperationException
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
Object run(OperationContext ctx, String id, Map<String,?> params) throws OperationException
Shortcut to execute a single operation described by the given ID and map of parameters- Throws:
OperationException
-
putOperationChain
@Deprecated void putOperationChain(OperationChain chain) throws OperationException
Deprecated.since 5.9.2 no specific chain registry anymore: chains are now operations, useputOperation(OperationType, boolean)
method instead.Registers a parametrized operation chain. This chain can be executed later by callingrun
and passing the chain ID. If a chain having the same ID exists an exception is thrown- Throws:
OperationException
- Since:
- 5.7.2
-
putOperationChain
@Deprecated void putOperationChain(OperationChain chain, boolean replace) throws OperationException
Deprecated.since 5.9.2 no specific chain registry anymore: chains are now operations, useputOperation(OperationType, boolean)
method instead.Registers a parametrized operation chain. This chain can be executed later by callingrun
and passing the chain ID. If the replace attribute is true then any chain already registered under the same id will be replaced otherwise an exception is thrown.- Throws:
OperationException
- Since:
- 5.7.2
-
removeOperationChain
@Deprecated void removeOperationChain(String id)
Deprecated.since 5.9.2 no specific chain registry anymore: chains are now operations, useremoveOperation(OperationType)
method instead.Removes a registered operation chain given its ID. Do nothing if the chain was not registered.- Since:
- 5.7.2
-
getOperationChain
@Deprecated OperationChain getOperationChain(String id) throws OperationNotFoundException
Deprecated.since 5.9.2 no specific chain registry anymore: chains are now operations, usegetOperation(String)
method instead.Gets a registered operation chain.- Throws:
OperationNotFoundException
- Since:
- 5.7.2
-
getOperationChains
@Deprecated List<OperationChain> getOperationChains()
Deprecated.since 5.9.2 no specific chain registry anymore: chains are now operations, usegetOperations()
method instead.Gets a list of all registered chains- Returns:
- the list or an empty list if no registered chains exists
- Since:
- 5.7.2
-
putTypeAdapter
void putTypeAdapter(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.
-
getTypeAdapter
TypeAdapter getTypeAdapter(Class<?> accept, Class<?> produce)
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
boolean isTypeAdaptable(Class<?> typeToAdapt, Class<?> targetType)
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
List<OperationDocumentation> getDocumentation() throws OperationException
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
boolean hasOperation(String id)
- Parameters:
id
- operation ID- Returns:
- true if operation registry contains the given operation
- Since:
- 5.7.2
-
putChainException
void putChainException(ChainException exceptionChain)
- Since:
- 5.7.3
-
removeExceptionChain
void removeExceptionChain(ChainException exceptionChain)
- Since:
- 5.7.3
-
getChainExceptions
ChainException[] getChainExceptions()
- Since:
- 5.7.3
-
getChainException
ChainException getChainException(String onChainId)
- Since:
- 5.7.3
-
putAutomationFilter
void putAutomationFilter(AutomationFilter automationFilter)
- Since:
- 5.7.3
-
removeAutomationFilter
void removeAutomationFilter(AutomationFilter automationFilter)
- Since:
- 5.7.3
-
getAutomationFilter
AutomationFilter getAutomationFilter(String id)
- Since:
- 5.7.3
-
getAutomationFilters
AutomationFilter[] getAutomationFilters()
- Since:
- 5.7.3
-
hasChainException
boolean hasChainException(String onChainId)
- 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 OperationException
This 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
-
-