log.info("Start deleting scheduled defect tracker update");
if (!PermissionUtils.isAuthorized(Permission.CAN_MANAGE_DEFECT_TRACKERS, null, null)){
return RestResponse.failure("You are not authorized to delete this scheduled defect tracker update.");
}
ScheduledDefectTrackerUpdate scheduledDefectTrackerUpdate = scheduledDefectTrackerUpdateService.loadById(scheduledDefectTrackerUpdateId);
if (scheduledDefectTrackerUpdate == null) {
return RestResponse.failure("That scheduled defect tracker update was not found.");
}
//Remove job from scheduler
if (scheduledDefectTrackerUpdater.removeScheduledDefectTrackerUpdate(scheduledDefectTrackerUpdate)) {
String ret = scheduledDefectTrackerUpdateService.delete(scheduledDefectTrackerUpdate);
if (ret != null) {
log.warn(ret);
return RestResponse.failure(ret);
} else {
log.info("Successfully deleted scheduled defect tracker update from scheduler");
return RestResponse.success(scheduledDefectTrackerUpdate.getFrequency() + " Scheduled Defect Tracker Update successfully deleted.");
}
} else {
String message = "Failed to delete " + scheduledDefectTrackerUpdate.getFrequency() + " Defect Tracker Update from scheduler";
log.warn(message);
return RestResponse.failure(message);
}
}