688699092da72a16af6aee5144efa1287873be5b
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / util / AAIApiServerURLBase.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 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
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  *
20  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22 package org.onap.aai.util;
23
24 import org.onap.aai.exceptions.AAIException;
25 import org.onap.aai.introspection.Version;
26
27 public class AAIApiServerURLBase {
28         
29         /**
30          * Gets the.
31          *
32          * @return the string
33          * @throws AAIException the AAI exception
34          */
35         public static String get() throws AAIException {
36                 
37                 String hostName = null;
38 //              try {
39 //                      Message message = PhaseInterceptorChain.getCurrentMessage();
40 //                      Map<String, List<String>> headers = CastUtils.cast((Map) message.get(Message.PROTOCOL_HEADERS));
41 //                      List sa = null;
42 //                          if (headers != null) {
43 //                                  sa = headers.get("host");
44 //                              }
45 //
46 //                              if (sa != null && sa.size() == 1) {
47 //                                  hostName = "https://"+ sa.get(0).toString() + "/aai/";
48 //                              }
49 //              } catch (Exception e) {
50 //                      // TODO: we may want to log an error here
51 //              }
52                 // TODO: should this check the value a little closer and look for a pattern?
53                 if (hostName == null) { 
54                         hostName = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE);
55                         //AAIConstants.AAI_SERVER_URL_BASE;
56                 }
57                 return hostName;
58         }
59         
60         /**
61          * Gets the.
62          *
63          * @param v the v
64          * @return the string
65          * @throws AAIException the AAI exception
66          */
67         public static String get(Version v) throws AAIException {
68                 String hostName = null;
69                 hostName = AAIApiServerURLBase.get();
70                 return hostName;
71         }
72         
73 }