Replaced all tabs with spaces in java and pom.xml
[so.git] / adapters / mso-sdnc-adapter / src / main / java / org / onap / so / adapters / sdnc / sdncrest / TypedRequestTunables.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
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=========================================================
21  */
22
23 package org.onap.so.adapters.sdnc.sdncrest;
24
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;
29
30 /**
31  * Typed Request Tunables. Each entry is identified by a TYPE in the property name. Different types can have different
32  * keys.
33  * <p>
34  * General format:
35  * 
36  * <pre>
37  * org.onap.so.adapters.sdnc.TYPE.KEY1[.KEY2...]=METHOD|TIMEOUT|URL|HEADER|NAMESPACE
38  * </pre>
39  * 
40  * Currently supported type(s): service
41  * 
42  * <pre>
43  * org.onap.so.adapters.sdnc.service.SERVICE.OPERATION = METHOD | TIMEOUT | URL | HEADER | NAMESPACE
44  * </pre>
45  */
46 public class TypedRequestTunables {
47
48     private static final Logger logger = LoggerFactory.getLogger(TypedRequestTunables.class);
49
50     private String reqId;
51     private String myUrlSuffix;
52     private String key = null;
53     private String error = "";
54
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;
62
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();
74     }
75
76     public TypedRequestTunables(String reqId, String myUrlSuffix) {
77         this.reqId = reqId;
78         this.myUrlSuffix = myUrlSuffix;
79     }
80
81     /**
82      * Sets the key for a service request:
83      * 
84      * <pre>
85      * org.onap.so.adapters.sdnc.service.SERVICE.OPERATION
86      * </pre>
87      * 
88      * @param service the sdncService
89      * @param operation the sdncOperation
90      */
91     public void setServiceKey(String service, String operation) {
92         key = Constants.REQUEST_TUNABLES + ".service." + service + "." + operation;
93         logger.debug("Generated {} key: {}", getClass().getSimpleName(), key);
94     }
95
96     /**
97      * Gets the SDNC request ID.
98      */
99     public String getReqId() {
100         return reqId;
101     }
102
103     /**
104      * Gets the generated key.
105      */
106     public String getKey() {
107         return key;
108     }
109
110     /**
111      * Gets the most recent error, or null if there was no error.
112      */
113     public String getError() {
114         return error;
115     }
116
117     public String getReqMethod() {
118         return reqMethod;
119     }
120
121     public String getTimeout() {
122         return timeout;
123     }
124
125     public String getSdncUrl() {
126         return sdncUrl;
127     }
128
129     public String getHeaderName() {
130         return headerName;
131     }
132
133     public String getNamespace() {
134         return namespace;
135     }
136
137     /**
138      * Gets the SDNC adapter notification URL, trimmed of trailing '/' characters.
139      */
140     public String getMyUrl() {
141         return myUrl;
142     }
143
144     public String getMyUrlSuffix() {
145         return myUrlSuffix;
146     }
147
148     public void setKey(String key) {
149         this.key = key;
150     }
151
152     public void setError(String error) {
153         this.error = error;
154     }
155
156     public void setReqMethod(String reqMethod) {
157         this.reqMethod = reqMethod;
158     }
159
160     public void setTimeout(String timeout) {
161         this.timeout = timeout;
162     }
163
164     public void setSdncUrl(String sdncUrl) {
165         this.sdncUrl = sdncUrl;
166     }
167
168     public void setHeaderName(String headerName) {
169         this.headerName = headerName;
170     }
171
172     public void setNamespace(String namespace) {
173         this.namespace = namespace;
174     }
175
176     public void setMyUrl(String myUrl) {
177         this.myUrl = myUrl;
178     }
179
180     @Override
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();
186     }
187
188 }