/** * Indicates if the call is loggable * * @return True if the call is loggable */ public boolean isLoggable() { return getRequest() == null ? null : getRequest().isLoggable(); }
/** * Allows filtering after processing by the next Restlet. Logs the call. * * @param request * The request to handle. * @param response * The response to update. */ @Override protected void afterHandle(Request request, Response response) { try { if (request.isLoggable() && this.logLogger.isLoggable(Level.INFO)) { long startTime = (Long) request.getAttributes().get( "org.restlet.startTime"); int duration = (int) (System.currentTimeMillis() - startTime); this.logLogger.log(Level.INFO, this.logService .getResponseLogMessage(response, duration)); } } catch (Throwable e) { // Error while logging the call, cf issue #931 getLogger().log(Level.SEVERE, "Cannot log call", e); } }
/** * Attempts to parse a formatted reference. If the parsing succeeds, the * given request's attributes are updated.<br> * Note that the values parsed are directly extracted from the formatted * reference and are therefore not percent-decoded. * * @see Reference#decode(String) * * @param formattedString * The string to parse. * @param request * The request to update. * @return The number of matched characters or -1 if no character matched. */ public int parse(String formattedString, Request request) { return parse(formattedString, request.getAttributes(), request.isLoggable()); }
/** * Challenges the client by adding a challenge request to the response and * by setting the status to {@link Status#CLIENT_ERROR_UNAUTHORIZED}. * * @param response * The response to update. * @param stale * Indicates if the new challenge is due to a stale response. */ public void challenge(Response response, boolean stale) { boolean loggable = response.getRequest().isLoggable() && getLogger().isLoggable(Level.FINE); if (loggable) { getLogger().log(Level.FINE, "An authentication challenge was requested."); } response.setStatus(Status.CLIENT_ERROR_UNAUTHORIZED); response.getChallengeRequests().add(createChallengeRequest(stale)); }
if (request.isLoggable()) { getLogger().log(Level.FINE, "Permanently redirecting client to: " + targetRef); if (request.isLoggable()) { getLogger().log(Level.FINE, "Redirecting client to found location: " + targetRef); if (request.isLoggable()) { getLogger().log(Level.FINE, "Redirecting client to another location: " + targetRef); if (request.isLoggable()) { getLogger().log(Level.FINE, "Temporarily redirecting client to: " + targetRef); if (request.isLoggable()) { getLogger().log(Level.FINE, "Redirecting via client dispatcher to: " + targetRef); if (request.isLoggable()) { getLogger().log(Level.FINE, "Redirecting via server dispatcher to: " + targetRef);
/** * Allows filtering before processing by the next Restlet. Saves the start * time. * * @param request * The request to handle. * @param response * The response to update. * @return The continuation status. */ @Override protected int beforeHandle(Request request, Response response) { request.getAttributes().put("org.restlet.startTime", System.currentTimeMillis()); // Set the log level for the given request request.setLoggable(this.logService.isLoggable(request)); if (request.isLoggable() && this.logLogger.isLoggable(Level.FINE)) { this.logLogger.fine("Processing request to: \"" + ((request.getResourceRef() == null) ? "Unknown URI" : request.getResourceRef().getTargetRef() .toString()) + "\""); } return CONTINUE; }
/** * Rejects the call due to a failed authentication or authorization. This * can be overridden to change the default behavior, for example to display * an error page. By default, if authentication is required, the challenge * method is invoked, otherwise the call status is set to * CLIENT_ERROR_FORBIDDEN. * * @param response * The reject response. */ public void forbid(Response response) { boolean loggable = response.getRequest().isLoggable() && getLogger().isLoggable(Level.FINE); if (loggable) { getLogger().log( Level.FINE, "Authentication or authorization failed for this URI: " + response.getRequest().getResourceRef()); } response.setStatus(Status.CLIENT_ERROR_FORBIDDEN); }
if (request.isLoggable() && getLogger().isLoggable(Level.FINER)) { getLogger().finer("No characters were matched"); if (request.isLoggable() && getLogger().isLoggable(Level.FINER)) { getLogger().finer( "" + matchedLength + " characters were matched"); if (request.isLoggable()) { if (getLogger().isLoggable(Level.FINE)) { remainingPart = request.getResourceRef() if (request.isLoggable() && getLogger().isLoggable(Level.FINE)) { getLogger().fine( "Unable to match this pattern: "
/** * Invoked upon failed authentication. By default, it updates the request's * clientInfo and challengeResponse "authenticated" properties, and returns * {@link Filter#STOP}. * * @param request * The request sent. * @param response * The response to update. * @return The filter continuation code. */ protected int unauthenticated(Request request, Response response) { boolean loggable = request.isLoggable() && getLogger().isLoggable(Level.FINE); if (request.getChallengeResponse() != null && loggable) { getLogger().log( Level.FINE, "The authentication failed for the identifer \"" + request.getChallengeResponse().getIdentifier() + "\" using the " + request.getChallengeResponse().getScheme() + " scheme."); } // Update the client info accordingly if (request.getClientInfo() != null) { request.getClientInfo().setAuthenticated(false); } // Stop the filtering chain return STOP; }
boolean loggable = request.isLoggable() && getLogger().isLoggable(Level.FINE);
/** * Allows filtering before processing by the next Restlet. Set the base * reference. * * @param request * The request to handle. * @param response * The response to update. * @return The continuation status. */ @Override protected int beforeHandle(Request request, Response response) { if (request.getHostRef() == null) { request.getResourceRef().setBaseRef( request.getResourceRef().getHostIdentifier()); } else { request.getResourceRef().setBaseRef(request.getHostRef()); } if (request.isLoggable() && getLogger().isLoggable(Level.FINE)) { getLogger().fine( "Base URI: \"" + request.getResourceRef().getBaseRef() + "\". Remaining part: \"" + request.getResourceRef().getRemainingPart() + "\""); } return CONTINUE; }
if (request.isLoggable() && getLogger().isLoggable(Level.FINER)) { getLogger().finer( "Call score for the \"" + getTemplate().getPattern()
protected boolean authenticate(Request request, Response response) { boolean result = false; boolean loggable = request.isLoggable() && getLogger().isLoggable(Level.FINE);
if (request.isLoggable()) { logRoute(result);