Improve handling 'empty'/null string in Service fields
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / components / validation / service / ServiceTypeValidator.java
index 2b592d8..d847a9a 100644 (file)
  */
 package org.openecomp.sdc.be.components.validation.service;
 
+import org.apache.commons.lang3.StringUtils;
 import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
-import org.openecomp.sdc.be.impl.ComponentsUtils;
 import org.openecomp.sdc.be.model.Service;
 import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
@@ -34,25 +34,15 @@ public class ServiceTypeValidator implements ServiceFieldValidator {
 
     private static final Logger log = Logger.getLogger(ServiceTypeValidator.class.getName());
     private static final String SERVICE_TYPE = JsonPresentationFields.SERVICE_TYPE.getPresentation();
-    private ComponentsUtils componentsUtils;
-
-    public ServiceTypeValidator(ComponentsUtils componentsUtils) {
-        this.componentsUtils = componentsUtils;
-    }
 
     @Override
     public void validateAndCorrectField(User user, Service service, AuditingActionEnum actionEnum) {
         log.debug("validate service type");
-        String serviceType = service.getServiceType();
-        if (serviceType == null) {
-            log.info("service type is not valid.");
-            throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY, "" + SERVICE_TYPE);
-        }
-        validateServiceType(serviceType);
+        validateServiceType(service.getServiceType());
     }
 
     private void validateServiceType(String serviceType) {
-        if (serviceType.isEmpty()) {
+        if (StringUtils.isEmpty(serviceType)) {
             return;
         }
         if (!ValidationUtils.validateServiceTypeLength(serviceType)) {