use of org.apache.sling.distribution.DistributionRequestState in project sling by apache.
the class QueueingDistributionPackageProcessor method scheduleImportPackage.
private Collection<SimpleDistributionResponse> scheduleImportPackage(DistributionPackage distributionPackage, String callingUser, String requestId, long startTime) {
Collection<SimpleDistributionResponse> distributionResponses = new LinkedList<SimpleDistributionResponse>();
// dispatch the distribution package to one or more queues
try {
// add metadata to the package
distributionPackage.getInfo().put(DistributionPackageUtils.PACKAGE_INFO_PROPERTY_REQUEST_USER, callingUser);
distributionPackage.getInfo().put(DistributionPackageUtils.PACKAGE_INFO_PROPERTY_REQUEST_ID, requestId);
distributionPackage.getInfo().put(DistributionPackageUtils.PACKAGE_INFO_PROPERTY_REQUEST_START_TIME, startTime);
// put the package in the queue
Iterable<DistributionQueueItemStatus> states = scheduleQueueStrategy.add(distributionPackage, queueProvider);
for (DistributionQueueItemStatus state : states) {
DistributionRequestState requestState = getRequestStateFromQueueState(state.getItemState());
distributionResponses.add(new SimpleDistributionResponse(requestState, state.getItemState().toString()));
}
distributionEventFactory.generatePackageEvent(DistributionEventTopics.AGENT_PACKAGE_QUEUED, DistributionComponentKind.AGENT, agentName, distributionPackage.getInfo());
} catch (DistributionException e) {
log.error("an error happened during dispatching items to the queue(s)", e);
distributionResponses.add(new SimpleDistributionResponse(DistributionRequestState.DROPPED, e.toString()));
}
return distributionResponses;
}
Aggregations