Example usage for org.springframework.batch.core.launch NoSuchJobExecutionException NoSuchJobExecutionException

List of usage examples for org.springframework.batch.core.launch NoSuchJobExecutionException NoSuchJobExecutionException

Introduction

In this page you can find the example usage for org.springframework.batch.core.launch NoSuchJobExecutionException NoSuchJobExecutionException.

Prototype

public NoSuchJobExecutionException(String msg) 

Source Link

Document

Create an exception with the given message.

Usage

From source file:com.xchanging.support.batch.admin.service.SimpleJobService.java

public Collection<StepExecution> getStepExecutions(Long jobExecutionId) throws NoSuchJobExecutionException {

    JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId);
    if (jobExecution == null) {
        throw new NoSuchJobExecutionException("No JobExecution with id=" + jobExecutionId);
    }// ww  w .  jav a2 s  .co  m

    stepExecutionDao.addStepExecutions(jobExecution);

    String jobName = jobExecution.getJobInstance() == null ? null : jobExecution.getJobInstance().getJobName();
    Collection<String> missingStepNames = new LinkedHashSet<String>();

    if (jobName != null) {
        missingStepNames.addAll(stepExecutionDao.findStepNamesForJobExecution(jobName, "*:partition*"));
        logger.debug("Found step executions in repository: " + missingStepNames);
    }

    Job job = null;
    try {
        job = jobLocator.getJob(jobName);
    } catch (NoSuchJobException e) {
        // expected
    }
    if (job instanceof StepLocator) {
        Collection<String> stepNames = ((StepLocator) job).getStepNames();
        missingStepNames.addAll(stepNames);
        logger.debug("Added step executions from job: " + missingStepNames);
    }

    for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
        String stepName = stepExecution.getStepName();
        if (missingStepNames.contains(stepName)) {
            missingStepNames.remove(stepName);
        }
        logger.debug("Removed step executions from job execution: " + missingStepNames);
    }

    for (String stepName : missingStepNames) {
        StepExecution stepExecution = jobExecution.createStepExecution(stepName);
        stepExecution.setStatus(BatchStatus.UNKNOWN);
    }

    return jobExecution.getStepExecutions();

}

From source file:admin.service.SimpleJobService.java

@Override
public Collection<StepExecution> getStepExecutions(Long jobExecutionId) throws NoSuchJobExecutionException {

    JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId);
    if (jobExecution == null) {
        throw new NoSuchJobExecutionException("No JobExecution with id=" + jobExecutionId);
    }/*  w  w w  . j  a  v a 2 s.c o  m*/

    stepExecutionDao.addStepExecutions(jobExecution);

    String jobName = jobExecution.getJobInstance() == null
            ? jobInstanceDao.getJobInstance(jobExecution).getJobName()
            : jobExecution.getJobInstance().getJobName();
    Collection<String> missingStepNames = new LinkedHashSet<String>();

    if (jobName != null) {
        missingStepNames.addAll(stepExecutionDao.findStepNamesForJobExecution(jobName, "*:partition*"));
        logger.debug("Found step executions in repository: " + missingStepNames);
    }

    Job job = null;
    try {
        job = jobLocator.getJob(jobName);
    } catch (NoSuchJobException e) {
        // expected
    }
    if (job instanceof StepLocator) {
        Collection<String> stepNames = ((StepLocator) job).getStepNames();
        missingStepNames.addAll(stepNames);
        logger.debug("Added step executions from job: " + missingStepNames);
    }

    for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
        String stepName = stepExecution.getStepName();
        if (missingStepNames.contains(stepName)) {
            missingStepNames.remove(stepName);
        }
        logger.debug("Removed step executions from job execution: " + missingStepNames);
    }

    for (String stepName : missingStepNames) {
        StepExecution stepExecution = jobExecution.createStepExecution(stepName);
        stepExecution.setStatus(BatchStatus.UNKNOWN);
    }

    return jobExecution.getStepExecutions();

}

From source file:de.codecentric.batch.web.JobMonitoringController.java

@RequestMapping(value = "/jobs/executions/{executionId}", method = RequestMethod.GET)
public JobExecution findExecution(@PathVariable long executionId) throws NoSuchJobExecutionException {
    JobExecution jobExecution = jobExplorer.getJobExecution(executionId);
    if (jobExecution == null) {
        throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found.");
    }/*from w  w  w. j av a  2 s .  com*/
    return jobExecution;
}

From source file:com.xchanging.support.batch.admin.service.SimpleJobService.java

public JobExecution getJobExecution(Long jobExecutionId) throws NoSuchJobExecutionException {
    JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId);
    if (jobExecution == null) {
        throw new NoSuchJobExecutionException("There is no JobExecution with id=" + jobExecutionId);
    }/*from w  ww .  jav a  2 s  . c o m*/
    jobExecution.setJobInstance(jobInstanceDao.getJobInstance(jobExecution));
    try {
        jobExecution.setExecutionContext(executionContextDao.getExecutionContext(jobExecution));
    } catch (Exception e) {
        logger.info("Cannot load execution context for job execution: " + jobExecution);
    }
    stepExecutionDao.addStepExecutions(jobExecution);
    return jobExecution;
}

From source file:de.codecentric.batch.web.JobOperationsController.java

@RequestMapping(value = "/jobs/executions/{executionId}", method = RequestMethod.GET)
public String getStatus(@PathVariable long executionId) throws NoSuchJobExecutionException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Get ExitCode for JobExecution with id: " + executionId + ".");
    }/*from  ww  w .  j av  a  2  s.  com*/
    JobExecution jobExecution = jobExplorer.getJobExecution(executionId);
    if (jobExecution != null) {
        return jobExecution.getExitStatus().getExitCode();
    } else {
        throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found.");
    }
}

From source file:admin.service.SimpleJobService.java

@Override
public JobExecution getJobExecution(Long jobExecutionId) throws NoSuchJobExecutionException {
    JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId);
    if (jobExecution == null) {
        throw new NoSuchJobExecutionException("There is no JobExecution with id=" + jobExecutionId);
    }/*from  ww  w.j  a v a  2  s  . co m*/
    jobExecution.setJobInstance(jobInstanceDao.getJobInstance(jobExecution));
    try {
        jobExecution.setExecutionContext(executionContextDao.getExecutionContext(jobExecution));
    } catch (Exception e) {
        logger.info("Cannot load execution context for job execution: " + jobExecution);
    }
    stepExecutionDao.addStepExecutions(jobExecution);
    return jobExecution;
}

From source file:de.codecentric.batch.web.JobOperationsController.java

@RequestMapping(value = "/jobs/executions/{executionId}/log", method = RequestMethod.GET)
public void getLogFile(HttpServletResponse response, @PathVariable long executionId)
        throws NoSuchJobExecutionException, IOException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Get log file for job with executionId: " + executionId);
    }//from ww w  .  ja  v a2s .c  o  m
    String loggingPath = createLoggingPath();
    JobExecution jobExecution = jobExplorer.getJobExecution(executionId);
    if (jobExecution == null) {
        throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found.");
    }
    File downloadFile = new File(loggingPath + jobLogFileNameCreator.getName(jobExecution));
    InputStream is = new FileInputStream(downloadFile);
    FileCopyUtils.copy(is, response.getOutputStream());
    response.flushBuffer();
}

From source file:org.springframework.batch.core.launch.support.SimpleJobOperator.java

private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException {
    JobExecution jobExecution = jobExplorer.getJobExecution(executionId);

    if (jobExecution == null) {
        throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]");
    }/*from w  w  w  . j  a  v a  2  s.c o m*/
    return jobExecution;

}