当前位置: 首页>>代码示例>>Java>>正文


Java CronExpression.isValidExpression方法代码示例

本文整理汇总了Java中org.quartz.CronExpression.isValidExpression方法的典型用法代码示例。如果您正苦于以下问题:Java CronExpression.isValidExpression方法的具体用法?Java CronExpression.isValidExpression怎么用?Java CronExpression.isValidExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.quartz.CronExpression的用法示例。


在下文中一共展示了CronExpression.isValidExpression方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkAndSaveSchedule

import org.quartz.CronExpression; //导入方法依赖的package包/类
private VmSchedule checkAndSaveSchedule(final VmScheduleVo schedule, final VmSchedule entity) {
	// Check the subscription is visible
	final Subscription subscription = subscriptionResource.checkVisibleSubscription(schedule.getSubscription());

	if (schedule.getCron().split(" ").length == 6) {
		// Add the missing "seconds" part
		schedule.setCron(schedule.getCron() + " *");
	}
	// Check expressions first
	if (!CronExpression.isValidExpression(schedule.getCron())) {
		throw new ValidationJsonException("cron", "vm-cron");
	}

	// Every second is not accepted
	if (schedule.getCron().startsWith("* ")) {
		throw new ValidationJsonException("cron", "vm-cron-second");
	}

	entity.setSubscription(subscription);
	entity.setOperation(schedule.getOperation());
	entity.setCron(schedule.getCron());

	// Persist the new schedules for each provided CRON
	vmScheduleRepository.saveAndFlush(entity);
	return entity;
}
 
开发者ID:ligoj,项目名称:plugin-vm,代码行数:27,代码来源:VmResource.java

示例2: validateCronExpression

import org.quartz.CronExpression; //导入方法依赖的package包/类
@RequestMapping("withoutAuth/validateCron.html")
@ResponseBody
public Object validateCronExpression(String cronExpression){
	try
	{
		boolean result = CronExpression.isValidExpression(cronExpression);
		if(result)
		{
			return true;
		}else
		{
			return false;
		}
	}catch(Exception e)
	{
		throw new AjaxException(e);
	}
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:19,代码来源:ScheduleJobController.java

示例3: registerCronJob

import org.quartz.CronExpression; //导入方法依赖的package包/类
/**
 * Register cron job REST API
 * @param message - JSON with cron expressions.
 * @return JSON with status.OK
 * @throws IOException, IllegalArgumentException
 */
@POST
@Path("cron/{notebookId}")
public Response registerCronJob(@PathParam("notebookId") String notebookId, String message) throws
    IOException, IllegalArgumentException {
  LOG.info("Register cron job note={} request cron msg={}", notebookId, message);

  CronRequest request = gson.fromJson(message,
                        CronRequest.class);
  
  Note note = notebook.getNote(notebookId);
  if (note == null) {
    return new JsonResponse<>(Status.NOT_FOUND, "note not found.").build();
  }
  
  if (!CronExpression.isValidExpression(request.getCronString())) {
    return new JsonResponse<>(Status.BAD_REQUEST, "wrong cron expressions.").build();
  }

  Map<String, Object> config = note.getConfig();
  config.put("cron", request.getCronString());
  note.setConfig(config);
  notebook.refreshCron(note.id());
  
  return new JsonResponse<>(Status.OK).build();
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:32,代码来源:NotebookRestApi.java

示例4: registerCronJob

import org.quartz.CronExpression; //导入方法依赖的package包/类
/**
 * Register cron job REST API
 *
 * @param message - JSON with cron expressions.
 * @return JSON with status.OK
 * @throws IOException, IllegalArgumentException
 */
@POST
@Path("cron/{noteId}")
@ZeppelinApi
public Response registerCronJob(@PathParam("noteId") String noteId, String message)
    throws IOException, IllegalArgumentException {
  LOG.info("Register cron job note={} request cron msg={}", noteId, message);

  CronRequest request = CronRequest.fromJson(message);

  Note note = notebook.getNote(noteId);
  checkIfNoteIsNotNull(note);
  checkIfUserCanRun(noteId, "Insufficient privileges you cannot set a cron job for this note");

  if (!CronExpression.isValidExpression(request.getCronString())) {
    return new JsonResponse<>(Status.BAD_REQUEST, "wrong cron expressions.").build();
  }

  Map<String, Object> config = note.getConfig();
  config.put("cron", request.getCronString());
  note.setConfig(config);
  notebook.refreshCron(note.getId());

  return new JsonResponse<>(Status.OK).build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:32,代码来源:NotebookRestApi.java

示例5: registerCronJob

import org.quartz.CronExpression; //导入方法依赖的package包/类
/**
 * Register cron job REST API
 *
 * @param message - JSON with cron expressions.
 * @return JSON with status.OK
 * @throws IOException, IllegalArgumentException
 */
@POST
@Path("cron/{noteId}")
public Response registerCronJob(@PathParam("noteId") String noteId, String message)
        throws IOException, IllegalArgumentException {
  LOG.info("Register cron job note={} request cron msg={}", noteId, message);

  CronRequest request = CronRequest.fromJson(message);

  Note note = notebook.getNote(noteId);
  checkIfNoteIsNotNull(note);
  checkIfUserCanWrite(noteId, "Insufficient privileges you cannot set a cron job for this note");

  if (!CronExpression.isValidExpression(request.getCronString())) {
    return new JsonResponse<>(Status.BAD_REQUEST, "wrong cron expressions.").build();
  }

  Map<String, Object> config = note.getConfig();
  config.put("cron", request.getCronString());
  note.setConfig(config);
  notebook.refreshCron(note.getId());

  return new JsonResponse<>(Status.OK).build();
}
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:31,代码来源:NotebookRestApi.java

示例6: updateAlertConfig

import org.quartz.CronExpression; //导入方法依赖的package包/类
/**
 * update alert config's cron and activation by id
 * @param id alert config id
 * @param cron cron expression for alert
 * @param isActive activate or not
 * @return Response
 * @throws Exception
 */
@PUT
@Path("/alert/{id}")
public Response updateAlertConfig(@NotNull @PathParam("id") Long id,
    @QueryParam("cron") String cron, @QueryParam("isActive") Boolean isActive) throws Exception {

  AlertConfigDTO alert = alertDAO.findById(id);
  if (alert == null) {
    throw new IllegalStateException("Alert Config with id " + id + " does not exist");
  }

  if (isActive != null) {
    alert.setActive(isActive);
  }

  if (StringUtils.isNotEmpty(cron)) {
    // validate cron
    if (!CronExpression.isValidExpression(cron)) {
      throw new IllegalArgumentException("Invalid cron expression for cron : " + cron);
    }
    alert.setCronExpression(cron);
  }

  alertDAO.update(alert);
  return Response.ok(id).build();
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:34,代码来源:EmailResource.java

示例7: updateAlertConfigHolidayCron

import org.quartz.CronExpression; //导入方法依赖的package包/类
/**
 * update alert config's holiday cron and activation by id
 * if this cron is not null then holiday mode is activate
 * @param id id of the config
 * @param cron holiday cron expression
 * @return Response
 * @throws Exception
 */
@PUT
@Path("/alert/{id}/holiday-mode")
public Response updateAlertConfigHolidayCron(@NotNull @PathParam("id") Long id,
    @QueryParam("cron") String cron) throws Exception {

  AlertConfigDTO alert = alertDAO.findById(id);
  if (alert == null) {
    throw new IllegalStateException("Alert Config with id " + id + " does not exist");
  }

  if (StringUtils.isNotEmpty(cron)) {
    // validate cron
    if (!CronExpression.isValidExpression(cron)) {
      throw new IllegalArgumentException("Invalid cron expression for cron : " + cron);
    }
    // as long as there is an valid holiday cron expression within the class
    // the holiday model is activate
    alert.setHolidayCronExpression(cron);
  } else {
    alert.setHolidayCronExpression(null);  // equivalent to deactivate holiday
  }

  alertDAO.update(alert);
  return Response.ok(id).build();
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:34,代码来源:EmailResource.java

示例8: isCronExpression

import org.quartz.CronExpression; //导入方法依赖的package包/类
/**
 * 校验cron表达式
 * @param unexpected
 * @param message
 */
public static void isCronExpression(String unexpected, String message) {
    boolean validExpression = CronExpression.isValidExpression(unexpected);
    if (!validExpression) {
        throw new IllegalArgumentException(message);
    }
}
 
开发者ID:quartzweb,项目名称:quartz-web,代码行数:12,代码来源:Assert.java

示例9: validateCronExp

import org.quartz.CronExpression; //导入方法依赖的package包/类
@RequestMapping(value = "exp.do",method= RequestMethod.POST)
@ResponseBody
public boolean validateCronExp(Integer cronType, String cronExp) {
    boolean pass = false;
    if (cronType == 0) pass = SchedulingPattern.validate(cronExp);
    if (cronType == 1) pass = CronExpression.isValidExpression(cronExp);
    return pass;
}
 
开发者ID:wolfboys,项目名称:opencron,代码行数:9,代码来源:VerifyController.java

示例10: validate

import org.quartz.CronExpression; //导入方法依赖的package包/类
public static JSONObject validate(InputDataConfig inputDataConfig) {
	JSONObject response = new JSONObject();

	if (inputDataConfig.getReportAccess().getMailReport().getMailList().size() == 0) {
		response.put(Constants.STATUS_CODE, 0);
		response.put(Constants.STATUS_MESSAGE, "Enter atleast 1 E-Mail ID");
		return response;
	}

	List<String> mailIDList = inputDataConfig.getReportAccess().getMailReport().getMailList();

	for (String mailID : mailIDList) {
		try {
			InternetAddress emailAddr = new InternetAddress(mailID);
			emailAddr.validate();
		} catch (AddressException e) {
			response.put(Constants.STATUS_CODE, 0);
			response.put(Constants.STATUS_MESSAGE, mailID + " is not a valid E-Mail ID");
			return response;
		}
	}

	if (inputDataConfig.getReportAccess().isScheduleReportEnabled()) {
		List<String> cronExpressionList = inputDataConfig.getReportAccess().getScheduleReport().getCronExpressionList();
		for (String cronExpression : cronExpressionList) {
			if (!CronExpression.isValidExpression(cronExpression)) {
				response.put(Constants.STATUS_CODE, 0);
				response.put(Constants.STATUS_MESSAGE, "CRON expression " + cronExpression + "is invalid");
				return response;
			}
		}
	}

	response.put(Constants.STATUS_CODE, 1);
	return response;
}
 
开发者ID:raghavendar-ts,项目名称:ElasticTab-Elasticsearch-to-Excel-Report,代码行数:37,代码来源:Util.java

示例11: validateCron

import org.quartz.CronExpression; //导入方法依赖的package包/类
@Mapping("/check/cron")
@Jsonp
@ResponseReturn(contentType = ResponseReturnType.TEXT_JAVASCRIPT)
public String validateCron(WebAttributers was) {
	String cronExpr = was.get(StaticDict.PAGE_PARAM_TASK_TRIGGER_CRON_EXPR);
	ProcessLogger.debug("validating cron expression:" + cronExpr);
	if (CronExpression.isValidExpression(cronExpr)) {
		return OperationJson.build().sucess().toString();
	}
	return OperationJson.build().error().toString();
}
 
开发者ID:daileyet,项目名称:webscheduler,代码行数:12,代码来源:TaskController.java

示例12: scheduleCronJob

import org.quartz.CronExpression; //导入方法依赖的package包/类
/**
 * Create a new cron job and register it with the job scheduler. Parameters (cron expression and eval states) are read from the
 * values updated in the request.
 *  
 * @return true if the method successfully scheduled the cron job, and false if some error prevented the cron job from being scheduled.
 */
protected boolean scheduleCronJob() {
	boolean error = false;
	if(cronExpression == null || cronExpression.trim().equals("")) { 
		//messages.addMessage(new TargettedMessage("administrate.sync.cronExpression.null", null, TargettedMessage.SEVERITY_ERROR));
		error = true;
		
	} else if(! CronExpression.isValidExpression(cronExpression)) {
		// send an error message through targeted messages
		//messages.addMessage(new TargettedMessage("administrate.sync.cronExpression.err", new Object[]{ cronExpression.trim() }, TargettedMessage.SEVERITY_ERROR));
		error = true;
	} 

	String states = null;
	if(! error) {
		
		states = getStateValues();
		if(states == null || states.trim().equals("")) {
			//messages.addMessage(new TargettedMessage("administrate.sync.stateList.null", null, TargettedMessage.SEVERITY_ERROR));
			error = true;
		}
	}

	if(! error){
		Map<String,String> dataMap = new HashMap<>();
		String uniqueId = EvalUtils.makeUniqueIdentifier(99);
		dataMap.put(EvalConstants.CRON_SCHEDULER_TRIGGER_NAME, uniqueId);
		dataMap.put(EvalConstants.CRON_SCHEDULER_TRIGGER_GROUP, JOB_GROUP_NAME);
		dataMap.put(EvalConstants.CRON_SCHEDULER_JOB_NAME, uniqueId);
		dataMap.put(EvalConstants.CRON_SCHEDULER_JOB_GROUP, JOB_GROUP_NAME);
		
		dataMap.put(EvalConstants.CRON_SCHEDULER_CRON_EXPRESSION, this.cronExpression);
		
		dataMap.put(EvalConstants.CRON_SCHEDULER_SPRING_BEAN_NAME, GroupMembershipSync.GROUP_MEMBERSHIP_SYNC_BEAN_NAME);
		dataMap.put(GroupMembershipSync.GROUP_MEMBERSHIP_SYNC_PROPNAME_STATE_LIST, states);

		commonLogic.scheduleCronJob("org.sakaiproject.api.app.scheduler.JobBeanWrapper.GroupMembershipSync", dataMap);
	}
	return !error;
}
 
开发者ID:sakaicontrib,项目名称:evaluation,代码行数:46,代码来源:ProviderSyncBean.java

示例13: verifyBaseReplicationRequest

import org.quartz.CronExpression; //导入方法依赖的package包/类
public static void verifyBaseReplicationRequest(ReplicationBaseDescriptor replication) {
    if (StringUtils.isBlank(replication.getCronExp())) {
        throw new BadRequestException("cronExp is required");
    }
    if (!CronExpression.isValidExpression(replication.getCronExp())) {
        throw new BadRequestException("Invalid cronExp");
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:9,代码来源:ReplicationConfigRequestHelper.java

示例14: validateCronSchedulableJob

import org.quartz.CronExpression; //导入方法依赖的package包/类
/**
 * Validates if the given {@code job} has cron expression, motech event and start date fields set.
 *
 * @param job  the job to be validated
 */
public static void validateCronSchedulableJob(CronSchedulableJob job) {
    notNull(job, JOB_CANNOT_BE_NULL);
    notEmpty(job.getCronExpression(), "Cron expression cannot be null or empty!");
    notNull(job.getMotechEvent(), MOTECH_EVENT_CANNOT_BE_NULL);

    if (!CronExpression.isValidExpression(job.getCronExpression())) {
        throw new MotechSchedulerException(format("Can not schedule job. Invalid Cron expression: %s",
                job.getCronExpression()),
                "scheduler.error.invalidCronExpression", Arrays.asList(job.getCronExpression()));
    }

    validateEndDate(job);
}
 
开发者ID:motech,项目名称:motech,代码行数:19,代码来源:SchedulableJobValidator.java

示例15: CronExpressionUtil

import org.quartz.CronExpression; //导入方法依赖的package包/类
public CronExpressionUtil(String expression) {
    if (!CronExpression.isValidExpression(expression)) {
        throw new CronExpressionException(expression);
    }

    String[] parts = expression.split(" ");

    time = new Time(Integer.valueOf(parts[2]), Integer.valueOf(parts[1]));

    daysOfWeek = new ArrayList<>();
    for (String part : parts[5].split(",")) {
        daysOfWeek.add(DayOfWeek.getDayOfWeek(getDayOfWeekValue(part)));
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:15,代码来源:CronExpressionUtil.java


注:本文中的org.quartz.CronExpression.isValidExpression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。