Class BatchManagerComponent
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.ecm.automation.server.jaxrs.batch.BatchManagerComponent
-
- All Implemented Interfaces:
BatchManager,Adaptable,Component,Extensible,TimestampedService
public class BatchManagerComponent extends DefaultComponent implements BatchManager
Runtime Component implementing theBatchManagerservice with theTransientStore.- Since:
- 5.4.2
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLIENT_BATCH_ID_FLAGstatic StringDEFAULT_BATCH_HANDLERThe default batch handler name.protected Map<String,BatchHandler>handlersprotected AtomicIntegeruploadInProgressstatic StringXP_BATCH_HANDLER-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description BatchManagerComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddBlob(String batchId, String index, Blob blob, int chunkCount, int chunkIndex, String name, String mime, long fileSize)Adds a blob as a chunk to a batch.voidaddBlob(String batchId, String index, Blob blob, String name, String mime)Adds a blob to a batch.voidaddStream(String batchId, String index, InputStream is, int chunkCount, int chunkIndex, String name, String mime, long fileSize)Adds an inputStream as a chunk to a batch.voidaddStream(String batchId, String index, InputStream is, String name, String mime)Adds an inputStream as a blob to a batch.voidclean(String batchId)Cleans up the temporary storage associated to the batch.protected Objectexecute(Object blobInput, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)Objectexecute(String batchId, String fileIndex, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)Executes the chain or operation on theBlobfrom the givenbatchIdandfileIndex.Objectexecute(String batchId, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)Executes the chain or operation on theBlobsfrom the givenbatchId.ObjectexecuteAndClean(String batchId, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)Executes the chain or operation on theBlobsfrom the givenbatchId.BatchgetBatch(String batchId)Fetches information about a batch.protected BlobgetBatchBlob(String batchId, String fileIndex)BlobgetBlob(String batchId, String fileIndex)BlobgetBlob(String batchId, String fileIndex, int timeoutS)List<Blob>getBlobs(String batchId)Gets Blobs associated to a given batch.List<Blob>getBlobs(String batchId, int timeoutS)Gets Blobs associated to a given batch.List<BatchFileEntry>getFileEntries(String batchId)BatchFileEntrygetFileEntry(String batchId, String fileIndex)BatchHandlergetHandler(String handlerName)Gets a batch handler.Set<String>getSupportedHandlers()Returns the supported batch handler names.TransientStoregetTransientStore()Deprecated.protected intgetUploadWaitTimeout()booleanhasBatch(String batchId)Returns true if there is a batch for the givenbatchId, false otherwise.StringinitBatch()Initializes a batch by with an automatically generated id.BatchinitBatch(String handlerName)Initiates a new batch with the given handler.StringinitBatch(String batchId, String contextName)Deprecated.protected BatchinitBatchInternal(String batchId)booleanremoveFileEntry(String batchId, String filedIdx)Removes a file from a batch.voidstart(ComponentContext context)Start the component.voidstop(ComponentContext context)Stop the component.-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterContribution, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
CLIENT_BATCH_ID_FLAG
public static final String CLIENT_BATCH_ID_FLAG
- See Also:
- Constant Field Values
-
DEFAULT_BATCH_HANDLER
public static final String DEFAULT_BATCH_HANDLER
The default batch handler name.- Since:
- 10.1
- See Also:
- Constant Field Values
-
XP_BATCH_HANDLER
public static final String XP_BATCH_HANDLER
- Since:
- 10.1
- See Also:
- Constant Field Values
-
handlers
protected Map<String,BatchHandler> handlers
-
uploadInProgress
protected final AtomicInteger uploadInProgress
-
-
Method Detail
-
start
public void start(ComponentContext context)
Description copied from interface:ComponentStart the component. This method is called after all the components were resolved and activated- Specified by:
startin interfaceComponent- Overrides:
startin classDefaultComponent
-
stop
public void stop(ComponentContext context) throws InterruptedException
Description copied from interface:ComponentStop the component.- Specified by:
stopin interfaceComponent- Overrides:
stopin classDefaultComponent- Throws:
InterruptedException
-
getTransientStore
@Deprecated public TransientStore getTransientStore()
Deprecated.Description copied from interface:BatchManagerReturns theTransientStorebacking the batches of the default handler.- Specified by:
getTransientStorein interfaceBatchManager
-
getSupportedHandlers
public Set<String> getSupportedHandlers()
Description copied from interface:BatchManagerReturns the supported batch handler names.- Specified by:
getSupportedHandlersin interfaceBatchManager- Returns:
- the supported batch handler names
-
getHandler
public BatchHandler getHandler(String handlerName)
Description copied from interface:BatchManagerGets a batch handler.- Specified by:
getHandlerin interfaceBatchManager- Parameters:
handlerName- the batch handler name- Returns:
- the batch handler, or
nullif it doesn't exist
-
initBatch
public String initBatch()
Description copied from interface:BatchManagerInitializes a batch by with an automatically generated id.- Specified by:
initBatchin interfaceBatchManager- Returns:
- the batch id
-
initBatch
@Deprecated public String initBatch(String batchId, String contextName)
Deprecated.Description copied from interface:BatchManagerInitializes a batch with a given batchId and Context Name. If batchId is not provided, it will be automatically generated.- Specified by:
initBatchin interfaceBatchManager- Returns:
- the batchId
-
initBatch
public Batch initBatch(String handlerName)
Description copied from interface:BatchManagerInitiates a new batch with the given handler.- Specified by:
initBatchin interfaceBatchManager- Parameters:
handlerName- the batch handler name- Returns:
- the newly created batch
-
getBatch
public Batch getBatch(String batchId)
Description copied from interface:BatchManagerFetches information about a batch.- Specified by:
getBatchin interfaceBatchManager- Parameters:
batchId- the batch id- Returns:
- the batch, or
nullif it doesn't exist
-
addStream
public void addStream(String batchId, String index, InputStream is, String name, String mime) throws IOException
Description copied from interface:BatchManagerAdds an inputStream as a blob to a batch. Will create a newBatchif needed.Streams are persisted as temporary files.
- Specified by:
addStreamin interfaceBatchManager- Throws:
IOException
-
addBlob
public void addBlob(String batchId, String index, Blob blob, String name, String mime) throws IOException
Description copied from interface:BatchManagerAdds a blob to a batch. Will create a newBatchif needed.- Specified by:
addBlobin interfaceBatchManager- Throws:
IOException
-
addStream
public void addStream(String batchId, String index, InputStream is, int chunkCount, int chunkIndex, String name, String mime, long fileSize) throws IOException
Description copied from interface:BatchManagerAdds an inputStream as a chunk to a batch. Will create a newBatchif needed.Streams are persisted as temporary files.
- Specified by:
addStreamin interfaceBatchManager- Throws:
IOException
-
addBlob
public void addBlob(String batchId, String index, Blob blob, int chunkCount, int chunkIndex, String name, String mime, long fileSize) throws IOException
Description copied from interface:BatchManagerAdds a blob as a chunk to a batch. Will create a newBatchif needed.- Specified by:
addBlobin interfaceBatchManager- Throws:
IOException
-
hasBatch
public boolean hasBatch(String batchId)
Description copied from interface:BatchManagerReturns true if there is a batch for the givenbatchId, false otherwise.- Specified by:
hasBatchin interfaceBatchManager
-
getBlobs
public List<Blob> getBlobs(String batchId)
Description copied from interface:BatchManagerGets Blobs associated to a given batch. Returns null if batch does not exist.- Specified by:
getBlobsin interfaceBatchManager
-
getBlobs
public List<Blob> getBlobs(String batchId, int timeoutS)
Description copied from interface:BatchManagerGets Blobs associated to a given batch. Returns null if batch does not exist. Waits for upload in progress if needed.- Specified by:
getBlobsin interfaceBatchManager
-
getBlob
public Blob getBlob(String batchId, String fileIndex)
- Specified by:
getBlobin interfaceBatchManager
-
getBlob
public Blob getBlob(String batchId, String fileIndex, int timeoutS)
- Specified by:
getBlobin interfaceBatchManager
-
getFileEntries
public List<BatchFileEntry> getFileEntries(String batchId)
- Specified by:
getFileEntriesin interfaceBatchManager
-
getFileEntry
public BatchFileEntry getFileEntry(String batchId, String fileIndex)
- Specified by:
getFileEntryin interfaceBatchManager
-
clean
public void clean(String batchId)
Description copied from interface:BatchManagerCleans up the temporary storage associated to the batch.- Specified by:
cleanin interfaceBatchManager
-
execute
public Object execute(String batchId, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
Description copied from interface:BatchManagerExecutes the chain or operation on theBlobsfrom the givenbatchId.This method does not clean the temporary storage associated to the
batchId.- Specified by:
executein interfaceBatchManager
-
execute
public Object execute(String batchId, String fileIndex, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
Description copied from interface:BatchManagerExecutes the chain or operation on theBlobfrom the givenbatchIdandfileIndex.This method does not clean the temporary storage associated to the
batchId.- Specified by:
executein interfaceBatchManager
-
execute
protected Object execute(Object blobInput, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
-
getUploadWaitTimeout
protected int getUploadWaitTimeout()
-
executeAndClean
public Object executeAndClean(String batchId, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
Description copied from interface:BatchManagerExecutes the chain or operation on theBlobsfrom the givenbatchId.This method cleans the temporary storage associated to the
batchIdafter the execution.- Specified by:
executeAndCleanin interfaceBatchManager
-
removeFileEntry
public boolean removeFileEntry(String batchId, String filedIdx)
Description copied from interface:BatchManagerRemoves a file from a batch.- Specified by:
removeFileEntryin interfaceBatchManager
-
-