diff options
author | Jim Hahn <jrh3@att.com> | 2021-04-27 15:08:59 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-04-29 14:49:33 -0400 |
commit | a05cc62b6426d31c23f60dbe4a6f367331431ea4 (patch) | |
tree | bb38e4b81c133004ab9541c15db030750957f5f3 /plugins/reception-plugins/src/main | |
parent | adfc3ee02f3194a143bcea430e5e3aeb99a23206 (diff) |
Remove GroupValidationResult
Removed GroupValidationResult, replacing it with BeanValidationResult.
Modified the ParameterGroup subclasses to use BeanValidator, adding
annotations where needed to trigger the validations that had been
automatically performed by GroupValidationResult.
Issue-ID: POLICY-2059
Change-Id: Ib5c0dc0ac3762e68307e63f5ce29efb49208e55d
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'plugins/reception-plugins/src/main')
-rw-r--r-- | plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java index 9c596f76..44e89c07 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Intel. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +25,10 @@ package org.onap.policy.distribution.reception.handling.file; import java.io.File; import lombok.Getter; import lombok.Setter; -import org.onap.policy.common.parameters.GroupValidationResult; +import org.onap.policy.common.parameters.BeanValidationResult; +import org.onap.policy.common.parameters.BeanValidator; +import org.onap.policy.common.parameters.ObjectValidationResult; +import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.parameters.ValidationStatus; import org.onap.policy.common.parameters.annotations.NotBlank; import org.onap.policy.common.parameters.annotations.NotNull; @@ -51,9 +55,9 @@ public class FileSystemReceptionHandlerConfigurationParameterGroup extends Recep * {@inheritDoc}. */ @Override - public GroupValidationResult validate() { - final GroupValidationResult validationResult = new GroupValidationResult(this); - validatePathElement(validationResult, watchPath, "watchPath"); + public BeanValidationResult validate() { + final BeanValidationResult validationResult = new BeanValidator().validateTop(getClass().getSimpleName(), this); + validationResult.addResult(validatePathElement(watchPath, "watchPath")); return validationResult; } @@ -61,23 +65,17 @@ public class FileSystemReceptionHandlerConfigurationParameterGroup extends Recep /** * Validate the string element. * - * @param validationResult the result object * @param element the element to validate * @param elementName the element name for error message */ - private void validatePathElement(final GroupValidationResult validationResult, final String element, - final String elementName) { - boolean valid = false; + private ValidationResult validatePathElement(final String element, final String elementName) { if (element != null) { final File file = new File(element); if (file.exists() && file.isDirectory()) { - valid = true; + return null; } } - if (!valid) { - validationResult.setResult(elementName, ValidationStatus.INVALID, - elementName + " must be a valid directory"); - } + + return new ObjectValidationResult(elementName, element, ValidationStatus.INVALID, "is not a valid directory"); } } - |