*/
@Override
public void validate(JobParameters parameters) throws JobParametersInvalidException {
if (parameters == null) {
throw new JobParametersInvalidException("The JobParameters can not be null");
}
Set<String> keys = parameters.getParameters().keySet();
// If there are explicit optional keys then all keys must be in that
// group, or in the required group.
if (!optionalKeys.isEmpty()) {
Collection<String> missingKeys = new HashSet<String>();
for (String key : keys) {
if (!optionalKeys.contains(key) && !requiredKeys.contains(key)) {
missingKeys.add(key);
}
}
if (!missingKeys.isEmpty()) {
throw new JobParametersInvalidException(
"The JobParameters contains keys that are not explicitly optional or required: " + missingKeys);
}
}
Collection<String> missingKeys = new HashSet<String>();
for (String key : requiredKeys) {
if (!keys.contains(key)) {
missingKeys.add(key);
}
}
if (!missingKeys.isEmpty()) {
throw new JobParametersInvalidException("The JobParameters do not contain required keys: " + missingKeys);
}
}