* of all of node groups then. And merge the failed info which have been
* producted by validation between cluster level and node group level.
*/
private ValidateResult validateConfiguration(ClusterCreate cluster,
ValidationType validationType) {
ValidateResult validateResult = new ValidateResult();
// validate cluster level Configuration
ValidateResult vr = null;
if (cluster.getConfiguration() != null
&& !cluster.getConfiguration().isEmpty()) {
vr =
AppConfigValidationUtils.validateConfig(validationType,
cluster.getConfiguration());
if (vr.getType() != ValidateResult.Type.VALID) {
validateResult.setType(vr.getType());
if (!vr.getFailureNames().isEmpty()) {
validateResult.setFailureNames(vr.getFailureNames());
}
if (!vr.getFailureValues().isEmpty()) {
validateResult.setFailureValues(vr.getFailureValues());
}
if (!vr.getNoExistFileNames().isEmpty()) {
validateResult.setNoExistFileNames(vr.getNoExistFileNames());
}
}
}
List<String> failureNames = new ArrayList<String>();
Map<String, List<String>> noExistingFileNamesMap =
new HashMap<String, List<String>>();
List<String> failureValues = new ArrayList<String>();
if (!validateResult.getFailureNames().isEmpty()) {
failureNames.addAll(validateResult.getFailureNames());
}
if (!validateResult.getNoExistFileNames().isEmpty()) {
noExistingFileNamesMap.putAll(validateResult.getNoExistFileNames());
}
if (!validateResult.getFailureValues().isEmpty()) {
failureValues.addAll(validateResult.getFailureValues());
}
// validate nodegroup level Configuration
for (NodeGroupCreate nodeGroup : cluster.getNodeGroups()) {
if (nodeGroup.getConfiguration() != null
&& !nodeGroup.getConfiguration().isEmpty()) {
vr =
AppConfigValidationUtils.validateConfig(validationType,
nodeGroup.getConfiguration());
if (vr.getType() != ValidateResult.Type.VALID) {
//invalid value will take higher priority than invalid name as it will throw failure
if (validateResult.getType() != ValidateResult.Type.WHITE_LIST_INVALID_VALUE) {
validateResult.setType(vr.getType());
}
// merge failed names between cluster level and node group level.
for (String failureName : vr.getFailureNames()) {
if (!failureNames.contains(failureName)) {
failureNames.add(failureName);
}
}
// merge failed names between cluster level and node group level.
for (String failureValue : vr.getFailureValues()) {
if (!failureValues.contains(failureValue)) {
failureValues.add(failureValue);
}
}
// merge no existing file names between cluster level and node
// group level
for (Entry<String, List<String>> noExistingFileNames : vr
.getNoExistFileNames().entrySet()) {
String configType = noExistingFileNames.getKey();
if (noExistingFileNamesMap.containsKey(configType)) {
List<String> noExistingFilesTemp =
noExistingFileNames.getValue();