private void validateFields(Repo repo) throws RepoException { if (repo.getName() == null || repo.getName().trim().equals("")) { throw new RepoException("Repo name is required"); } if (repo.getSyncSchedule() != null) { try { CronExpression ce = new CronExpression(repo.getSyncSchedule()); } catch (ParseException e) { throw new RepoException("Repo sync schedule is not a vaild format."); } } }
/** * This will schedule the sync job for the given repository. Once the scheduling is complete, the repository's * adapter will be asked to synchronize with the remote repository according to the time(s) specified * in the {@link Repo#getSyncSchedule() schedule}. * * <p>If the repository's sync schedule is empty, this method assumes it should not be automatically sync'ed, so * no schedule will be created, and this method simply returns.</p> * * @param repo repository to sync * * @throws SchedulerException if failed to schedule the job */ public void scheduleRepoSyncJob(Repo repo) throws SchedulerException { String syncSchedule = repo.getSyncSchedule(); if ((syncSchedule == null) || (syncSchedule.trim().length() == 0)) { getLog().warn(repo.toString() + " does not define a sync schedule - not scheduling."); return; } SchedulerLocal scheduler = LookupUtil.getSchedulerBean(); scheduler.scheduleCronJob(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME, RepoSyncJob .createJobDataMap(null, repo), RepoSyncJob.class, true, false, syncSchedule); }