Class OperationServiceImpl
java.lang.Object
org.nuxeo.ecm.automation.core.impl.OperationServiceImpl
- All Implemented Interfaces:
AutomationAdmin,AutomationService
The operation registry is thread safe and optimized for modifications at startup and lookups at runtime.
- Author:
- Bogdan Stefanescu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AdapterKeyedRegistryprotected final Map<String, ChainException> protected final OperationChainCompilerstatic final Stringprotected final Map<String, ChainExceptionFilter> protected final Map<String, OperationType> -
Constructor Summary
ConstructorsConstructorDescriptionOperationServiceImpl(Map<String, OperationType> operations, Map<String, ChainException> chainExceptions, Map<String, ChainExceptionFilter> filters, Map<TypeAdapterKey, ? extends TypeAdapter> adapters) -
Method Summary
Modifier and TypeMethodDescriptioncompileChain(Class<?> inputType, OperationChain chain) Builds the operation chain given a context.compileChain(Class<?> inputType, OperationParameters... ops) Same as previous but takes an array of operation parametersvoidFlush compiled chains to handle hot-reload<T> TgetAdaptedValue(OperationContext ctx, Object toAdapt, Class<?> targetType) Adapts an object to a target type if possible otherwise throws an exception.protected CatchChainExceptiongetCatchChainExceptionByPriority(CatchChainException catchChainException, CatchChainException catchChainExceptionItem) getChainException(String onChainId) protected StringgetChainExceptionToRun(OperationContext ctx, String operationTypeId, OperationException oe) Generates a documentation model for all registered operations.getOperation(String id) Gets an operation type given its ID.protected OperationChainGets 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.static Class<?> getTypeForPrimitive(Class<?> primitiveType) booleanhasChainException(String onChainId) booleanhasOperation(String id) booleanisTypeAdaptable(Class<?> typeToAdapt, Class<?> targetType) Checks whether or not the given type is adaptable into the target type.run(OperationContext ctx, String operationId) Same as previous but for managed chains identified by an ID.run(OperationContext ctx, String operationId, Map<String, ?> args) 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.static OperationParameters[]
-
Field Details
-
EXPORT_ALIASES_CONFIGURATION_PARAM
- See Also:
-
operations
-
chainExceptions
-
filters
-
adapters
-
compiler
-
-
Constructor Details
-
OperationServiceImpl
public OperationServiceImpl(Map<String, OperationType> operations, Map<String, ChainException> chainExceptions, Map<String, ChainExceptionFilter> filters, Map<TypeAdapterKey, ? extends TypeAdapter> adapters)
-
-
Method Details
-
run
Description copied from interface:AutomationServiceSame 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- Specified by:
runin interfaceAutomationService- Throws:
OperationException
-
run
public Object run(OperationContext ctx, String operationId, Map<String, ?> args) throws OperationExceptionDescription copied from interface:AutomationServiceShortcut to execute a single operation described by the given ID and map of parameters- Specified by:
runin interfaceAutomationService- Throws:
OperationException
-
run
Description copied from interface:AutomationServiceBuilds 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.- Specified by:
runin interfaceAutomationService- Throws:
OperationException
-
runInNewTx
public Object runInNewTx(OperationContext ctx, String chainId, Map<String, ?> chainParameters, Integer timeout, boolean rollbackGlobalOnError) throws OperationExceptionDescription copied from interface:AutomationServiceThis running method execute operation process through a new transaction.- Specified by:
runInNewTxin interfaceAutomationService- Parameters:
ctx- the operation context.chainId- the chain Id.chainParameters- chain parameters.timeout- Transaction timeout.rollbackGlobalOnError- Rollback or not transaction after failing.- Throws:
OperationException
-
getChainExceptionToRun
protected String getChainExceptionToRun(OperationContext ctx, String operationTypeId, OperationException oe) throws OperationException - Throws:
OperationException- Since:
- 5.7.3 Fetch the right chain id to run when catching exception for given chain failure.
-
getCatchChainExceptionByPriority
protected CatchChainException getCatchChainExceptionByPriority(CatchChainException catchChainException, CatchChainException catchChainExceptionItem) - Since:
- 5.7.3
-
toParams
-
getOperationChain
- Throws:
OperationNotFoundException
-
flushCompiledChains
public void flushCompiledChains()Description copied from interface:AutomationAdminFlush compiled chains to handle hot-reload- Specified by:
flushCompiledChainsin interfaceAutomationAdmin
-
getOperations
Description copied from interface:AutomationServiceGets all operation types that was registered.- Specified by:
getOperationsin interfaceAutomationService
-
getOperation
Description copied from interface:AutomationServiceGets an operation type given its ID. Throws an exception if the operation is not found.- Specified by:
getOperationin interfaceAutomationService- Throws:
OperationNotFoundException
-
hasOperation
- Specified by:
hasOperationin interfaceAutomationService- Parameters:
id- operation ID.- Returns:
- true if operation registry contains the given operation.
- Since:
- 5.7.2
-
compileChain
public CompiledChain compileChain(Class<?> inputType, OperationParameters... ops) throws OperationException Description copied from interface:AutomationServiceSame as previous but takes an array of operation parameters- Specified by:
compileChainin interfaceAutomationService- Throws:
OperationException
-
compileChain
public CompiledChain compileChain(Class<?> inputType, OperationChain chain) throws OperationException Description copied from interface:AutomationServiceBuilds 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.- Specified by:
compileChainin interfaceAutomationService- Throws:
OperationException
-
getTypeAdapter
Description copied from interface:AutomationServiceGets a type adapter for the input type accept and the output type produce. Returns null if no adapter was registered for these types.- Specified by:
getTypeAdapterin interfaceAutomationService
-
isTypeAdaptable
Description copied from interface:AutomationServiceChecks 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- Specified by:
isTypeAdaptablein interfaceAutomationService
-
getAdaptedValue
public <T> T getAdaptedValue(OperationContext ctx, Object toAdapt, Class<?> targetType) throws OperationException Description copied from interface:AutomationServiceAdapts 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.- Specified by:
getAdaptedValuein interfaceAutomationService- Throws:
OperationException
-
getDocumentation
Description copied from interface:AutomationServiceGenerates 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.- Specified by:
getDocumentationin interfaceAutomationService- Throws:
OperationException
-
getTypeForPrimitive
-
getChainExceptions
- Specified by:
getChainExceptionsin interfaceAutomationService- Since:
- 5.7.3
-
getChainException
- Specified by:
getChainExceptionin interfaceAutomationService- Since:
- 5.7.3
-
hasChainException
- Specified by:
hasChainExceptionin interfaceAutomationService- Since:
- 5.7.3
-
getAutomationFilter
- Specified by:
getAutomationFilterin interfaceAutomationService- Since:
- 5.7.3
-
getAutomationFilters
- Specified by:
getAutomationFiltersin interfaceAutomationService- Since:
- 5.7.3
-