diff options
Diffstat (limited to 'services/services-engine')
-rw-r--r-- | services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java index faa6d79b3..7cd75a300 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java @@ -32,6 +32,7 @@ import org.onap.policy.common.parameters.ParameterGroup; import org.onap.policy.common.parameters.ValidationStatus; import org.onap.policy.common.utils.resources.ResourceUtils; +// @formatter:off /** * This class holds the parameters for an Apex Engine Service with multiple engine threads running multiple engines. * @@ -54,9 +55,8 @@ import org.onap.policy.common.utils.resources.ResourceUtils; * <li>periodicEventPeriod: The period in milliseconds at which the periodic event PERIOIC_EVENT will be generated by * APEX, 0 means no periodic event generation, negative values are illegal. * </ol> - * - * @author Liam Fallon (liam.fallon@ericsson.com) */ +// @formatter:on public class EngineServiceParameters implements ParameterGroup { private static final int MAX_PORT = 65535; @@ -98,7 +98,7 @@ public class EngineServiceParameters implements ParameterGroup { */ public EngineServiceParameters() { super(); - + // Set the name for the parameters this.name = ApexParameterConstants.ENGINE_SERVICE_GROUP_NAME; } @@ -276,6 +276,24 @@ public class EngineServiceParameters implements ParameterGroup { public GroupValidationResult validate() { final GroupValidationResult result = new GroupValidationResult(this); + validateStringParameters(result); + + validateNumericParameters(result); + + if (policyModelFileName != null) { + validatePolicyModelFileName(result); + } + result.setResult("engineParameters", engineParameters.validate()); + + return result; + } + + /** + * Validate string parameters. + * + * @param result the result of string parameter validation + */ + private void validateStringParameters(final GroupValidationResult result) { if (name == null || !name.matches(AxKey.NAME_REGEXP)) { result.setResult("name", ValidationStatus.INVALID, "name is invalid, it must match regular expression" + AxKey.NAME_REGEXP); @@ -285,7 +303,14 @@ public class EngineServiceParameters implements ParameterGroup { result.setResult("version", ValidationStatus.INVALID, "version is invalid, it must match regular expression" + AxKey.VERSION_REGEXP); } + } + /** + * Validate numeric parameters. + * + * @param result the result of numeric parameter validation + */ + private void validateNumericParameters(final GroupValidationResult result) { if (id < 0) { result.setResult("id", ValidationStatus.INVALID, "id not specified or specified value [" + id + "] invalid, must be specified as id >= 0"); @@ -301,29 +326,24 @@ public class EngineServiceParameters implements ParameterGroup { + "] invalid, must be specified as 1024 <= port <= 65535"); } - if (policyModelFileName != null) { - validatePolicyModelFileName(result); - } - if (periodicEventPeriod < 0) { result.setResult("periodicEventPeriod", ValidationStatus.INVALID, "periodicEventPeriod [" + periodicEventPeriod + "] invalid, must be specified in milliseconds as >=0"); } - - return result; } /** * Validate the policy model file name parameter. + * * @param result the variable in which to store the result of the validation */ private void validatePolicyModelFileName(final GroupValidationResult result) { if (policyModelFileName.trim().length() == 0) { - result.setResult(POLICY_MODEL_FILE_NAME, ValidationStatus.INVALID, "\"" - + policyModelFileName + "\" invalid, must be specified as a non-empty string"); + result.setResult(POLICY_MODEL_FILE_NAME, ValidationStatus.INVALID, + "\"" + policyModelFileName + "\" invalid, must be specified as a non-empty string"); return; } - + // The file name can refer to a resource on the local file system or on the class // path final URL fileUrl = ResourceUtils.getUrl4Resource(policyModelFileName); |