use of org.forgerock.http.protocol.Request in project OpenAM by OpenRock.
the class LogWriter method sendEvent.
private static void sendEvent(String topic, JsonValue eventJson, String sessionId, String baseUrl) throws HttpApplicationException, URISyntaxException {
Client client = new Client(new HttpClientHandler());
Request request = new Request();
request.setMethod("POST");
if (eventJson.isDefined(EVENT_REALM)) {
String realm = eventJson.get(EVENT_REALM).asString();
baseUrl = baseUrl + "/json/realm-audit" + (realm.endsWith("/") ? realm : realm + "/");
} else {
baseUrl = baseUrl + "/json/global-audit/";
}
request.setUri(baseUrl + topic + "?_action=create");
request.getHeaders().add(SystemProperties.get("com.iplanet.am.cookie.name"), sessionId);
request.getHeaders().add(new AcceptApiVersionHeader(version(1), version(1)));
request.getEntity().setJson(eventJson.getObject());
client.send(request).then(WARN_OF_FAILURES_FUNCTION);
}
Aggregations