[VID-6] Initial rebase push
[vid.git] / vid-app-common / src / main / java / org / openecomp / vid / client / HttpBasicClient.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * VID\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 package org.openecomp.vid.client;\r
22 \r
23 \r
24 import java.text.DateFormat;\r
25 import java.text.SimpleDateFormat;\r
26 \r
27 import javax.servlet.ServletContext;\r
28 import javax.ws.rs.client.Client;\r
29 import javax.ws.rs.client.ClientBuilder;\r
30 \r
31 import org.glassfish.jersey.client.ClientConfig;\r
32 import org.glassfish.jersey.client.ClientProperties;\r
33 import org.springframework.beans.factory.annotation.Autowired;\r
34 \r
35 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
36 \r
37 /**\r
38  *  General HTTP client.\r
39  */\r
40 \r
41 public class HttpBasicClient{\r
42         \r
43         /** The servlet context. */\r
44         @Autowired \r
45         private ServletContext servletContext;\r
46         \r
47         /** The logger. */\r
48         EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HttpBasicClient.class);\r
49         \r
50         /** The Constant dateFormat. */\r
51         final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");\r
52         \r
53         /**\r
54          * Obtain a basic HTTP client .\r
55          *\r
56          * @return Client client object\r
57          * @throws Exception the exception\r
58          */\r
59         public static Client getClient() throws Exception {\r
60                 \r
61                 ClientConfig config = new ClientConfig();\r
62                 config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);\r
63                 \r
64                 return ClientBuilder.newClient(config)\r
65                                 .register(org.openecomp.aai.util.CustomJacksonJaxBJsonProvider.class);\r
66         }       \r
67 }  \r