Revision 5013
Added by daigle almost 15 years ago
WorkflowScheduler.java | ||
---|---|---|
194 | 194 |
} |
195 | 195 |
|
196 | 196 |
String destination = "/style/skins/" + qformat + "/" + forwardto |
197 |
+ "?workflowid=" + jobParams.get("workflowid") + "&karid="
|
|
198 |
+ jobParams.get("karid"); |
|
197 |
+ "?workflowid=" + jobParams.get("workflowid") |
|
198 |
+ "&karid=" + jobParams.get("karid");
|
|
199 | 199 |
RequestUtil.forwardRequest(request, response, destination); |
200 | 200 |
} else { |
201 | 201 |
ResponseUtil.sendSuccessXML(response, xmlResult); |
... | ... | |
264 | 264 |
ScheduledJobDAO jobDAO = jobAccess.getJobByName(jobName); |
265 | 265 |
|
266 | 266 |
// we need to include the workflow id in the forward url |
267 |
String workflowId = null;
|
|
268 |
ScheduledJobParamDAO jobParamDAO = jobDAO.getJobParam("workflowid");
|
|
269 |
if (jobParamDAO != null) {
|
|
270 |
workflowId = jobParamDAO.getValue();
|
|
267 |
ScheduledJobParamDAO workflowIdJobParamDAO = jobDAO.getJobParam("workflowid");
|
|
268 |
if (workflowIdJobParamDAO == null) {
|
|
269 |
throw new MetacatSchedulerException("WorkflowScheduler.unScheduleJob - could not find workflow "
|
|
270 |
+ "id when unscheduling job: " + jobName);
|
|
271 | 271 |
} |
272 | 272 |
|
273 | 273 |
// we need to include the workflow id in the forward url |
274 |
String karId = null; |
|
275 | 274 |
ScheduledJobParamDAO karJobParamDAO = jobDAO.getJobParam("karid"); |
276 |
if (karJobParamDAO != null) { |
|
277 |
karId = karJobParamDAO.getValue(); |
|
275 |
if (karJobParamDAO == null) { |
|
276 |
throw new MetacatSchedulerException("WorkflowScheduler.unScheduleJob - could not find kar " |
|
277 |
+ "id when unscheduling job: " + jobName); |
|
278 | 278 |
} |
279 | 279 |
|
280 |
// we need to include the workflow id in the url |
|
281 |
ScheduledJobParamDAO workflowNameJobParamDAO = jobDAO.getJobParam("workflowname"); |
|
282 |
if (workflowNameJobParamDAO == null) { |
|
283 |
throw new MetacatSchedulerException("WorkflowScheduler.unScheduleJob - could not find workflow " |
|
284 |
+ "name when unscheduling job: " + jobName); |
|
285 |
} |
|
286 |
|
|
280 | 287 |
String destination = "/style/skins/" + qformat + "/" + forwardto |
281 |
+ "?workflowid=" + workflowId + "&karid=" + karId; |
|
288 |
+ "?workflowid=" + workflowIdJobParamDAO.getValue() |
|
289 |
+ "&karid=" + karJobParamDAO.getValue() |
|
290 |
+ "&workflowname=" + workflowNameJobParamDAO.getValue(); |
|
291 |
|
|
282 | 292 |
RequestUtil.forwardRequest(request, response, destination.toString()); |
283 | 293 |
} else { |
284 | 294 |
ResponseUtil.sendSuccessXML(response, xmlResult); |
... | ... | |
344 | 354 |
qformat = qformats[0]; |
345 | 355 |
} |
346 | 356 |
|
347 |
// we need to include the workflow id in the forward url |
|
348 |
String workflowId = null; |
|
349 |
ScheduledJobParamDAO jobParamDAO = jobDAO.getAllJobParams().get("workflowid"); |
|
350 |
if (jobParamDAO != null) { |
|
351 |
workflowId = jobParamDAO.getValue(); |
|
357 |
// we need to include the workflow id in the url |
|
358 |
ScheduledJobParamDAO workflowIdJobParamDAO = jobDAO.getAllJobParams().get("workflowid"); |
|
359 |
if (workflowIdJobParamDAO == null) { |
|
360 |
throw new MetacatSchedulerException("WorkflowScheduler.reScheduleJob - could not find workflow " |
|
361 |
+ "id when deleting job: " + jobName); |
|
362 |
|
|
352 | 363 |
} |
353 | 364 |
|
354 |
// we need to include the workflow id in the forward url |
|
355 |
String karId = null; |
|
365 |
// we need to include the workflow id in the url |
|
356 | 366 |
ScheduledJobParamDAO karJobParamDAO = jobDAO.getJobParam("karid"); |
357 |
if (karJobParamDAO != null) { |
|
358 |
karId = karJobParamDAO.getValue(); |
|
367 |
if (karJobParamDAO == null) { |
|
368 |
throw new MetacatSchedulerException("WorkflowScheduler.reScheduleJob - could not find kar " |
|
369 |
+ "id when deleting job: " + jobName); |
|
359 | 370 |
} |
360 | 371 |
|
372 |
// we need to include the workflow id in the url |
|
373 |
ScheduledJobParamDAO workflowNameJobParamDAO = jobDAO.getJobParam("workflowname"); |
|
374 |
if (workflowNameJobParamDAO == null) { |
|
375 |
throw new MetacatSchedulerException("WorkflowScheduler.reScheduleJob - could not find workflow " |
|
376 |
+ "name when deleting job: " + jobName); |
|
377 |
} |
|
378 |
|
|
361 | 379 |
String destination = "/style/skins/" + qformat + "/" + forwardto |
362 |
+ "?workflowid=" + workflowId + "&karid=" + karId; |
|
363 |
RequestUtil.forwardRequest(request, response, destination.toString()); |
|
380 |
+ "?workflowid=" + workflowIdJobParamDAO.getValue() |
|
381 |
+ "&karid=" + karJobParamDAO.getValue() |
|
382 |
+ "&workflowname=" + workflowNameJobParamDAO.getValue(); |
|
383 |
|
|
384 |
RequestUtil.forwardRequest(request, response, destination); |
|
364 | 385 |
} else { |
365 | 386 |
ResponseUtil.sendSuccessXML(response, result); |
366 | 387 |
} |
... | ... | |
383 | 404 |
*/ |
384 | 405 |
public void deleteJob(HttpServletRequest request, HttpServletResponse response, |
385 | 406 |
Hashtable<String, String[]> params, String username, String[] groups) throws MetacatSchedulerException { |
407 |
try { |
|
408 |
// workflow job id must exist |
|
409 |
String jobNames[] = params.get("workflowjobid"); |
|
410 |
if (jobNames == null || jobNames.length == 0) { |
|
411 |
throw new MetacatSchedulerException("WorkflowScheduler.deleteJob - workflowjobid field must be populated " |
|
412 |
+ "in scheduler parameters when deleting job."); |
|
413 |
} |
|
414 |
String jobName = jobNames[0]; |
|
415 |
|
|
416 |
ScheduledJobAccess jobAccess = new ScheduledJobAccess(); |
|
417 |
ScheduledJobDAO jobDAO = jobAccess.getJobByName(jobName); |
|
386 | 418 |
|
419 |
// delete the job |
|
420 |
SchedulerService schedulerService = SchedulerService.getInstance(); |
|
421 |
String result = schedulerService.deleteJob(jobDAO, username, groups); |
|
422 |
|
|
423 |
// if there is a forwardto param on the request, then send the user to the page |
|
424 |
// referenced in that param, otherwise, just send the xml back. |
|
425 |
String forwardtos[] = params.get("forwardto"); |
|
426 |
String forwardto = null; |
|
427 |
if (forwardtos != null && forwardtos.length > 0) { |
|
428 |
forwardto = forwardtos[0]; |
|
429 |
} |
|
430 |
|
|
431 |
if (forwardto != null) { |
|
432 |
String qformats[] = params.get("qformat"); |
|
433 |
String qformat = null; |
|
434 |
if (qformats != null && qformats.length > 0) { |
|
435 |
qformat = qformats[0]; |
|
436 |
} |
|
437 |
|
|
438 |
// we need to include the workflow id in the url |
|
439 |
ScheduledJobParamDAO workflowIdJobParamDAO = jobDAO.getAllJobParams().get("workflowid"); |
|
440 |
if (workflowIdJobParamDAO == null) { |
|
441 |
throw new MetacatSchedulerException("WorkflowScheduler.deleteJob - could not find workflow " |
|
442 |
+ "id when deleting job: " + jobName); |
|
443 |
|
|
444 |
} |
|
445 |
|
|
446 |
// we need to include the workflow id in the url |
|
447 |
ScheduledJobParamDAO karJobParamDAO = jobDAO.getJobParam("karid"); |
|
448 |
if (karJobParamDAO == null) { |
|
449 |
throw new MetacatSchedulerException("WorkflowScheduler.deleteJob - could not find kar " |
|
450 |
+ "id when deleting job: " + jobName); |
|
451 |
} |
|
452 |
|
|
453 |
// we need to include the workflow id in the url |
|
454 |
ScheduledJobParamDAO workflowNameJobParamDAO = jobDAO.getJobParam("workflowname"); |
|
455 |
if (workflowNameJobParamDAO == null) { |
|
456 |
throw new MetacatSchedulerException("WorkflowScheduler.deleteJob - could not find workflow " |
|
457 |
+ "name when deleting job: " + jobName); |
|
458 |
} |
|
459 |
|
|
460 |
String destination = "/style/skins/" + qformat + "/" + forwardto |
|
461 |
+ "?workflowid=" + workflowIdJobParamDAO.getValue() |
|
462 |
+ "&karid=" + karJobParamDAO.getValue() |
|
463 |
+ "&workflowname=" + workflowNameJobParamDAO.getValue(); |
|
464 |
|
|
465 |
RequestUtil.forwardRequest(request, response, destination); |
|
466 |
} else { |
|
467 |
ResponseUtil.sendSuccessXML(response, result); |
|
468 |
} |
|
469 |
|
|
470 |
} catch (AccessException ae) { |
|
471 |
throw new MetacatSchedulerException("WorkflowScheduler.deleteJob - DB access issue when deleting job : ", ae); |
|
472 |
} catch (ServiceException se) { |
|
473 |
throw new MetacatSchedulerException("WorkflowScheduler.deleteJob - Service issue deleting job", se); |
|
474 |
} catch (IOException ioe) { |
|
475 |
throw new MetacatSchedulerException("WorkflowScheduler.deleteJob - I/O issue deleting job: " + ioe.getMessage()); |
|
476 |
} catch (ServletException se) { |
|
477 |
throw new MetacatSchedulerException("WorkflowScheduler.deleteJob - Servlet issue deleting job: " + se.getMessage()); |
|
478 |
} catch (ErrorSendingErrorException esee) { |
|
479 |
throw new MetacatSchedulerException("WorkflowScheduler.deleteJob - Issue sending erro when deleting job: " + esee.getMessage()); |
|
480 |
} |
|
387 | 481 |
} |
388 | 482 |
|
389 | 483 |
/** |
Also available in: Unified diff
Add the ability to delete a scheduled workflow (move status to deleted in database)