log.info("Start deleting scheduled scan from application with id " + appId);
if (!PermissionUtils.isAuthorized(Permission.CAN_MANAGE_APPLICATIONS,orgId,appId)){
return RestResponse.failure("You are not authorized to delete this scheduled scan.");
}
ScheduledScan scheduledScan = scheduledScanService.loadById(scheduledScanId);
if (scheduledScan == null) {
return RestResponse.failure("That scheduled scan was not found.");
}
//Remove job from scheduler
if (scheduledScanScheduler.removeScheduledScan(scheduledScan)) {
String ret = scheduledScanService.delete(scheduledScan);
if (ret != null) {
log.warn(ret);
return RestResponse.failure(ret);
} else {
log.info("Successfully deleted scheduled scan from scheduler");
return RestResponse.success(scheduledScan.getFrequency() + " Scan for " + scheduledScan.getScanner()
+ " Scheduled Scan successfully deleted.");
}
} else {
String message = "Failed to delete " + scheduledScan.getFrequency() + " Scan for " + scheduledScan.getScanner() +
" scheduled scan from scheduler";
log.warn(message);
return RestResponse.failure(message);
}
}