* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.components.validation.service;
import org.apache.commons.lang3.StringUtils;
public ServiceNamingPolicyValidator(ComponentsUtils componentsUtils) {
this.componentsUtils = componentsUtils;
}
+
@Override
public void validateAndCorrectField(User user, Service service, AuditingActionEnum actionEnum) {
Boolean isEcompGeneratedCurr = service.isEcompGeneratedNaming();
throw new ByActionStatusComponentException(ActionStatus.MISSING_ECOMP_GENERATED_NAMING);
}
if (isEcompGeneratedCurr) {
- if (!ValidationUtils.validateServiceNamingPolicyLength(namingPolicyUpdate)) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.NAMING_POLICY_EXCEEDS_LIMIT, "" + ValidationUtils.SERVICE_NAMING_POLICY_MAX_SIZE);
- throw new ByResponseFormatComponentException(responseFormat);
- }
if (StringUtils.isEmpty(namingPolicyUpdate)) {
- service.setNamingPolicy("");
return;
}
+ if (!ValidationUtils.validateServiceNamingPolicyLength(namingPolicyUpdate)) {
+ ResponseFormat responseFormat = componentsUtils
+ .getResponseFormat(ActionStatus.NAMING_POLICY_EXCEEDS_LIMIT, "" + ValidationUtils.SERVICE_NAMING_POLICY_MAX_SIZE);
+ throw new ByResponseFormatComponentException(responseFormat);
+ }
if (!ValidationUtils.validateCommentPattern(namingPolicyUpdate)) {
throw new ByActionStatusComponentException(ActionStatus.INVALID_NAMING_POLICY);
}
- service.setNamingPolicy(namingPolicyUpdate);
} else {
- if (!StringUtils.isEmpty(namingPolicyUpdate)) {
+ if (StringUtils.isNotEmpty(namingPolicyUpdate)) {
log.warn("NamingPolicy must be empty for EcompGeneratedNaming=false");
}
service.setNamingPolicy("");