From 1cf48f3c80c97813b0f18174e35ff100204c5887 Mon Sep 17 00:00:00 2001 From: mojahidi Date: Fri, 22 Dec 2017 11:03:21 +0530 Subject: Fixed sonar issues - NovaServerResourceValidator Fixed all sonar issues Change-Id: I4ee3a6fdc33a3874ce36d32296ab508ee7089468 Issue-ID: SDC-343 Signed-off-by: mojahidi --- .../heatresource/NovaServerResourceValidator.java | 51 +++++++++++++++------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src') diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java index 33d20d5714..7d8ab251b9 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.openecomp.sdc.validation.impl.validators.heatresource; import org.apache.commons.collections4.MapUtils; @@ -20,21 +36,19 @@ import org.openecomp.sdc.validation.type.HeatResourceValidationContext; import java.util.Map; -/** - * Created by TALIO on 2/22/2017. - */ public class NovaServerResourceValidator implements ResourceValidator { - private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage(); private static final ErrorMessageCode ERROR_CODE_HNS1 = new ErrorMessageCode("HNS1"); private static final ErrorMessageCode ERROR_CODE_HNS2 = new ErrorMessageCode("HNS2"); + @Override public void validate(String fileName, Map.Entry resourceEntry, GlobalValidationContext globalContext, ValidationContext validationContext) { HeatResourceValidationContext heatResourceValidationContext = (HeatResourceValidationContext) validationContext; - validateNovaServerResourceType - (fileName, resourceEntry, heatResourceValidationContext, globalContext); + validateNovaServerResourceType (fileName, + resourceEntry, heatResourceValidationContext, globalContext ); } private static void validateNovaServerResourceType(String fileName, @@ -42,14 +56,13 @@ public class NovaServerResourceValidator implements ResourceValidator { HeatResourceValidationContext heatResourceValidationContext, GlobalValidationContext globalContext) { - mdcDataDebugMessage.debugEntryMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", fileName); validateAssignedValueForImageOrFlavorFromNova(fileName, resourceEntry, globalContext); - validateAllServerGroupsPointedByServerExistAndDefined - (fileName, resourceEntry, - heatResourceValidationContext.getHeatOrchestrationTemplate(), globalContext); + validateAllServerGroupsPointedByServerExistAndDefined (fileName, + resourceEntry, heatResourceValidationContext.getHeatOrchestrationTemplate(), globalContext ); - mdcDataDebugMessage.debugExitMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", fileName); } @@ -59,7 +72,7 @@ public class NovaServerResourceValidator implements ResourceValidator { GlobalValidationContext globalContext) { - mdcDataDebugMessage.debugEntryMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", fileName); Resource resource = resourceEntry.getValue(); Map propertiesMap = resource.getProperties(); @@ -72,7 +85,7 @@ public class NovaServerResourceValidator implements ResourceValidator { LoggerErrorDescription.MISSING_NOVA_PROPERTIES); } - mdcDataDebugMessage.debugExitMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", fileName); } @SuppressWarnings("unchecked") @@ -81,7 +94,7 @@ public class NovaServerResourceValidator implements ResourceValidator { HeatOrchestrationTemplate heatOrchestrationTemplate, GlobalValidationContext globalContext) { - mdcDataDebugMessage.debugEntryMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", fileName); Map resourcesMap = heatOrchestrationTemplate.getResources(); Map resourceProperties = resourceEntry.getValue().getProperties(); @@ -93,6 +106,14 @@ public class NovaServerResourceValidator implements ResourceValidator { return; } + validateServerGroupValue(fileName, resourceEntry, globalContext, resourcesMap, schedulerHintsMap); + + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", fileName); + } + + private static void validateServerGroupValue(String fileName, Map.Entry resourceEntry, GlobalValidationContext globalContext, + Map resourcesMap, Map schedulerHintsMap) { if (schedulerHintsMap != null) { for (Object serverGroupValue : schedulerHintsMap.values()) { if (!(serverGroupValue instanceof Map)) { @@ -115,8 +136,6 @@ public class NovaServerResourceValidator implements ResourceValidator { } } } - - mdcDataDebugMessage.debugExitMessage("file", fileName); } } -- cgit 1.2.3-korg