use of org.forgerock.json.resource.AdviceWarning in project OpenAM by OpenRock.
the class ResourceApiVersionRoutingFilter method handle.
void handle(Request request, Response response, RestletRouter next) {
ApiVersionRouterContext apiVersionRouterContext = createApiVersionRouterContext(new RootContext());
next.handle(apiVersionRouterContext, request, response);
if (apiVersionRouterContext.getResourceVersion() != null) {
addContentAPIVersion(response, enforcedProtocolVersion, apiVersionRouterContext.getResourceVersion());
// If warnings are wanted, and we haven't thrown an exception by this point let's see what we can do...
if (behaviourManager.isWarningEnabled()) {
Version requestedVersion = parseResourceApiVersion(request);
if (requestedVersion == null) {
// If no version specified at all, we can warn about that
AdviceWarning warningHeader = AdviceWarning.newAdviceWarning(AGENT_NAME, "No " + AcceptApiVersionHeader.NAME + " specified");
ServletUtils.getResponse(response).addHeader("Warning", warningHeader.toString());
}
}
}
}
Aggregations