Advertisement
Guest User

GarciaPL

a guest
Mar 14th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. @Override
  2.     public void sendResults(Integer serviceId, Integer stageId, List results) throws UnirestException, XStreamException {
  3.         List results = new ArrayList();
  4.         for (Entrant entrant : results) {
  5.             ResultDTO record = new ResultDTO();
  6.             record.setDateCreated(new Date());
  7.             results.add(record);
  8.         }
  9.  
  10.         String xml = xStream.toXML(results);
  11.  
  12.         HttpResponse response = Unirest.post("http://server.com/" + "send-drawing-results" +
  13.                 "/" + serviceId + "/" + stageId).basicAuth("login", "password").
  14.                 header("Content-Type", "application/xml").body(xml).asString();
  15.  
  16.         if (response.getStatus() == 403) {
  17.             throw new UnirestException("No authorized");
  18.         }
  19.  
  20.         if (response.getStatus() != 204) {
  21.             throw new UnirestException("Unexpected response with code " + response.getStatus());
  22.         }
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement