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 theBatchManager
service with theTransientStore
.- Since:
- 5.4.2
-
-
Field Summary
Fields Modifier and Type Field Description static String
CLIENT_BATCH_ID_FLAG
static String
DEFAULT_BATCH_HANDLER
The default batch handler name.protected Map<String,BatchHandler>
handlers
protected AtomicInteger
uploadInProgress
static String
XP_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 void
addBlob(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.void
addBlob(String batchId, String index, Blob blob, String name, String mime)
Adds a blob to a batch.void
addStream(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.void
addStream(String batchId, String index, InputStream is, String name, String mime)
Adds an inputStream as a blob to a batch.void
clean(String batchId)
Cleans up the temporary storage associated to the batch.protected Object
execute(Object blobInput, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
Object
execute(String batchId, String fileIndex, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
Executes the chain or operation on theBlob
from the givenbatchId
andfileIndex
.Object
execute(String batchId, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
Executes the chain or operation on theBlobs
from the givenbatchId
.Object
executeAndClean(String batchId, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
Executes the chain or operation on theBlobs
from the givenbatchId
.Batch
getBatch(String batchId)
Fetches information about a batch.protected Blob
getBatchBlob(String batchId, String fileIndex)
Blob
getBlob(String batchId, String fileIndex)
Blob
getBlob(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)
BatchFileEntry
getFileEntry(String batchId, String fileIndex)
BatchHandler
getHandler(String handlerName)
Gets a batch handler.Set<String>
getSupportedHandlers()
Returns the supported batch handler names.TransientStore
getTransientStore()
Deprecated.protected int
getUploadWaitTimeout()
boolean
hasBatch(String batchId)
Returns true if there is a batch for the givenbatchId
, false otherwise.String
initBatch()
Initializes a batch by with an automatically generated id.Batch
initBatch(String handlerName)
Initiates a new batch with the given handler.String
initBatch(String batchId, String contextName)
Deprecated.protected Batch
initBatchInternal(String batchId)
boolean
removeFileEntry(String batchId, String filedIdx)
Removes a file from a batch.void
start(ComponentContext context)
Start the component.void
stop(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:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
stop
public void stop(ComponentContext context) throws InterruptedException
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
- Throws:
InterruptedException
-
getTransientStore
@Deprecated public TransientStore getTransientStore()
Deprecated.Description copied from interface:BatchManager
Returns theTransientStore
backing the batches of the default handler.- Specified by:
getTransientStore
in interfaceBatchManager
-
getSupportedHandlers
public Set<String> getSupportedHandlers()
Description copied from interface:BatchManager
Returns the supported batch handler names.- Specified by:
getSupportedHandlers
in interfaceBatchManager
- Returns:
- the supported batch handler names
-
getHandler
public BatchHandler getHandler(String handlerName)
Description copied from interface:BatchManager
Gets a batch handler.- Specified by:
getHandler
in interfaceBatchManager
- Parameters:
handlerName
- the batch handler name- Returns:
- the batch handler, or
null
if it doesn't exist
-
initBatch
public String initBatch()
Description copied from interface:BatchManager
Initializes a batch by with an automatically generated id.- Specified by:
initBatch
in interfaceBatchManager
- Returns:
- the batch id
-
initBatch
@Deprecated public String initBatch(String batchId, String contextName)
Deprecated.Description copied from interface:BatchManager
Initializes a batch with a given batchId and Context Name. If batchId is not provided, it will be automatically generated.- Specified by:
initBatch
in interfaceBatchManager
- Returns:
- the batchId
-
initBatch
public Batch initBatch(String handlerName)
Description copied from interface:BatchManager
Initiates a new batch with the given handler.- Specified by:
initBatch
in interfaceBatchManager
- Parameters:
handlerName
- the batch handler name- Returns:
- the newly created batch
-
getBatch
public Batch getBatch(String batchId)
Description copied from interface:BatchManager
Fetches information about a batch.- Specified by:
getBatch
in interfaceBatchManager
- Parameters:
batchId
- the batch id- Returns:
- the batch, or
null
if it doesn't exist
-
addStream
public void addStream(String batchId, String index, InputStream is, String name, String mime) throws IOException
Description copied from interface:BatchManager
Adds an inputStream as a blob to a batch. Will create a newBatch
if needed.Streams are persisted as temporary files.
- Specified by:
addStream
in interfaceBatchManager
- Throws:
IOException
-
addBlob
public void addBlob(String batchId, String index, Blob blob, String name, String mime) throws IOException
Description copied from interface:BatchManager
Adds a blob to a batch. Will create a newBatch
if needed.- Specified by:
addBlob
in 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:BatchManager
Adds an inputStream as a chunk to a batch. Will create a newBatch
if needed.Streams are persisted as temporary files.
- Specified by:
addStream
in 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:BatchManager
Adds a blob as a chunk to a batch. Will create a newBatch
if needed.- Specified by:
addBlob
in interfaceBatchManager
- Throws:
IOException
-
hasBatch
public boolean hasBatch(String batchId)
Description copied from interface:BatchManager
Returns true if there is a batch for the givenbatchId
, false otherwise.- Specified by:
hasBatch
in interfaceBatchManager
-
getBlobs
public List<Blob> getBlobs(String batchId)
Description copied from interface:BatchManager
Gets Blobs associated to a given batch. Returns null if batch does not exist.- Specified by:
getBlobs
in interfaceBatchManager
-
getBlobs
public List<Blob> getBlobs(String batchId, int timeoutS)
Description copied from interface:BatchManager
Gets Blobs associated to a given batch. Returns null if batch does not exist. Waits for upload in progress if needed.- Specified by:
getBlobs
in interfaceBatchManager
-
getBlob
public Blob getBlob(String batchId, String fileIndex)
- Specified by:
getBlob
in interfaceBatchManager
-
getBlob
public Blob getBlob(String batchId, String fileIndex, int timeoutS)
- Specified by:
getBlob
in interfaceBatchManager
-
getFileEntries
public List<BatchFileEntry> getFileEntries(String batchId)
- Specified by:
getFileEntries
in interfaceBatchManager
-
getFileEntry
public BatchFileEntry getFileEntry(String batchId, String fileIndex)
- Specified by:
getFileEntry
in interfaceBatchManager
-
clean
public void clean(String batchId)
Description copied from interface:BatchManager
Cleans up the temporary storage associated to the batch.- Specified by:
clean
in interfaceBatchManager
-
execute
public Object execute(String batchId, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
Description copied from interface:BatchManager
Executes the chain or operation on theBlobs
from the givenbatchId
.This method does not clean the temporary storage associated to the
batchId
.- Specified by:
execute
in 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:BatchManager
Executes the chain or operation on theBlob
from the givenbatchId
andfileIndex
.This method does not clean the temporary storage associated to the
batchId
.- Specified by:
execute
in 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:BatchManager
Executes the chain or operation on theBlobs
from the givenbatchId
.This method cleans the temporary storage associated to the
batchId
after the execution.- Specified by:
executeAndClean
in interfaceBatchManager
-
removeFileEntry
public boolean removeFileEntry(String batchId, String filedIdx)
Description copied from interface:BatchManager
Removes a file from a batch.- Specified by:
removeFileEntry
in interfaceBatchManager
-
-