Search in sources :

Example 1 with JobValidationException

use of org.ow2.proactive.scheduler.common.exception.JobValidationException in project scheduling by ow2-proactive.

the class DefaultModelJobValidatorServiceProvider method validateJob.

@Override
public TaskFlowJob validateJob(TaskFlowJob job) throws JobValidationException {
    ModelValidatorContext context = new ModelValidatorContext(job);
    for (JobVariable jobVariable : job.getVariables().values()) {
        checkVariableFormat(null, jobVariable, context);
        context.updateJobWithContext(job);
    }
    for (Task task : job.getTasks()) {
        context = new ModelValidatorContext(task);
        for (TaskVariable taskVariable : task.getVariables().values()) {
            checkVariableFormat(task, taskVariable, context);
            context.updateTaskWithContext(task);
        }
    }
    return job;
}
Also used : Task(org.ow2.proactive.scheduler.common.task.Task) TaskVariable(org.ow2.proactive.scheduler.common.task.TaskVariable) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 2 with JobValidationException

use of org.ow2.proactive.scheduler.common.exception.JobValidationException in project scheduling by ow2-proactive.

the class StaxJobValidatorServiceProvider method validateJob.

@Override
public File validateJob(File jobFile) throws JobValidationException {
    String findSchemaByNamespaceUsed;
    try {
        findSchemaByNamespaceUsed = findSchemaByNamespaceUsed(jobFile);
        InputStream schemaStream = this.getClass().getResourceAsStream(findSchemaByNamespaceUsed);
        ValidationUtil.validate(jobFile, schemaStream);
    } catch (Exception e) {
        // wrap all occurring exceptions as a schema exception
        throw new JobValidationException(true, e);
    }
    return jobFile;
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) JobValidationException(org.ow2.proactive.scheduler.common.exception.JobValidationException) JobValidationException(org.ow2.proactive.scheduler.common.exception.JobValidationException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) XMLStreamException(javax.xml.stream.XMLStreamException)

Example 3 with JobValidationException

use of org.ow2.proactive.scheduler.common.exception.JobValidationException in project scheduling by ow2-proactive.

the class StaxJobFactory method validate.

/*
     * Validate the given job descriptor
     */
private File validate(File file) throws VerifierConfigurationException, JobCreationException {
    Map<String, JobValidatorService> factories;
    try {
        factories = JobValidatorRegistry.getInstance().getRegisteredFactories();
    } catch (Exception e) {
        logger.error(MSG_UNABLE_TO_INSTANCIATE_JOB_VALIDATION_FACTORIES, e);
        throw new VerifierConfigurationException(MSG_UNABLE_TO_INSTANCIATE_JOB_VALIDATION_FACTORIES, e);
    }
    File updatedFile = file;
    try {
        for (JobValidatorService factory : factories.values()) {
            updatedFile = factory.validateJob(updatedFile);
        }
    } catch (JobValidationException e) {
        throw e;
    } catch (Exception e) {
        throw new JobValidationException(true, e);
    }
    return updatedFile;
}
Also used : JobValidatorService(org.ow2.proactive.scheduler.common.job.factories.spi.JobValidatorService) VerifierConfigurationException(org.iso_relax.verifier.VerifierConfigurationException) File(java.io.File) JobValidationException(org.ow2.proactive.scheduler.common.exception.JobValidationException) XMLStreamException(javax.xml.stream.XMLStreamException) JobValidationException(org.ow2.proactive.scheduler.common.exception.JobValidationException) FileNotFoundException(java.io.FileNotFoundException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) VerifierConfigurationException(org.iso_relax.verifier.VerifierConfigurationException)

Example 4 with JobValidationException

use of org.ow2.proactive.scheduler.common.exception.JobValidationException in project scheduling by ow2-proactive.

the class StaxJobFactory method validate.

/*
     * Validate the given job descriptor
     */
private TaskFlowJob validate(TaskFlowJob job) throws VerifierConfigurationException, JobCreationException {
    Map<String, JobValidatorService> factories;
    try {
        factories = JobValidatorRegistry.getInstance().getRegisteredFactories();
    } catch (Exception e) {
        throw new VerifierConfigurationException(MSG_UNABLE_TO_INSTANCIATE_JOB_VALIDATION_FACTORIES, e);
    }
    TaskFlowJob updatedJob = job;
    try {
        for (JobValidatorService factory : factories.values()) {
            updatedJob = factory.validateJob(updatedJob);
        }
    } catch (JobValidationException e) {
        throw e;
    } catch (Exception e) {
        throw new JobValidationException(e);
    }
    return updatedJob;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobValidatorService(org.ow2.proactive.scheduler.common.job.factories.spi.JobValidatorService) VerifierConfigurationException(org.iso_relax.verifier.VerifierConfigurationException) JobValidationException(org.ow2.proactive.scheduler.common.exception.JobValidationException) XMLStreamException(javax.xml.stream.XMLStreamException) JobValidationException(org.ow2.proactive.scheduler.common.exception.JobValidationException) FileNotFoundException(java.io.FileNotFoundException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) VerifierConfigurationException(org.iso_relax.verifier.VerifierConfigurationException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)3 VerifierConfigurationException (org.iso_relax.verifier.VerifierConfigurationException)2 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)2 JobValidatorService (org.ow2.proactive.scheduler.common.job.factories.spi.JobValidatorService)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)1 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)1 Task (org.ow2.proactive.scheduler.common.task.Task)1 TaskVariable (org.ow2.proactive.scheduler.common.task.TaskVariable)1