2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.adapters.sdnc.sdncrest;
25 import org.apache.commons.lang3.builder.ToStringBuilder;
26 import org.onap.so.adapters.sdnc.impl.Constants;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * Typed Request Tunables. Each entry is identified by a TYPE in the property name.
32 * Different types can have different keys.
36 * org.onap.so.adapters.sdnc.TYPE.KEY1[.KEY2...]=METHOD|TIMEOUT|URL|HEADER|NAMESPACE
38 * Currently supported type(s): service
40 * org.onap.so.adapters.sdnc.service.SERVICE.OPERATION=METHOD|TIMEOUT|URL|HEADER|NAMESPACE
43 public class TypedRequestTunables {
45 private static final Logger logger = LoggerFactory.getLogger(TypedRequestTunables.class);
48 private String myUrlSuffix;
49 private String key = null;
50 private String error = "";
52 // tunables (all are required)
53 private String reqMethod = null;
54 private String timeout = null;
55 private String sdncUrl = null;
56 private String headerName = null;
57 private String namespace = null;
58 private String myUrl = null;
60 public TypedRequestTunables(TypedRequestTunables reqTunableOriginal) {
61 this.reqId = reqTunableOriginal.getReqId();
62 this.myUrlSuffix = reqTunableOriginal.getMyUrlSuffix();
63 this.key = reqTunableOriginal.getKey();
64 this.error = reqTunableOriginal.getError();
65 this.reqMethod = reqTunableOriginal.getReqMethod();
66 this.timeout = reqTunableOriginal.getTimeout();
67 this.sdncUrl = reqTunableOriginal.getSdncUrl();
68 this.headerName = reqTunableOriginal.getHeaderName();
69 this.namespace = reqTunableOriginal.getNamespace();
70 this.myUrl = reqTunableOriginal.getMyUrl();
73 public TypedRequestTunables(String reqId, String myUrlSuffix) {
75 this.myUrlSuffix = myUrlSuffix;
79 * Sets the key for a service request:
81 * org.onap.so.adapters.sdnc.service.SERVICE.OPERATION
83 * @param service the sdncService
84 * @param operation the sdncOperation
86 public void setServiceKey(String service, String operation) {
87 key = Constants.REQUEST_TUNABLES + ".service." + service + "." + operation;
88 logger.debug("Generated {} key: {}", getClass().getSimpleName(), key);
92 * Gets the SDNC request ID.
94 public String getReqId() {
99 * Gets the generated key.
101 public String getKey() {
106 * Gets the most recent error, or null if there was no error.
108 public String getError() {
112 public String getReqMethod() {
116 public String getTimeout() {
120 public String getSdncUrl() {
124 public String getHeaderName() {
128 public String getNamespace() {
133 * Gets the SDNC adapter notification URL, trimmed of trailing '/' characters.
135 public String getMyUrl() {
139 public String getMyUrlSuffix() {
143 public void setKey(String key) {
147 public void setError(String error) {
151 public void setReqMethod(String reqMethod) {
152 this.reqMethod = reqMethod;
155 public void setTimeout(String timeout) {
156 this.timeout = timeout;
159 public void setSdncUrl(String sdncUrl) {
160 this.sdncUrl = sdncUrl;
163 public void setHeaderName(String headerName) {
164 this.headerName = headerName;
167 public void setNamespace(String namespace) {
168 this.namespace = namespace;
171 public void setMyUrl(String myUrl) {
176 public String toString() {
177 return new ToStringBuilder(this).append("reqId", reqId).append("myUrlSuffix", myUrlSuffix).append("key", key)
178 .append("error", error).append("reqMethod", reqMethod).append("timeout", timeout)
179 .append("sdncUrl", sdncUrl).append("headerName", headerName).append("namespace", namespace)
180 .append("myUrl", myUrl).toString();