2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.sdnc.sdncrest;
23 import org.apache.commons.lang3.builder.ToStringBuilder;
24 import org.onap.so.adapters.sdnc.impl.Constants;
25 import org.onap.so.logger.MsoLogger;
28 * Typed Request Tunables. Each entry is identified by a TYPE in the property name.
29 * Different types can have different keys.
33 * org.onap.so.adapters.sdnc.TYPE.KEY1[.KEY2...]=METHOD|TIMEOUT|URL|HEADER|NAMESPACE
35 * Currently supported type(s): service
37 * org.onap.so.adapters.sdnc.service.SERVICE.OPERATION=METHOD|TIMEOUT|URL|HEADER|NAMESPACE
40 public class TypedRequestTunables {
42 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, TypedRequestTunables.class);
45 private String myUrlSuffix;
46 private String key = null;
47 private String error = "";
49 // tunables (all are required)
50 private String reqMethod = null;
51 private String timeout = null;
52 private String sdncUrl = null;
53 private String headerName = null;
54 private String namespace = null;
55 private String myUrl = null;
57 public TypedRequestTunables(TypedRequestTunables reqTunableOriginal) {
58 this.reqId = reqTunableOriginal.getReqId();
59 this.myUrlSuffix = reqTunableOriginal.getMyUrlSuffix();
60 this.key = reqTunableOriginal.getKey();
61 this.error = reqTunableOriginal.getError();
62 this.reqMethod = reqTunableOriginal.getReqMethod();
63 this.timeout = reqTunableOriginal.getTimeout();
64 this.sdncUrl = reqTunableOriginal.getSdncUrl();
65 this.headerName = reqTunableOriginal.getHeaderName();
66 this.namespace = reqTunableOriginal.getNamespace();
67 this.myUrl = reqTunableOriginal.getMyUrl();
70 public TypedRequestTunables(String reqId, String myUrlSuffix) {
72 this.myUrlSuffix = myUrlSuffix;
76 * Sets the key for a service request:
78 * org.onap.so.adapters.sdnc.service.SERVICE.OPERATION
80 * @param service the sdncService
81 * @param operation the sdncOperation
83 public void setServiceKey(String service, String operation) {
84 key = Constants.REQUEST_TUNABLES + ".service." + service + "." + operation;
85 LOGGER.debug("Generated " + getClass().getSimpleName() + " key: " + key);
89 * Gets the SDNC request ID.
91 public String getReqId() {
96 * Gets the generated key.
98 public String getKey() {
103 * Gets the most recent error, or null if there was no error.
105 public String getError() {
109 public String getReqMethod() {
113 public String getTimeout() {
117 public String getSdncUrl() {
121 public String getHeaderName() {
125 public String getNamespace() {
130 * Gets the SDNC adapter notification URL, trimmed of trailing '/' characters.
132 public String getMyUrl() {
136 public String getMyUrlSuffix() {
140 public void setKey(String key) {
144 public void setError(String error) {
148 public void setReqMethod(String reqMethod) {
149 this.reqMethod = reqMethod;
152 public void setTimeout(String timeout) {
153 this.timeout = timeout;
156 public void setSdncUrl(String sdncUrl) {
157 this.sdncUrl = sdncUrl;
160 public void setHeaderName(String headerName) {
161 this.headerName = headerName;
164 public void setNamespace(String namespace) {
165 this.namespace = namespace;
168 public void setMyUrl(String myUrl) {
173 public String toString() {
174 return new ToStringBuilder(this).append("reqId", reqId).append("myUrlSuffix", myUrlSuffix).append("key", key)
175 .append("error", error).append("reqMethod", reqMethod).append("timeout", timeout)
176 .append("sdncUrl", sdncUrl).append("headerName", headerName).append("namespace", namespace)
177 .append("myUrl", myUrl).toString();