Search in sources :

Example 1 with DistributionQueueItemState

use of org.apache.sling.distribution.queue.DistributionQueueItemState in project sling by apache.

the class SimpleDistributionQueue method add.

public DistributionQueueEntry add(@Nonnull DistributionQueueItem item) {
    DistributionQueueItemState itemState = DistributionQueueItemState.ERROR;
    boolean result = false;
    try {
        result = queue.offer(item);
        itemState = DistributionQueueItemState.QUEUED;
    } catch (Exception e) {
        log.error("cannot add an item to the queue", e);
    } finally {
        statusMap.put(item, new DistributionQueueItemStatus(Calendar.getInstance(), itemState, 0, name));
    }
    if (result) {
        return new DistributionQueueEntry(item.getPackageId(), item, statusMap.get(item));
    }
    return null;
}
Also used : DistributionQueueItemStatus(org.apache.sling.distribution.queue.DistributionQueueItemStatus) DistributionQueueEntry(org.apache.sling.distribution.queue.DistributionQueueEntry) DistributionQueueItemState(org.apache.sling.distribution.queue.DistributionQueueItemState)

Aggregations

DistributionQueueEntry (org.apache.sling.distribution.queue.DistributionQueueEntry)1 DistributionQueueItemState (org.apache.sling.distribution.queue.DistributionQueueItemState)1 DistributionQueueItemStatus (org.apache.sling.distribution.queue.DistributionQueueItemStatus)1