use of org.apache.sling.commons.scheduler.ScheduleOptions in project acs-aem-commons by Adobe-Consulting-Services.
the class ReviewTaskAssetMoverHandler method handleEvent.
@Override
public void handleEvent(Event event) {
ResourceResolver resourceResolver = null;
try {
resourceResolver = resourceResolverFactory.getServiceResourceResolver(AUTH_INFO);
final String path = (String) event.getProperty("TaskId");
final Resource taskResource = resourceResolver.getResource(path);
if (taskResource != null) {
final ValueMap taskProperties = taskResource.getValueMap();
// Perform a fast check to see if this project has the required properties to perform the asset moving
if (StringUtils.startsWith(taskProperties.get(PN_ON_APPROVE, String.class), PATH_CONTENT_DAM) || StringUtils.startsWith(taskProperties.get(PN_ON_REJECT, String.class), PATH_CONTENT_DAM)) {
log.debug("Handling event (creating a Job) for Assets Review Task @ [ {} ]", path);
ScheduleOptions options = scheduler.NOW();
String jobName = this.getClass().getSimpleName().toString().replace(".", "/") + "/" + path;
options.name(jobName);
options.canRunConcurrently(false);
scheduler.schedule(new ImmediateJob(path), options);
}
}
} catch (LoginException e) {
log.error("Could not get resource resolver", e);
} finally {
// Always close resource resolvers you open
if (resourceResolver != null) {
resourceResolver.close();
}
}
}
Aggregations