Improve handling 'empty'/null string in Service fields
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / components / validation / service / ServiceRoleValidator.java
index 10c831b..6e10a20 100644 (file)
@@ -45,26 +45,22 @@ public class ServiceRoleValidator implements ServiceFieldValidator {
     @Override
     public void validateAndCorrectField(User user, Service service, AuditingActionEnum actionEnum) {
         log.debug("validate service role");
-        String serviceRole = service.getServiceRole();
-        if (serviceRole != null) {
-            validateServiceRole(serviceRole);
-        }
+        validateServiceRole(service.getServiceRole());
     }
 
     private void validateServiceRole(String serviceRole) {
         if (StringUtils.isEmpty(serviceRole)) {
             return;
-        } else {
-            if (!ValidationUtils.validateServiceRoleLength(serviceRole)) {
-                log.info("service role exceeds limit.");
-                ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.PROPERTY_EXCEEDS_LIMIT, "" + SERVICE_ROLE);
-                throw new ByResponseFormatComponentException(errorResponse);
-            }
-            if (!ValidationUtils.validateServiceMetadata(serviceRole)) {
-                log.info("service role is not valid.");
-                ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERY, "" + SERVICE_ROLE);
-                throw new ByResponseFormatComponentException(errorResponse);
-            }
+        }
+        if (!ValidationUtils.validateServiceRoleLength(serviceRole)) {
+            log.info("service role exceeds limit.");
+            ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.PROPERTY_EXCEEDS_LIMIT, "" + SERVICE_ROLE);
+            throw new ByResponseFormatComponentException(errorResponse);
+        }
+        if (!ValidationUtils.validateServiceMetadata(serviceRole)) {
+            log.info("service role is not valid.");
+            ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERY, "" + SERVICE_ROLE);
+            throw new ByResponseFormatComponentException(errorResponse);
         }
     }
 }