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;
26 * Apex parameters for REST as an event carrier technology with Apex as a REST client.
28 * The parameters for this plugin are:
30 * <li>url: The URL that the Apex Rest client will connect to over REST for event reception or event sending. This
31 * parameter is mandatory.
32 * <li>httpMethod: The HTTP method to use when sending events over REST, legal values are POST (default) and PUT. When
33 * receiving events, the REST client plugin always uses the HTTP GET method.
36 * @author Joss Armstrong (joss.armstrong@ericsson.com)
38 public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyParameters {
40 /** The label of this carrier technology. */
41 public static final String RESTCLIENT_CARRIER_TECHNOLOGY_LABEL = "RESTCLIENT";
43 /** The producer plugin class for the REST carrier technology. */
44 public static final String RESTCLIENT_EVENT_PRODUCER_PLUGIN_CLASS = ApexRestClientProducer.class.getCanonicalName();
46 /** The consumer plugin class for the REST carrier technology. */
47 public static final String RESTCLIENT_EVENT_CONSUMER_PLUGIN_CLASS = ApexRestClientConsumer.class.getCanonicalName();
49 /** The default HTTP method for output of events. */
50 public static final String DEFAULT_PRODUCER_HTTP_METHOD = "POST";
52 /** The HTTP method for input of events. */
53 public static final String CONSUMER_HTTP_METHOD = "GET";
55 private String url = null;
56 private String httpMethod = null;
59 * Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
62 public RESTClientCarrierTechnologyParameters() {
63 super(RESTClientCarrierTechnologyParameters.class.getCanonicalName());
65 // Set the carrier technology properties for the web socket carrier technology
66 this.setLabel(RESTCLIENT_CARRIER_TECHNOLOGY_LABEL);
67 this.setEventProducerPluginClass(RESTCLIENT_EVENT_PRODUCER_PLUGIN_CLASS);
68 this.setEventConsumerPluginClass(RESTCLIENT_EVENT_CONSUMER_PLUGIN_CLASS);
73 * Gets the URL for the REST request.
77 public String getURL() {
82 * Sets the URL for the REST request.
84 * @param incomingURL the URL
86 public void setURL(final String incomingURL) {
87 this.url = incomingURL;
91 * Gets the HTTP method to use for the REST request.
93 * @return the HTTP method
95 public String getHttpMethod() {
100 * Sets the HTTP method to use for the REST request.
102 * @param httpMethod the HTTP method
104 public void setHttpMethod(final String httpMethod) {
105 this.httpMethod = httpMethod;
111 * @see java.lang.Object#toString()
114 public String toString() {
115 return "RESTClientCarrierTechnologyParameters [url=" + url + ", httpMethod=" + httpMethod + "]";
121 * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
124 public String validate() {
125 final StringBuilder errorMessageBuilder = new StringBuilder();
127 // Check if the URL has been set for event output
128 if (getURL() == null) {
129 errorMessageBuilder.append(" no URL has been set for event sending on REST client");
132 return errorMessageBuilder.toString();