public user getUser() throws IOException, URISyntaxException { URI uri = new URI("http://api.huddle.dev/" + "entry/"); HttpGet httpget = new HttpGet(uri); httpget.addHeader("Authorization", "OAuth2 " + tokenClient.getAccessToken()); HttpResponse response = httpClient.execute(httpget); user user; user = xml.parseXmlUser(response.getEntity().getContent()); return user; }
@Override public folder getFolders(URI uri) throws IOException { HttpGet httpget = new HttpGet(uri); httpget.addHeader("Authorization", "OAuth2 " + tokenClient.getAccessToken()); HttpResponse response = httpClient.execute(httpget); folder folder; folder = xml.parseXmlFolder(response.getEntity().getContent()); return folder; }
@Override public document createFile(URI uri, String name, String desc) throws IOException { HttpPost httpPost = new HttpPost(uri); httpPost.addHeader("Authorization", "OAuth2 " + tokenClient.getAccessToken()); httpPost.addHeader("Content-Type", "application/vnd.huddle.data+xml"); // set the body to post StringEntity entity = new StringEntity( "<document title=" + "\"" + name + "\"" + " description=" + "\"" + desc + "\"" + "/>"); httpPost.setEntity(entity); HttpResponse response = httpClient.execute(httpPost); document document = xml.parseXmlDocuments(response.getEntity().getContent()); return document; }