use of org.forgerock.http.header.AcceptApiVersionHeader in project OpenAM by OpenRock.
the class CrestProtocolEnforcementFilter method defaultProtocolVersion.
private Version defaultProtocolVersion(Request request) throws BadRequestException {
AcceptApiVersionHeader apiVersionHeader;
try {
apiVersionHeader = AcceptApiVersionHeader.valueOf(request);
} catch (IllegalArgumentException e) {
throw new BadRequestException(e);
}
apiVersionHeader.withDefaultProtocolVersion(ENFORCE_PROTOCOL_VERSION);
request.getHeaders().put(apiVersionHeader);
return apiVersionHeader.getProtocolVersion();
}
use of org.forgerock.http.header.AcceptApiVersionHeader in project OpenAM by OpenRock.
the class ResourceApiVersionRestlet method parseResourceApiVersion.
public static Version parseResourceApiVersion(Request request) {
HttpServletRequest httpRequest = ServletUtils.getRequest(request);
String versionHeader = httpRequest.getHeader(AcceptApiVersionHeader.NAME);
AcceptApiVersionHeader apiVersionHeader = AcceptApiVersionHeader.valueOf(versionHeader);
return apiVersionHeader.getResourceVersion();
}
use of org.forgerock.http.header.AcceptApiVersionHeader 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