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;
27 import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters;
28 import org.onap.policy.common.parameters.GroupValidationResult;
29 import org.onap.policy.common.parameters.ValidationStatus;
33 * Apex parameters for REST as an event carrier technology with Apex issuing a REST request and receiving a REST
36 * <p>The parameters for this plugin are:
38 * <li>url: The URL that the Apex Rest Requestor will connect to over REST for REST request sending.
39 * This parameter is mandatory.
40 * <li>httpMethod: The HTTP method to use when making requests over REST, legal values are GET (default),
41 * POST, PUT, and DELETE.
42 * <li>httpHeaders, the HTTP headers to send on REST requests, optional parameter, defaults to none.
43 * <li>httpCodeFilter: a regular expression filter for returned HTTP codes, if the returned HTTP code passes this
44 * filter, then the request is assumed to have succeeded by the plugin, optional, defaults to allowing 2xx codes
45 * through, that is a regular expression of "[2][0-9][0-9]"
48 * @author Liam Fallon (liam.fallon@ericsson.com)
53 public class RestRequestorCarrierTechnologyParameters extends RestPluginCarrierTechnologyParameters {
55 /** The default HTTP method for request events. */
56 public static final HttpMethod DEFAULT_REQUESTOR_HTTP_METHOD = HttpMethod.GET;
58 /** The default timeout for REST requests. */
59 public static final long DEFAULT_REST_REQUEST_TIMEOUT = 500;
62 * Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
65 public RestRequestorCarrierTechnologyParameters() {
68 // Set the carrier technology properties for the REST requestor carrier technology
69 this.setLabel("RESTREQUESTOR");
70 this.setEventProducerPluginClass(ApexRestRequestorProducer.class.getName());
71 this.setEventConsumerPluginClass(ApexRestRequestorConsumer.class.getName());
79 * http://www.blah.com/{par1/somethingelse (Missing end tag) use {[^\\{}]*$
80 * http://www.blah.com/{par1/{some}thingelse (Nested tag) use {[^}]*{
81 * http://www.blah.com/{par1}/some}thingelse (Missing start tag1) use }[^{}]*.}
82 * http://www.blah.com/par1}/somethingelse (Missing start tag2) use }[^{}]*}
83 * http://www.blah.com/{}/somethingelse (Empty tag) use {[\s]*}
84 * @param result the result of the validation
88 public GroupValidationResult validateUrl(final GroupValidationResult result) {
89 // URL is only set on Requestor consumers
90 if (getUrl() == null) {
94 Matcher matcher = patternErrorKey.matcher(getUrl());
96 result.setResult("url", ValidationStatus.INVALID,
97 "no proper URL has been set for event sending on REST requestor");