use of com.infiniteautomation.mango.rest.latest.model.modules.UpgradeStatusModel in project ma-modules-public by infiniteautomation.
the class ModulesRestController method getUpgradeStatus.
@ApiOperation(value = "Get Current Upgrade Task Status", notes = "")
@RequestMapping(method = RequestMethod.GET, value = "/upgrade-status")
public UpgradeStatusModel getUpgradeStatus(@AuthenticationPrincipal PermissionHolder user) {
permissionService.ensureAdminRole(user);
UpgradeStatus status = service.monitorDownloads();
UpgradeStatusModel model = new UpgradeStatusModel();
if (status.getStage() == UpgradeState.IDLE) {
// Not running
model.setRunning(false);
} else {
List<ModuleModel> modules = new ArrayList<ModuleModel>();
List<StringStringPair> results = status.getResults();
for (StringStringPair r : results) modules.add(new ModuleModel(r.getKey(), r.getValue()));
model.setResults(modules);
model.setFinished(status.isFinished());
model.setCancelled(status.isCancelled());
model.setWillRestart(status.isRestart());
model.setError(status.getError());
model.setStage(status.getStage().name());
}
return model;
}
Aggregations