use of org.structr.core.scheduler.JobQueueManager in project structr by structr.
the class FileImportCommand method processMessage.
// ~--- methods --------------------------------------------------------
@Override
public void processMessage(WebSocketMessage webSocketData) throws FrameworkException {
// final SecurityContext securityContext = getWebSocket().getSecurityContext();
final Map<String, Object> properties = webSocketData.getNodeData();
// default: list start | pause | resume | cancel | abort
final String mode = (String) properties.get("mode");
final Long jobId = (Long) properties.get("jobId");
final JobQueueManager mgr = JobQueueManager.getInstance();
final List<GraphObject> result = new LinkedList<>();
switch(mode) {
case "start":
mgr.startJob(jobId);
break;
case "pause":
mgr.pauseRunningJob(jobId);
break;
case "resume":
mgr.resumePausedJob(jobId);
break;
case "abort":
mgr.abortActiveJob(jobId);
break;
case "cancel":
mgr.cancelQueuedJob(jobId);
break;
case "list":
default:
final GraphObjectMap importsContainer = new GraphObjectMap();
importsContainer.put(importJobsProperty, mgr.listJobs());
result.add(importsContainer);
}
webSocketData.setResult(result);
webSocketData.setRawResultCount(1);
getWebSocket().send(webSocketData, true);
}
Aggregations