+ /* Method sets RequestIs and InvocationId for se in EELF logs
+ * @Method - setIpAndFqdnForEelf
+ * @Params - Req, Request used to get RequestId and InvocationId
+ */
+ public static void setRequestIdAndInvocationId(HttpServletRequest req) {
+ String reqId = req.getHeader("X-ONAP-RequestID");
+ if (StringUtils.isBlank(reqId)) {
+ reqId = UUID.randomUUID().toString();
+ }
+ MDC.put(MDC_KEY_REQUEST_ID, reqId);
+ String invId = req.getHeader("X-InvocationID");
+ if (StringUtils.isBlank(invId)) {
+ invId = UUID.randomUUID().toString();
+ }
+ MDC.put("InvocationId", invId);
+ }
+
+ public static void sendResponseError(HttpServletResponse response, int errorCode, Logger intlogger) {
+ try {
+ response.sendError(errorCode);
+ } catch (IOException ioe) {
+ intlogger.error("IOException" + ioe.getMessage());
+ }
+ }
+
+ /**
+ * Method to check to see if file is of type gzip
+ *
+ * @param file The name of the file to be checked
+ * @return True if the file is of type gzip
+ */
+ public static boolean isFiletypeGzip(File file){
+ try(FileInputStream fileInputStream = new FileInputStream(file);
+ GZIPInputStream gzip = new GZIPInputStream(fileInputStream)) {
+
+ return true;
+ }catch (IOException e){
+ nodeUtilsLogger.error("NODE0403 " + file.toString() + " Not in gzip(gz) format: " + e.toString() + e);
+ return false;
+ }
+ }
+