summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-26 18:30:37 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-26 18:53:29 +0100
commit3db2feb37ac427a09790fef1ba637c16c3187ed6 (patch)
tree04d4ac3f0cb845c4f3b37996aafffe02b66ce0ef /services
parentcad13bc9dbd2eaebf91fcde1a0aa03dc179f4795 (diff)
Allow custom JSON adapter specification
In order to decode and encode complex Java POJOs with GSON, type adapters must be specified. This change allows specification of GSON type adapters for decoding and encoding of JSON in apex. Issue-ID: POLICY-954 Change-Id: Ib402d4e82c4f22fa4d532c016f77fb8e7bb568d3 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'services')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java44
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);