2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.plugins.event.carrier.restclient;
23 import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
24 import org.onap.policy.common.parameters.GroupValidationResult;
25 import org.onap.policy.common.parameters.ValidationStatus;
28 * Apex parameters for REST as an event carrier technology with Apex as a REST client.
30 * <p>The parameters for this plugin are:
32 * <li>url: The URL that the Apex Rest client will connect to over REST for event reception or event sending. This
33 * parameter is mandatory.
34 * <li>httpMethod: The HTTP method to use when sending events over REST, legal values are POST (default) and PUT. When
35 * receiving events, the REST client plugin always uses the HTTP GET method.
38 * @author Joss Armstrong (joss.armstrong@ericsson.com)
40 public class RestClientCarrierTechnologyParameters extends CarrierTechnologyParameters {
42 /** The label of this carrier technology. */
43 public static final String RESTCLIENT_CARRIER_TECHNOLOGY_LABEL = "RESTCLIENT";
45 /** The producer plugin class for the REST carrier technology. */
46 public static final String RESTCLIENT_EVENT_PRODUCER_PLUGIN_CLASS = ApexRestClientProducer.class.getCanonicalName();
48 /** The consumer plugin class for the REST carrier technology. */
49 public static final String RESTCLIENT_EVENT_CONSUMER_PLUGIN_CLASS = ApexRestClientConsumer.class.getCanonicalName();
51 /** The default HTTP method for output of events. */
52 public static final String DEFAULT_PRODUCER_HTTP_METHOD = "POST";
54 /** The HTTP method for input of events. */
55 public static final String CONSUMER_HTTP_METHOD = "GET";
57 private String url = null;
58 private String httpMethod = null;
61 * Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
64 public RestClientCarrierTechnologyParameters() {
67 // Set the carrier technology properties for the web socket carrier technology
68 this.setLabel(RESTCLIENT_CARRIER_TECHNOLOGY_LABEL);
69 this.setEventProducerPluginClass(RESTCLIENT_EVENT_PRODUCER_PLUGIN_CLASS);
70 this.setEventConsumerPluginClass(RESTCLIENT_EVENT_CONSUMER_PLUGIN_CLASS);
75 * Gets the URL for the REST request.
79 public String getUrl() {
84 * Sets the URL for the REST request.
86 * @param incomingUrl the URL
88 public void setUrl(final String incomingUrl) {
89 this.url = incomingUrl;
93 * Gets the HTTP method to use for the REST request.
95 * @return the HTTP method
97 public String getHttpMethod() {
102 * Sets the HTTP method to use for the REST request.
104 * @param httpMethod the HTTP method
106 public void setHttpMethod(final String httpMethod) {
107 this.httpMethod = httpMethod;
113 * @see java.lang.Object#toString()
116 public String toString() {
117 return "RESTClientCarrierTechnologyParameters [url=" + url + ", httpMethod=" + httpMethod + "]";
122 * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
125 public GroupValidationResult validate() {
126 final GroupValidationResult result = super.validate();
128 // Check if the URL has been set for event output
129 if (getUrl() == null) {
130 result.setResult("url", ValidationStatus.INVALID, "no URL has been set for event sending on REST client");