use of org.ow2.proactive.scheduler.common.job.factories.spi.model.DefaultModelJobValidatorServiceProvider in project scheduling by ow2-proactive.
the class SchedulerFrontend method validateJobSignal.
@Override
@ImmediateService
public List<JobVariable> validateJobSignal(String jobId, String signalName, Map<String, String> updatedVariables) throws NotConnectedException, UnknownJobException, PermissionException, SignalApiException, JobValidationException {
if (updatedVariables == null || updatedVariables.isEmpty()) {
return null;
}
String currentUser = frontendState.getCurrentUser();
logger.debug("Request to validate signal " + signalName + " on job " + jobId + " received from " + currentUser);
final JobId jobIdObject = JobIdImpl.makeJobId(jobId);
frontendState.checkPermissions("addJobSignal", frontendState.getIdentifiedJob(jobIdObject), YOU_DO_NOT_HAVE_PERMISSION_TO_SEND_SIGNALS_TO_THIS_JOB);
String readyPrefix = SignalApiImpl.READY_PREFIX;
if (StringUtils.isBlank(signalName.trim())) {
throw new SignalApiException("Empty signals are not allowed");
}
try {
TaskId taskId = createFakeTaskId(jobId);
publicStore.createChannelIfAbsent(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId, true);
Signal signal = (Signal) publicStore.get(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId, readyPrefix + signalName);
if (signal != null) {
DefaultModelJobValidatorServiceProvider validatorServiceProvider = new DefaultModelJobValidatorServiceProvider();
Map<String, Serializable> serializableUpdatedVariables = new LinkedHashMap<>();
serializableUpdatedVariables.putAll(updatedVariables);
validatorServiceProvider.validateVariables(signal.getInputVariables(), serializableUpdatedVariables, this, this);
return signal.getInputVariables();
} else {
throw new SignalApiException("Signal not found");
}
} catch (InvalidChannelException e) {
throw new SignalApiException("Could not read signals channel", e);
} catch (IOException e) {
throw new SignalApiException("Could not add signalName for the job " + jobId, e);
}
}
use of org.ow2.proactive.scheduler.common.job.factories.spi.model.DefaultModelJobValidatorServiceProvider in project scheduling by ow2-proactive.
the class SchedulerFrontend method validateUpdatedVariables.
private boolean validateUpdatedVariables(Map<String, String> updatedVariables, List<JobVariable> inputVariables) throws JobValidationException {
DefaultModelJobValidatorServiceProvider validatorServiceProvider = new DefaultModelJobValidatorServiceProvider();
Map<String, Serializable> serializableUpdatedVariables = new LinkedHashMap<>(updatedVariables);
validatorServiceProvider.validateVariables(inputVariables, serializableUpdatedVariables, this, this);
return true;
}
Aggregations