Project

General

Profile

« Previous | Next » 

Revision 5005

Added by daigle over 15 years ago

Input date formatting changes

View differences:

lib/style/skins/sanparks/sanparks-scheduled-jobs.css
89 89
}
90 90

  
91 91
.field-suffix {
92
	margin: 0px 0px 0px 15px;
92
	margin: 0px 0px 0px 5px;
93 93
	padding: 0px 7px 0px 0px;
94 94
	width: 125px;
95 95
	display: inline;
lib/style/common/scheduleWorkflowRunSection.jsp
1 1
<%@ page    language="java" %>
2
<%@ page import="java.util.TimeZone" %>
2 3
<%
3 4
/*
4 5
*  '$RCSfile$'
......
87 88
					<div class="form-input-row">
88 89
						<div class="field-label" id='start-time-label' >Start Time: </div>  
89 90
						<input class="date-input" name='starttime' id='starttime' /> 
90
						<div class="field-suffix"> (mm/dd/yyyy hh:mm:ss z)</div>
91
						<div class="field-suffix"><%= TimeZone.getDefault().getDisplayName(true, TimeZone.SHORT) %> &nbsp;&nbsp;(mm/dd/yyyy hh:mm:ss)</div>
91 92
					</div>
92 93
					<div class="form-input-row">
93 94
						<div class="field-label" id='interval-label' >Interval: </div>  
src/edu/ucsb/nceas/metacat/workflow/WorkflowScheduler.java
27 27
package edu.ucsb.nceas.metacat.workflow;
28 28

  
29 29
import java.io.IOException;
30
import java.text.SimpleDateFormat;
31
import java.text.ParseException;
32 30
import java.util.Calendar;
33
import java.util.Date;
34 31
import java.util.Hashtable;
35 32
import java.util.HashMap;
36 33

  
......
52 49
import edu.ucsb.nceas.metacat.util.ResponseUtil;
53 50
import edu.ucsb.nceas.metacat.util.RequestUtil;
54 51
import edu.ucsb.nceas.shared.AccessException;
52
import edu.ucsb.nceas.utilities.DateUtil;
53
import edu.ucsb.nceas.utilities.UtilException;
55 54

  
56 55
/**
57 56
 * @author daigle
......
113 112
		try {
114 113
			SchedulerService schedulerService = SchedulerService.getInstance();
115 114

  
116
			// get start time or delay.  Start time takes precidence if both exist.
115
			// get start time or delay.  Start time takes precedence if both exist.
117 116
			if (startTimes != null && startTimes.length > 0) {
118
				SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss z");
119
				Date startDate = dateFormat.parse(startTimes[0]);
120
				startCal = Calendar.getInstance();
121
				startCal.setTime(startDate);
117
				startCal = DateUtil.humanReadableToCalendar(startTimes[0], "MM/dd/yyyy HH:mm:ss z");
122 118
			} else if (delays != null && delays.length > 0) {
123 119
				startCal = schedulerService.getStartDateFromDelay(delays[0]);
124 120
			} else {
......
197 193
				ResponseUtil.sendSuccessXML(response, xmlResult);
198 194
			}
199 195
			
200
		} catch (ParseException pe) {
201
			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - Could not " + "schedule job  : " 
202
					+ pe.getMessage());
196
		} catch (UtilException ue) {
197
			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - Utility issue when scheduling job: " + ue.getMessage());
203 198
		} catch (ServiceException se) {
204
			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - Service issue scheduling job", se);
199
			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - Service issue when scheduling job", se);
205 200
		} catch (IOException ioe) {
206
			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - I/O issue scheduling job: " + ioe.getMessage());
201
			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - I/O issue when scheduling job: " + ioe.getMessage());
207 202
		} catch (ServletException se) {
208
			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - Servlet issue scheduling job: " + se.getMessage());
203
			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - Servlet issue when scheduling job: " + se.getMessage());
209 204
		} catch (ErrorSendingErrorException esee) {
210
			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - Issue sending erro when scheduling job: " + esee.getMessage());			
205
			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - Issue sending error when scheduling job: " + esee.getMessage());			
211 206
		}
212 207
	}
213 208
	
src/edu/ucsb/nceas/metacat/scheduler/SchedulerService.java
44 44
import edu.ucsb.nceas.metacat.service.BaseService;
45 45
import edu.ucsb.nceas.metacat.service.ServiceException;
46 46
import edu.ucsb.nceas.shared.AccessException;
47
import edu.ucsb.nceas.utilities.DateUtil;
47 48
import edu.ucsb.nceas.utilities.StatusUtil;
49
import edu.ucsb.nceas.utilities.UtilException;
48 50

  
49 51
public class SchedulerService extends BaseService {
50 52
	
......
188 190
			String username, String[] groups) throws ServiceException {
189 191
        
190 192
        Class<Job> jobClass = null;
191
        try {        	
192
        	jobClass = (Class<Job>)Class.forName(jobClassName);     	
193
        } catch (ClassNotFoundException cnfe) {
194
        	throw new ServiceException("SchedulerService.scheduleJob - Could not find class with name: " 
195
        			+ jobClassName + " : " + cnfe.getMessage());
196
        } 
197
        
198
        logMetacat.info("SchedulerService.scheduleJob - Scheduling job -- name: " + jobName + ", class: " + jobClassName 
199
        		+ ", start time: " + startCal.toString() + ", interval value: " + intervalValue 
200
        		+ ", interval unit: " + intervalUnit);  
201
		
202
        // start the job in the job scheduler
203
		startJob(jobName, startCal, intervalValue, intervalUnit, jobClass, jobGroup, jobParams);
204
		
205
		// get a database access object and create the job in the database
206
		try {
193
        try {
194
			jobClass = (Class<Job>) Class.forName(jobClassName);
195

  
196
			String startTimeStr = DateUtil.getHumanReadable(startCal, true);
197
			logMetacat.info("SchedulerService.scheduleJob - Scheduling job -- name: "
198
					+ jobName + ", class: " + jobClassName + ", start time: "
199
					+ startTimeStr + ", interval value: " + intervalValue
200
					+ ", interval unit: " + intervalUnit);
201

  
202
			// start the job in the job scheduler
203
			startJob(jobName, startCal, intervalValue, intervalUnit, jobClass, jobGroup,
204
					jobParams);
205

  
206
			// get a database access object and create the job in the database
207

  
207 208
			ScheduledJobAccess jobAccess = new ScheduledJobAccess();
208
			jobAccess.createJob(jobName, jobName, jobGroup, jobClass, startCal, intervalValue, intervalUnit, jobParams);
209
			jobAccess.createJob(jobName, jobName, jobGroup, jobClass, startCal,
210
					intervalValue, intervalUnit, jobParams);
209 211
		} catch (AccessException ae) {
210 212
			try {
211 213
				deleteJob(jobName, username, groups);
212 214
			} catch (Exception e) {
213 215
				// Not much we can do here but log this
214
				logMetacat.error("SchedulerService.scheduleJob - An access exception was thrown when writing job: " + jobName 
215
						+ "to the db, and another exception was thrown when trying to remove the " 
216
				logMetacat.error("SchedulerService.scheduleJob - An access exception was thrown when writing job: "
217
						+ jobName + "to the db, and another exception was thrown when trying to remove the "
216 218
						+ "job from the scheduler.  The db and scheduler may be out of sync: " + e.getMessage());
217 219
			}
218 220
			throw new ServiceException("SchedulerService.scheduleJob - Error accessing db: ", ae);
221
		} catch (ClassNotFoundException cnfe) {
222
			throw new ServiceException("SchedulerService.scheduleJob - Could not find class with name: "
223
							+ jobClassName + " : " + cnfe.getMessage());
224
		} catch (UtilException ue) {
225
			throw new ServiceException("SchedulerService.scheduleJob - Could not schedule "
226
							+ "job due to a utility issue: " + ue.getMessage());
219 227
		}
220 228
		
221 229
		return "Scheduled: " + jobName;
......
323 331
	        			+ jobDAO.getClassName() + " : " + cnfe.getMessage());
324 332
	        } 
325 333
	        
334
	        String startTimeStr = DateUtil.getHumanReadable(startCal, true);
326 335
	        logMetacat.info("SchedulerService.rescheduleJob - name: " + jobDAO.getName() + ", class: " + jobClassName 
327
	        		+ ", start time: " + startCal.toString() + ", interval value: " + jobDAO.getIntervalValue() 
336
	        		+ ", start time: " + startTimeStr + ", interval value: " + jobDAO.getIntervalValue() 
328 337
	        		+ ", interval unit: " + jobDAO.getIntervalUnit());  
329 338
			
330 339
	        // start the job in the scheduler
......
337 346
		} catch (AccessException ae) {
338 347
			throw new ServiceException("SchedulerService.reScheduleJob - Could not reschedule "
339 348
					+ "job because of db access issue: ", ae);
349
		} catch (UtilException ue) {
350
			throw new ServiceException("SchedulerService.reScheduleJob - Could not reschedule "
351
					+ "job due to a utility issue: " + ue.getMessage());
340 352
		}
341 353
        		
342 354
		return "Resheduled: " + jobDAO.getName();
......
461 473
			jobXML += "<triggerName>" + scheduledJobDAO.getName() + "</triggerName>";
462 474
			jobXML += "<groupName>" + scheduledJobDAO.getGroupName() + "</groupName>";
463 475
			jobXML += "<className>" + scheduledJobDAO.getClassName() + "</className>";
464
			jobXML += "<startTime>" + scheduledJobDAO.getStartTime().toString()
476
			String startTimeString = null;
477
			try {
478
				startTimeString = 
479
					DateUtil.getHumanReadable(scheduledJobDAO.getStartTime(), true);
480
			} catch (UtilException ue) {
481
				throw new ServiceException("SchedulerService.jobToXML - error getting human readable date for job: " 
482
						+ scheduledJobDAO.getId() + " ; " + ue.getMessage());
483
			}
484
			jobXML += "<startTime>" + startTimeString
465 485
					+ "</startTime>";
466 486
			jobXML += "<intervalValue>" + scheduledJobDAO.getIntervalValue()
467 487
					+ "</intervalValue>";

Also available in: Unified diff