class RestfulUtil {

    public RestfulResponse send(String msbUrl, String methodType, String content, Map<String, String> requestHeader) {
        // String msbUrl = getMsbHost() + url;
        logger.debug("Begin to sent message " + methodType + ": " + msbUrl);

        HttpRequestBase method = null;
        HttpResponse httpResponse = null;

        try {
            int timeout = DEFAULT_TIME_OUT;

            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout)
                    .setConnectionRequestTimeout(timeout).build();

            HttpClient client = HttpClientBuilder.create().build();

            if ("POST".equalsIgnoreCase(methodType)) {
                HttpPost httpPost = new HttpPost(msbUrl);
                httpPost.setConfig(requestConfig);
                for (String key : requestHeader.keySet()) {
                    httpPost.setHeader(key, requestHeader.get(key));
                }
                httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
                method = httpPost;
            } else if ("PUT".equalsIgnoreCase(methodType)) {
                HttpPut httpPut = new HttpPut(msbUrl);
                httpPut.setConfig(requestConfig);
                httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
                method = httpPut;
            } else if ("GET".equalsIgnoreCase(methodType)) {
                HttpGet httpGet = new HttpGet(msbUrl);
                httpGet.setConfig(requestConfig);
                method = httpGet;
            } else if ("DELETE".equalsIgnoreCase(methodType)) {
                HttpDelete httpDelete = new HttpDelete(msbUrl);
                httpDelete.setConfig(requestConfig);
                method = httpDelete;
            }

            // now VFC have no auth
            // String userCredentials =
            // SDNCAdapterProperties.getEncryptedProperty(Constants.SDNC_AUTH_PROP,
            // Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY);
            // String authorization = "Basic " +
            // DatatypeConverter.printBase64Binary(userCredentials.getBytes());
            // method.setHeader("Authorization", authorization);

            httpResponse = client.execute(method);
            Map<String, String> responseHeader = new HashMap<>();
            String responseContent = null;
            if (httpResponse.getEntity() != null) {
                responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
                Header[] httpResponseAllHeaders = httpResponse.getAllHeaders();
                for (Header header : httpResponseAllHeaders) {
                    responseHeader.put(header.getName(), header.getValue());

                }
            }

            int statusCode = httpResponse.getStatusLine().getStatusCode();
            String statusMessage = httpResponse.getStatusLine().getReasonPhrase();

            logger.debug("VFC Response: {} {}", statusCode,
                    statusMessage + (responseContent == null ? "" : System.lineSeparator() + responseContent));

            if (httpResponse.getStatusLine().getStatusCode() >= 300) {
                String errMsg = "VFC returned " + statusCode + " " + statusMessage;
                logError(errMsg);
                return createResponse(statusCode, errMsg);
            }

            httpResponse = null;

            if (null != method) {
                method.reset();
            } else {
                logger.debug("method is NULL:");
            }

            method = null;
            return createResponse(statusCode, responseContent, responseHeader);

        } catch (SocketTimeoutException | ConnectTimeoutException e) {
            String errMsg = "Request to VFC timed out";
            logError(errMsg, e);
            return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg);

        } catch (Exception e) {
            String errMsg = "Error processing request to VFC";
            logError(errMsg, e);
            return createResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, errMsg);

        } finally {
            if (httpResponse != null) {
                try {
                    EntityUtils.consume(httpResponse.getEntity());
                } catch (Exception e) {
                    logger.debug("Exception :", e);
                }
            }

            if (method != null) {
                try {
                    method.reset();
                } catch (Exception e) {
                    logger.debug("Exception :", e);
                }
            }
        }
    }

    private  RestfulUtil();

}