[VID-6] Initial rebase push
[vid.git] / vid-app-common / src / main / java / org / openecomp / vid / mso / MsoRestInt.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.mso;\r
22 \r
23 import java.text.DateFormat;\r
24 import java.text.SimpleDateFormat;\r
25 import java.util.Date;\r
26 \r
27 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
28 import com.fasterxml.jackson.databind.ObjectMapper;\r
29 \r
30 /**\r
31  * The Class MsoRestInt.\r
32  */\r
33 public class MsoRestInt {\r
34         \r
35         /** The logger. */\r
36         EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestInterface.class);\r
37         \r
38         /** The Constant dateFormat. */\r
39         final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");\r
40         \r
41         /** The request date format. */\r
42         public DateFormat requestDateFormat = new SimpleDateFormat("EEE, dd MMM YYYY HH:mm:ss z");\r
43         \r
44         /**\r
45          * Instantiates a new mso rest int.\r
46          */\r
47         public MsoRestInt() {\r
48                 requestDateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));\r
49         }\r
50         \r
51         /**\r
52          * Log request.\r
53          *\r
54          * @param r the r\r
55          */\r
56         public void logRequest ( org.openecomp.vid.mso.rest.RequestDetails r ) {\r
57         String methodName = "logRequest";\r
58             ObjectMapper mapper = new ObjectMapper();\r
59             String r_json_str = "";\r
60             if ( r != null ) {\r
61                 r_json_str = r.toString();\r
62                     try {\r
63                         r_json_str = mapper.writeValueAsString(r);\r
64                     }\r
65                     catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {\r
66                         logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " +  methodName + " Unable to parse request as json");\r
67                     }\r
68             }\r
69             logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " +  methodName + " Request=(" + r_json_str + ")");  \r
70     }\r
71 }\r