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. Different types can have different
37 * org.onap.so.adapters.sdnc.TYPE.KEY1[.KEY2...]=METHOD|TIMEOUT|URL|HEADER|NAMESPACE
40 * Currently supported type(s): service
43 * org.onap.so.adapters.sdnc.service.SERVICE.OPERATION = METHOD | TIMEOUT | URL | HEADER | NAMESPACE
46 public class TypedRequestTunables {
48 private static final Logger logger = LoggerFactory.getLogger(TypedRequestTunables.class);
51 private String myUrlSuffix;
52 private String key = null;
53 private String error = "";
55 // tunables (all are required)
56 private String reqMethod = null;
57 private String timeout = null;
58 private String sdncUrl = null;
59 private String headerName = null;
60 private String namespace = null;
61 private String myUrl = null;
63 public TypedRequestTunables(TypedRequestTunables reqTunableOriginal) {
64 this.reqId = reqTunableOriginal.getReqId();
65 this.myUrlSuffix = reqTunableOriginal.getMyUrlSuffix();
66 this.key = reqTunableOriginal.getKey();
67 this.error = reqTunableOriginal.getError();
68 this.reqMethod = reqTunableOriginal.getReqMethod();
69 this.timeout = reqTunableOriginal.getTimeout();
70 this.sdncUrl = reqTunableOriginal.getSdncUrl();
71 this.headerName = reqTunableOriginal.getHeaderName();
72 this.namespace = reqTunableOriginal.getNamespace();
73 this.myUrl = reqTunableOriginal.getMyUrl();
76 public TypedRequestTunables(String reqId, String myUrlSuffix) {
78 this.myUrlSuffix = myUrlSuffix;
82 * Sets the key for a service request:
85 * org.onap.so.adapters.sdnc.service.SERVICE.OPERATION
88 * @param service the sdncService
89 * @param operation the sdncOperation
91 public void setServiceKey(String service, String operation) {
92 key = Constants.REQUEST_TUNABLES + ".service." + service + "." + operation;
93 logger.debug("Generated {} key: {}", getClass().getSimpleName(), key);
97 * Gets the SDNC request ID.
99 public String getReqId() {
104 * Gets the generated key.
106 public String getKey() {
111 * Gets the most recent error, or null if there was no error.
113 public String getError() {
117 public String getReqMethod() {
121 public String getTimeout() {
125 public String getSdncUrl() {
129 public String getHeaderName() {
133 public String getNamespace() {
138 * Gets the SDNC adapter notification URL, trimmed of trailing '/' characters.
140 public String getMyUrl() {
144 public String getMyUrlSuffix() {
148 public void setKey(String key) {
152 public void setError(String error) {
156 public void setReqMethod(String reqMethod) {
157 this.reqMethod = reqMethod;
160 public void setTimeout(String timeout) {
161 this.timeout = timeout;
164 public void setSdncUrl(String sdncUrl) {
165 this.sdncUrl = sdncUrl;
168 public void setHeaderName(String headerName) {
169 this.headerName = headerName;
172 public void setNamespace(String namespace) {
173 this.namespace = namespace;
176 public void setMyUrl(String myUrl) {
181 public String toString() {
182 return new ToStringBuilder(this).append("reqId", reqId).append("myUrlSuffix", myUrlSuffix).append("key", key)
183 .append("error", error).append("reqMethod", reqMethod).append("timeout", timeout)
184 .append("sdncUrl", sdncUrl).append("headerName", headerName).append("namespace", namespace)
185 .append("myUrl", myUrl).toString();