public Content authedGet(String id) throws N0ticeException { final OAuthRequest request = createOauthRequest(Verb.GET, urlBuilder.get(id)); oauthSignRequest(request); final Response response = request.send(); if (response.getCode() == 200) { return searchParser.parseReport(response.getBody()); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public Content updateReport(String id, String headline, String body) throws N0ticeException { OAuthRequest request = createOauthRequest(Verb.POST, apiUrl + "/" + id); addBodyParameter(request, "headline", headline); oauthSignRequest(request); Response response = request.send(); final String responseBody = response.getBody(); if (response.getCode() == 200) { return searchParser.parseReport(responseBody); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public Content postReport( String headline, Double latitude, Double longitude, String body, String link, MediaFile image, VideoAttachment video, String noticeboard, DateTime date) throws N0ticeException { OAuthRequest request = createOauthRequest(Verb.POST, apiUrl + "/report/new"); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); if (headline != null) { addStringPart(entity, "headline", headline); } if (noticeboard != null) { addStringPart(entity, "noticeboard", noticeboard); } if (latitude != null && longitude != null) { addStringPart(entity, "latitude", Double.toString(latitude)); addStringPart(entity, "longitude", Double.toString(longitude)); } populateUpdateFields(body, link, image, video, entity); if (date != null) { addStringPart(entity, "date", date.toString(ZULE_TIME_FORMAT)); } request.addHeader("Content-Type", entity.getContentType().getValue()); addMultipartEntity(request, entity); oauthSignRequest(request); Response response = request.send(); final String responseBody = response.getBody(); if (response.getCode() == 200) { return searchParser.parseReport(responseBody); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public Content postEvent( String headline, double latitude, double longitude, String body, String link, MediaFile image, VideoAttachment video, String noticeboard, LocalDateTime startDate, LocalDateTime endDate, Reoccurence reoccurence, LocalDateTime reoccursTo) throws N0ticeException { final OAuthRequest request = createOauthRequest(Verb.POST, apiUrl + "/event/new"); final MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); addEntityPartParameter(entity, "headline", headline); addEntityPartParameter(entity, "noticeboard", noticeboard); addEntityPartParameter(entity, "latitude", Double.toString(latitude)); addEntityPartParameter(entity, "longitude", Double.toString(longitude)); populateUpdateFields(body, link, image, video, entity); addEntityPartParameter(entity, "startDate", startDate.toString(LOCAL_DATE_TIME_FORMAT)); addEntityPartParameter(entity, "endDate", endDate.toString(LOCAL_DATE_TIME_FORMAT)); if (reoccurence != null && reoccursTo != null) { addEntityPartParameter(entity, "reoccurs", reoccurence.toString()); addEntityPartParameter(entity, "reoccursTo", reoccursTo.toString(LOCAL_DATE_TIME_FORMAT)); } request.addHeader("Content-Type", entity.getContentType().getValue()); addMultipartEntity(request, entity); oauthSignRequest(request); Response response = request.send(); final String responseBody = response.getBody(); if (response.getCode() == 200) { return searchParser.parseReport(responseBody); } handleExceptions(response); throw new N0ticeException(response.getBody()); }
public Content get(String id) throws N0ticeException { return searchParser.parseReport(httpFetcher.fetchContent(urlBuilder.get(id), UTF_8)); }