protected Date parseDate(String date, String time) { Calendar cal = Calendar.getInstance(); Calendar timeCalendar = Calendar.getInstance(); try { timeCalendar.setTime(timeFormat.parse(time)); cal.setTime(new Date(Long.parseLong(date))); cal.add(Calendar.HOUR_OF_DAY, timeCalendar.get(Calendar.HOUR_OF_DAY)); cal.add(Calendar.MINUTE, timeCalendar.get(Calendar.MINUTE)); if (getLogger().isDebugEnabled()) { getLogger().debug("Parsed date from task creation request: " + cal.getTime()); } } catch (ParseException e) { cal = null; } return cal == null ? null : cal.getTime(); }
ScheduledServiceOnceResource res = (ScheduledServiceOnceResource) resource; res.setStartDate(formatDate(taskSchedule.getStartDate())); res.setStartTime(formatTime(taskSchedule.getStartDate())); ScheduledServiceHourlyResource res = (ScheduledServiceHourlyResource) resource; res.setStartDate(formatDate(taskSchedule.getStartDate())); res.setStartTime(formatTime(taskSchedule.getStartDate())); res.setStartDate(formatDate(taskSchedule.getStartDate())); res.setRecurringTime(formatTime(taskSchedule.getStartDate())); res.setStartDate(formatDate(taskSchedule.getStartDate())); res.setRecurringTime(formatTime(taskSchedule.getStartDate())); res.setRecurringDay(formatRecurringDayOfWeek(taskSchedule.getDaysToRun())); res.setStartDate(formatDate(taskSchedule.getStartDate())); res.setRecurringTime(formatTime(taskSchedule.getStartDate())); res.setRecurringDay(formatRecurringDayOfMonth(taskSchedule.getDaysToRun())); resource.setEnabled(task.isEnabled()); resource.setName(task.getName()); resource.setSchedule(getScheduleShortName(task.getSchedule())); resource.setTypeId(task.getType()); resource.setProperties(formatServiceProperties(task.getTaskParams())); resource.setAlertEmail(TaskUtils.getAlertEmail(task));
parseDate(((ScheduledServiceMonthlyResource) model).getStartDate(), ((ScheduledServiceMonthlyResource) model).getRecurringTime()); formatRecurringDayOfMonth(((ScheduledServiceMonthlyResource) model).getRecurringDay())); parseDate(((ScheduledServiceWeeklyResource) model).getStartDate(), ((ScheduledServiceWeeklyResource) model).getRecurringTime()); formatRecurringDayOfWeek(((ScheduledServiceWeeklyResource) model).getRecurringDay())); parseDate(((ScheduledServiceDailyResource) model).getStartDate(), ((ScheduledServiceDailyResource) model).getRecurringTime()); parseDate(((ScheduledServiceHourlyResource) model).getStartDate(), ((ScheduledServiceHourlyResource) model).getStartTime()); parseDate(((ScheduledServiceOnceResource) model).getStartDate(), ((ScheduledServiceOnceResource) model).getStartTime()); validateStartDate(((ScheduledServiceOnceResource) model).getStartDate()); validateTime("startTime", date); new OnceSchedule(parseDate(((ScheduledServiceOnceResource) model).getStartDate(), ((ScheduledServiceOnceResource) model).getStartTime()));
public NexusTask<?> getModelNexusTask(ScheduledServiceBaseResource model, Request request) throws IllegalArgumentException, ResourceException { String serviceType = model.getTypeId(); NexusTask<?> task = getNexusScheduler().createTaskInstance(serviceType); for (Iterator iter = model.getProperties().iterator(); iter.hasNext(); ) { ScheduledServicePropertyResource prop = (ScheduledServicePropertyResource) iter.next(); task.addParameter(prop.getKey(), prop.getValue()); } TaskUtils.setAlertEmail(task, model.getAlertEmail()); TaskUtils.setId(task, model.getId()); TaskUtils.setName(task, model.getName()); return task; }
ScheduledServiceOnceResource res = (ScheduledServiceOnceResource) resource; res.setStartDate( formatDate( taskSchedule.getStartDate() ) ); res.setStartTime( formatTime( taskSchedule.getStartDate() ) ); ScheduledServiceHourlyResource res = (ScheduledServiceHourlyResource) resource; res.setStartDate( formatDate( taskSchedule.getStartDate() ) ); res.setStartTime( formatTime( taskSchedule.getStartDate() ) ); res.setStartDate( formatDate( taskSchedule.getStartDate() ) ); res.setRecurringTime( formatTime( taskSchedule.getStartDate() ) ); res.setStartDate( formatDate( taskSchedule.getStartDate() ) ); res.setRecurringTime( formatTime( taskSchedule.getStartDate() ) ); res.setRecurringDay( formatRecurringDayOfWeek( taskSchedule.getDaysToRun() ) ); res.setStartDate( formatDate( taskSchedule.getStartDate() ) ); res.setRecurringTime( formatTime( taskSchedule.getStartDate() ) ); res.setRecurringDay( formatRecurringDayOfMonth( taskSchedule.getDaysToRun() ) ); resource.setEnabled( task.isEnabled() ); resource.setName( task.getName() ); resource.setSchedule( getScheduleShortName( task.getSchedule() ) ); resource.setTypeId( task.getType() ); resource.setProperties( formatServiceProperties( task.getTaskParams() ) ); resource.setAlertEmail( TaskUtils.getAlertEmail( task ) );
parseDate( ( (ScheduledServiceMonthlyResource) model ).getStartDate(), ( (ScheduledServiceMonthlyResource) model ).getRecurringTime() ); formatRecurringDayOfMonth( ( (ScheduledServiceMonthlyResource) model ).getRecurringDay() ) ); parseDate( ( (ScheduledServiceWeeklyResource) model ).getStartDate(), ( (ScheduledServiceWeeklyResource) model ).getRecurringTime() ); formatRecurringDayOfWeek( ( (ScheduledServiceWeeklyResource) model ).getRecurringDay() ) ); parseDate( ( (ScheduledServiceDailyResource) model ).getStartDate(), ( (ScheduledServiceDailyResource) model ).getRecurringTime() ); parseDate( ( (ScheduledServiceHourlyResource) model ).getStartDate(), ( (ScheduledServiceHourlyResource) model ).getStartTime() ); parseDate( ( (ScheduledServiceOnceResource) model ).getStartDate(), ( (ScheduledServiceOnceResource) model ).getStartTime() ); validateStartDate( ( (ScheduledServiceOnceResource) model ).getStartDate() ); validateTime( "startTime", date ); new OnceSchedule( parseDate( ( (ScheduledServiceOnceResource) model ).getStartDate(), ( (ScheduledServiceOnceResource) model ).getStartTime() ) );
public NexusTask<?> getModelNexusTask( ScheduledServiceBaseResource model, Request request ) throws IllegalArgumentException, ResourceException { String serviceType = model.getTypeId(); NexusTask<?> task = getNexusScheduler().createTaskInstance( serviceType ); for ( Iterator iter = model.getProperties().iterator(); iter.hasNext(); ) { ScheduledServicePropertyResource prop = (ScheduledServicePropertyResource) iter.next(); task.addParameter( prop.getKey(), prop.getValue() ); } TaskUtils.setAlertEmail( task, model.getAlertEmail() ); TaskUtils.setId( task, model.getId() ); TaskUtils.setName( task, model.getName() ); return task; }
protected Date parseDate( String date, String time ) { Calendar cal = Calendar.getInstance(); Calendar timeCalendar = Calendar.getInstance(); try { timeCalendar.setTime( timeFormat.parse( time ) ); cal.setTime( new Date( Long.parseLong( date ) ) ); cal.add( Calendar.HOUR_OF_DAY, timeCalendar.get( Calendar.HOUR_OF_DAY ) ); cal.add( Calendar.MINUTE, timeCalendar.get( Calendar.MINUTE ) ); if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Parsed date from task creation request: " + cal.getTime() ); } } catch ( ParseException e ) { cal = null; } return cal == null ? null : cal.getTime(); }
public void validateStartDate(String date) throws InvalidConfigurationException { Calendar cal = Calendar.getInstance(); Date startDate = new Date(Long.parseLong(date)); cal.setTime(startDate); Calendar nowCal = Calendar.getInstance(); nowCal.add(Calendar.DAY_OF_YEAR, -1); nowCal.set(Calendar.HOUR, 0); nowCal.set(Calendar.MINUTE, 0); nowCal.set(Calendar.SECOND, 0); nowCal.set(Calendar.MILLISECOND, 0); // This is checking just the year/month/day, time isn't of concern right now // basic check that the day timestamp is roughly in the correct range if (cal.before(nowCal)) { if (getLogger().isDebugEnabled()) { getLogger().debug("Validation error for startDate: " + startDate.toString()); } ValidationResponse vr = new ApplicationValidationResponse(); ValidationMessage vm = new ValidationMessage("startDate", "Date cannot be in the past."); vr.addValidationError(vm); throw new InvalidConfigurationException(vr); } }
public void validateStartDate( String date ) throws InvalidConfigurationException { Calendar cal = Calendar.getInstance(); Date startDate = new Date( Long.parseLong( date ) ); cal.setTime( startDate ); Calendar nowCal = Calendar.getInstance(); nowCal.add( Calendar.DAY_OF_YEAR, -1 ); nowCal.set( Calendar.HOUR, 0 ); nowCal.set( Calendar.MINUTE, 0 ); nowCal.set( Calendar.SECOND, 0 ); nowCal.set( Calendar.MILLISECOND, 0 ); // This is checking just the year/month/day, time isn't of concern right now // basic check that the day timestamp is roughly in the correct range if ( cal.before( nowCal ) ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Validation error for startDate: " + startDate.toString() ); } ValidationResponse vr = new ApplicationValidationResponse(); ValidationMessage vm = new ValidationMessage( "startDate", "Date cannot be in the past." ); vr.addValidationError( vm ); throw new InvalidConfigurationException( vr ); } }