X-Git-Url: https://gerrit.onap.org/r/gitweb?p=sdc.git;a=blobdiff_plain;f=catalog-be%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fsdc%2Fbe%2Fcomponents%2Fvalidation%2Fservice%2FServiceRoleValidator.java;h=6e10a208878185e48f3600e1d499fb426dd1f3d6;hp=10c831b9093e58ab3996d05f7c19629a5e9f3a5a;hb=438650c3a958c9176db3720204ec1ff9af94fc3a;hpb=0c47a1b7118b45eecbbb0064b635efb026173ec4 diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/service/ServiceRoleValidator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/service/ServiceRoleValidator.java index 10c831b909..6e10a20887 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/service/ServiceRoleValidator.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/service/ServiceRoleValidator.java @@ -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); } } }