diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-08-30 09:37:29 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@ericsson.com> | 2018-08-31 19:23:41 +0100 |
commit | f32508381ce0b555fc14978cbaa458aa4e2d91c5 (patch) | |
tree | 1cab66e5372b6467f288ae1351ce836e4eba2d03 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver | |
parent | 052038c7a7e0b385462b3b653b7d06094d472df3 (diff) |
Use parameter service in apex
Switch parameter handling in apex to use
the ONAP PF common parameter service
Change-Id: Id318d19c726b18b1a69c630fa81ca7d695355e9c
Issue-ID: POLICY-954
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver')
-rw-r--r-- | plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java index 47e31fffa..cd7f388f2 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java @@ -21,6 +21,8 @@ package org.onap.policy.apex.plugins.event.carrier.restserver; import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters; +import org.onap.policy.common.parameters.GroupValidationResult; +import org.onap.policy.common.parameters.ValidationStatus; /** * Apex parameters for REST as an event carrier technology with Apex as a REST client. @@ -63,7 +65,7 @@ public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyPara * service. */ public RESTServerCarrierTechnologyParameters() { - super(RESTServerCarrierTechnologyParameters.class.getCanonicalName()); + super(); // Set the carrier technology properties for the web socket carrier technology this.setLabel(RESTSERVER_CARRIER_TECHNOLOGY_LABEL); @@ -105,32 +107,30 @@ public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyPara * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate() */ @Override - public String validate() { - final StringBuilder errorMessageBuilder = new StringBuilder(); - - errorMessageBuilder.append(super.validate()); + public GroupValidationResult validate() { + final GroupValidationResult result = super.validate(); // Check if host is defined, it is only defined on REST server consumers if (standalone) { - if (host != null) { - if (host.trim().length() == 0) { - errorMessageBuilder.append(" host not specified, must be host as a string\n"); - } + if (host != null && host.trim().length() == 0) { + result.setResult("host", ValidationStatus.INVALID, + "host not specified, host must be specified as a string"); } // Check if port is defined, it is only defined on REST server consumers - if (port != -1) { - if (port < MIN_USER_PORT || port > MAX_USER_PORT) { - errorMessageBuilder - .append(" port [" + port + "] invalid, must be specified as 1024 <= port <= 6535\n"); - } + if (port != -1 && port < MIN_USER_PORT || port > MAX_USER_PORT) { + result.setResult("port", ValidationStatus.INVALID, + "[" + port + "] invalid, must be specified as 1024 <= port <= 65535"); } } else { - if (host != null || port != -1) { - errorMessageBuilder.append(" host and port are specified only in standalone mode\n"); + if (host != null) { + result.setResult("host", ValidationStatus.INVALID, "host is specified only in standalone mode"); + } + if (port != -1) { + result.setResult("port", ValidationStatus.INVALID, "port is specified only in standalone mode"); } } - return errorMessageBuilder.toString(); + return result; } } |