FluentHttpClient.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <dependency>
  2. <groupId>org.apache.httpcomponents</groupId>
  3. <artifactId>httpcore</artifactId>
  4. <version>4.4.10</version>
  5. <scope>compile</scope>
  6. </dependency>
  7. <dependency>
  8. <groupId>org.apache.httpcomponents</groupId>
  9. <artifactId>httpclient</artifactId>
  10. <version>4.5.6</version>
  11. <scope>compile</scope>
  12. </dependency>
  13. <dependency>
  14. <groupId>org.apache.httpcomponents</groupId>
  15. <artifactId>httpmime</artifactId>
  16. <version>4.5.6</version>
  17. </dependency>
  18. <dependency>
  19. <groupId>org.apache.httpcomponents</groupId>
  20. <artifactId>fluent-hc</artifactId>
  21. <version>4.5.6</version>
  22. </dependency>
  23. String port = ConfigurationUtil.getUserConfigSingleValue("DataRelease", "Service", "Publish-Port");
  24. String drUrl = "http://" + ip + ":" + port + "/datarelease/api/dr/meta/rowpermission";
  25. try {
  26. HttpResponse httpResponse = Request.Post(drUrl)
  27. .bodyForm(Form.form().add("resApplyId", resApplyId).build())
  28. .socketTimeout(3000)
  29. .connectTimeout(3000)
  30. .execute().returnResponse();
  31. if (httpResponse.getStatusLine().getStatusCode() == 200) {
  32. return "1";
  33. } else {
  34. return "-1";
  35. }
  36. } catch (IOException e) {
  37. log.error(e.getMessage(), e);
  38. return "-1";
  39. }