public class BatchManagerComponent extends DefaultComponent implements BatchManager
BatchManager
service with the TransientStore
.Modifier and Type | Field and Description |
---|---|
static String |
CLIENT_BATCH_ID_FLAG |
static String |
DEFAULT_BATCH_HANDLER
The default batch handler name.
|
static String |
EP_BATCH_HANDLER |
protected Map<String,BatchHandler> |
handlers |
protected static org.apache.commons.logging.Log |
log |
protected static String |
TRANSIENT_STORE_NAME |
protected AtomicInteger |
uploadInProgress |
lastModified
Constructor and Description |
---|
BatchManagerComponent() |
Modifier and Type | Method and Description |
---|---|
void |
activate(ComponentContext context)
Activates the component.
|
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.
|
void |
deactivate(ComponentContext context)
Deactivates the component.
|
protected Object |
execute(Object blobInput,
String chainOrOperationId,
CoreSession session,
Map<String,Object> contextParams,
Map<String,Object> operationParams) |
Object |
execute(String batchId,
String chainOrOperationId,
CoreSession session,
Map<String,Object> contextParams,
Map<String,Object> operationParams)
Executes the chain or operation on the
Blobs from the given batchId . |
Object |
execute(String batchId,
String fileIndex,
String chainOrOperationId,
CoreSession session,
Map<String,Object> contextParams,
Map<String,Object> operationParams)
Executes the chain or operation on the
Blob from the given batchId and fileIndex . |
Object |
executeAndClean(String batchId,
String chainOrOperationId,
CoreSession session,
Map<String,Object> contextParams,
Map<String,Object> operationParams)
Executes the chain or operation on the
Blobs from the given batchId . |
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()
Returns the
TransientStore backing the batches. |
protected int |
getUploadWaitTimeout() |
boolean |
hasBatch(String batchId)
Returns true if there is a batch for the given
batchId , 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) |
void |
registerContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
boolean |
removeFileEntry(String batchId,
String filedIdx)
Removes a file from a batch.
|
void |
unregisterContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
getAdapter, getLastModified, registerExtension, setLastModified, setModifiedNow, start, stop, unregisterExtension
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applicationStarted, getApplicationStartedOrder
protected static final org.apache.commons.logging.Log log
protected static final String TRANSIENT_STORE_NAME
public static final String CLIENT_BATCH_ID_FLAG
public static final String DEFAULT_BATCH_HANDLER
public static final String EP_BATCH_HANDLER
protected Map<String,BatchHandler> handlers
protected final AtomicInteger uploadInProgress
public BatchManagerComponent()
public void activate(ComponentContext context)
Component
This method is called by the runtime when a component is activated.
activate
in interface Component
activate
in class DefaultComponent
context
- the runtime contextpublic void deactivate(ComponentContext context)
Component
This method is called by the runtime when a component is deactivated.
deactivate
in interface Component
deactivate
in class DefaultComponent
context
- the runtime contextpublic void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
registerContribution
in class DefaultComponent
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
unregisterContribution
in class DefaultComponent
public TransientStore getTransientStore()
BatchManager
TransientStore
backing the batches.getTransientStore
in interface BatchManager
public Set<String> getSupportedHandlers()
BatchManager
getSupportedHandlers
in interface BatchManager
public BatchHandler getHandler(String handlerName)
BatchManager
getHandler
in interface BatchManager
handlerName
- the batch handler namenull
if it doesn't existpublic String initBatch()
BatchManager
initBatch
in interface BatchManager
@Deprecated public String initBatch(String batchId, String contextName)
BatchManager
initBatch
in interface BatchManager
protected Batch initBatchInternal(String batchId)
public Batch initBatch(String handlerName)
BatchManager
initBatch
in interface BatchManager
handlerName
- the batch handler namepublic Batch getBatch(String batchId)
BatchManager
getBatch
in interface BatchManager
batchId
- the batch idnull
if it doesn't existpublic void addStream(String batchId, String index, InputStream is, String name, String mime) throws IOException
BatchManager
Batch
if needed.
Streams are persisted as temporary files.
addStream
in interface BatchManager
IOException
public void addBlob(String batchId, String index, Blob blob, String name, String mime) throws IOException
BatchManager
Batch
if needed.addBlob
in interface BatchManager
IOException
public void addStream(String batchId, String index, InputStream is, int chunkCount, int chunkIndex, String name, String mime, long fileSize) throws IOException
BatchManager
Batch
if needed.
Streams are persisted as temporary files.
addStream
in interface BatchManager
IOException
public void addBlob(String batchId, String index, Blob blob, int chunkCount, int chunkIndex, String name, String mime, long fileSize) throws IOException
BatchManager
Batch
if needed.addBlob
in interface BatchManager
IOException
public boolean hasBatch(String batchId)
BatchManager
batchId
, false otherwise.hasBatch
in interface BatchManager
public List<Blob> getBlobs(String batchId)
BatchManager
getBlobs
in interface BatchManager
public List<Blob> getBlobs(String batchId, int timeoutS)
BatchManager
getBlobs
in interface BatchManager
public Blob getBlob(String batchId, String fileIndex)
getBlob
in interface BatchManager
public Blob getBlob(String batchId, String fileIndex, int timeoutS)
getBlob
in interface BatchManager
protected Blob getBatchBlob(String batchId, String fileIndex)
public List<BatchFileEntry> getFileEntries(String batchId)
getFileEntries
in interface BatchManager
public BatchFileEntry getFileEntry(String batchId, String fileIndex)
getFileEntry
in interface BatchManager
public void clean(String batchId)
BatchManager
clean
in interface BatchManager
public Object execute(String batchId, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
BatchManager
Blobs
from the given batchId
.
This method does not clean the temporary storage associated to the batchId
.
execute
in interface BatchManager
public Object execute(String batchId, String fileIndex, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
BatchManager
Blob
from the given batchId
and fileIndex
.
This method does not clean the temporary storage associated to the batchId
.
execute
in interface BatchManager
protected Object execute(Object blobInput, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
protected int getUploadWaitTimeout()
public Object executeAndClean(String batchId, String chainOrOperationId, CoreSession session, Map<String,Object> contextParams, Map<String,Object> operationParams)
BatchManager
Blobs
from the given batchId
.
This method cleans the temporary storage associated to the batchId
after the execution.
executeAndClean
in interface BatchManager
public boolean removeFileEntry(String batchId, String filedIdx)
BatchManager
removeFileEntry
in interface BatchManager
Copyright © 2018 Nuxeo. All rights reserved.