Browse Source

Merge pull request #322 from lgcareer/branch-1.0.2

add checkExists in deleteJob
pull/2/head
lgcareer 6 years ago committed by GitHub
parent
commit
a221ec0a6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      escheduler-api/src/main/java/cn/escheduler/api/quartz/QuartzExecutors.java
  2. 7
      escheduler-api/src/main/java/cn/escheduler/api/service/SchedulerService.java

10
escheduler-api/src/main/java/cn/escheduler/api/quartz/QuartzExecutors.java

@ -26,8 +26,8 @@ import org.quartz.impl.matchers.GroupMatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Calendar;
import java.util.*;
import java.util.Calendar;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@ -226,8 +226,12 @@ public class QuartzExecutors {
public boolean deleteJob(String jobName, String jobGroupName) {
lock.writeLock().lock();
try {
logger.info("try to delete job, job name: {}, job group name: {},", jobName, jobGroupName);
return scheduler.deleteJob(new JobKey(jobName, jobGroupName));
JobKey jobKey = new JobKey(jobName,jobGroupName);
if(scheduler.checkExists(jobKey)){
logger.info("try to delete job, job name: {}, job group name: {},", jobName, jobGroupName);
return scheduler.deleteJob(jobKey);
}
} catch (SchedulerException e) {
logger.error(String.format("delete job : %s failed",jobName), e);
} finally {

7
escheduler-api/src/main/java/cn/escheduler/api/service/SchedulerService.java

@ -514,6 +514,13 @@ public class SchedulerService extends BaseService {
putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, scheduleId);
return result;
}
// Determine if the login user is the owner of the schedule
if (loginUser.getId() != schedule.getUserId()) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
// check schedule is already online
if(schedule.getReleaseState() == ReleaseState.ONLINE){
putMsg(result, Status.SCHEDULE_CRON_STATE_ONLINE,schedule.getId());

Loading…
Cancel
Save