2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2019-2020 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.plugins.event.carrier.restrequestor;
24 import java.util.regex.Matcher;
29 import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters;
30 import org.onap.policy.common.parameters.GroupValidationResult;
31 import org.onap.policy.common.parameters.ValidationStatus;
35 * Apex parameters for REST as an event carrier technology with Apex issuing a REST request and receiving a REST
38 * <p>The parameters for this plugin are:
40 * <li>url: The URL that the Apex Rest Requestor will connect to over REST for REST request sending.
41 * This parameter is mandatory.
42 * <li>httpMethod: The HTTP method to use when making requests over REST, legal values are GET (default),
43 * POST, PUT, and DELETE.
44 * <li>httpHeaders, the HTTP headers to send on REST requests, optional parameter, defaults to none.
45 * <li>httpCodeFilter: a regular expression filter for returned HTTP codes, if the returned HTTP code passes this
46 * filter, then the request is assumed to have succeeded by the plugin, optional, defaults to allowing 2xx codes
47 * through, that is a regular expression of "[2][0-9][0-9]"
50 * @author Liam Fallon (liam.fallon@ericsson.com)
55 public class RestRequestorCarrierTechnologyParameters extends RestPluginCarrierTechnologyParameters {
57 /** The default HTTP method for request events. */
58 public static final HttpMethod DEFAULT_REQUESTOR_HTTP_METHOD = HttpMethod.GET;
60 /** The default timeout for REST requests. */
61 public static final long DEFAULT_REST_REQUEST_TIMEOUT = 500;
64 * Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
67 public RestRequestorCarrierTechnologyParameters() {
70 // Set the carrier technology properties for the REST requestor carrier technology
71 this.setLabel("RESTREQUESTOR");
72 this.setEventProducerPluginClass(ApexRestRequestorProducer.class.getName());
73 this.setEventConsumerPluginClass(ApexRestRequestorConsumer.class.getName());
81 * http://www.blah.com/{par1/somethingelse (Missing end tag) use {[^\\{}]*$
82 * http://www.blah.com/{par1/{some}thingelse (Nested tag) use {[^}]*{
83 * http://www.blah.com/{par1}/some}thingelse (Missing start tag1) use }[^{}]*.}
84 * http://www.blah.com/par1}/somethingelse (Missing start tag2) use }[^{}]*}
85 * http://www.blah.com/{}/somethingelse (Empty tag) use {[\s]*}
86 * @param result the result of the validation
90 public GroupValidationResult validateUrl(final GroupValidationResult result) {
91 // URL is only set on Requestor consumers
92 if (getUrl() == null) {
96 Matcher matcher = patternErrorKey.matcher(getUrl());
98 result.setResult("url", ValidationStatus.INVALID,
99 "no proper URL has been set for event sending on REST requestor");