private RangerExportPolicyList importRangerPoliciesPlain(String jsonRangerExportPolicyList,
                                                           String rangerPoliciesJsonFileName,
                                                           String serviceMapJsonFileName, String jsonServiceMap,
                                                           String finalUrl, RangerExportPolicyList
                                                           rangerExportPolicyList, HiveConf hiveConf) throws Exception {
    ClientResponse clientResp = null;
    StreamDataBodyPart filePartPolicies = new StreamDataBodyPart("file",
      new ByteArrayInputStream(jsonRangerExportPolicyList.getBytes(StandardCharsets.UTF_8)),
      rangerPoliciesJsonFileName);
    StreamDataBodyPart filePartServiceMap = new StreamDataBodyPart("servicesMapJson",
      new ByteArrayInputStream(jsonServiceMap.getBytes(StandardCharsets.UTF_8)), serviceMapJsonFileName);

    FormDataMultiPart formDataMultiPart = new FormDataMultiPart();
    MultiPart multipartEntity = null;
    try {
      multipartEntity = formDataMultiPart.bodyPart(filePartPolicies).bodyPart(filePartServiceMap);
      WebResource.Builder builder = getRangerResourceBuilder(finalUrl, hiveConf);
      clientResp = builder.accept(MediaType.APPLICATION_JSON).type(MediaType.MULTIPART_FORM_DATA)
        .post(ClientResponse.class, multipartEntity);
      if (clientResp != null) {
        if (clientResp.getStatus() == HttpServletResponse.SC_NO_CONTENT) {
          LOG.debug("Ranger policy import finished successfully");

        } else if (clientResp.getStatus() == HttpServletResponse.SC_UNAUTHORIZED) {
          throw new RuntimeException(ErrorMsg.RANGER_AUTHENTICATION_FAILED.getMsg());
        } else {
          throw new Exception("Ranger policy import failed, Please refer target Ranger admin logs.");
        }
      }
    } finally {
      try {
        if (filePartPolicies != null) {
          filePartPolicies.cleanup();
        }
        if (filePartServiceMap != null) {
          filePartServiceMap.cleanup();
        }
        if (formDataMultiPart != null) {
          formDataMultiPart.close();
        }
        if (multipartEntity != null) {
          multipartEntity.close();
        }
      } catch (IOException e) {
        LOG.error("Exception occurred while closing resources: {}", e);
      }
    }
    return rangerExportPolicyList;
  }
RangerRestClientImpl to connect to Ranger and export policies.
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ranger/RangerRestClientImpl.java