Filter preferencesFilter = new Filter(getContext()) { protected int beforeHandle(Request request, Response response) { if (request.getClientInfo().getAcceptedMediaTypes().isEmpty()) { request.getClientInfo().accept(MediaType.APPLICATION_JSON); } else if ((request.getClientInfo().getAcceptedMediaTypes().size() == 1) && (request.getClientInfo().getAcceptedMediaTypes().get(0).getMetadata().equals(MediaType.ALL))) { request.getClientInfo().accept(MediaType.APPLICATION_JSON); } return super.beforeHandle(request, response); } }
/** * Returns the client-specific information. * * @return The client-specific information. */ @Override public ClientInfo getClientInfo() { return getWrappedRequest().getClientInfo(); }
@Override public String getCountedValue(Request request) { return request.getClientInfo().getUpstreamAddress(); }
@Override public String getCountedValue(Request request) { return request.getClientInfo().getUpstreamAddress(); }
@Override public String getCountedValue(Request request) { return request.getClientInfo().getUpstreamAddress(); }
@Override public String getCountedValue(Request request) { return request.getClientInfo().getUpstreamAddress(); }
@Override public String getCountedValue(Request request) { if (request.getClientInfo().getUser() != null) { return request.getClientInfo().getUser().getIdentifier(); } // Otherwise, use the IP address. return request.getClientInfo().getUpstreamAddress(); }
@Override public String getCountedValue(Request request) { if (request.getClientInfo().getUser() != null) { return request.getClientInfo().getUser().getIdentifier(); } // Otherwise, use the IP address. return request.getClientInfo().getUpstreamAddress(); }
@Override public String getCountedValue(Request request) { if (request.getClientInfo().getUser() != null) { return request.getClientInfo().getUser().getIdentifier(); } // Otherwise, use the IP address. return request.getClientInfo().getUpstreamAddress(); }
@Override public String getCountedValue(Request request) { if (request.getClientInfo().getUser() != null) { return request.getClientInfo().getUser().getIdentifier(); } // Otherwise, use the IP address. return request.getClientInfo().getUpstreamAddress(); }
@Override public String getCountedValue(Request request) { if (request.getClientInfo().getUser() != null) { return request.getClientInfo().getUser().getIdentifier(); } // Otherwise, use the IP address. return request.getClientInfo().getUpstreamAddress(); }
/** * Returns the enriched list of language preferences. * * @return The enriched list of language preferences. */ protected List<Preference<Language>> getLanguagePrefs() { return getRequest().getClientInfo().getAcceptedLanguages(); }
/** * Returns the enriched list of media type preferences. * * @return The enriched list of media type preferences. */ protected List<Preference<MediaType>> getMediaTypePrefs() { return getRequest().getClientInfo().getAcceptedMediaTypes(); }
/** * Returns the enriched list of character set preferences. * * @return The enriched list of character set preferences. */ protected List<Preference<CharacterSet>> getCharacterSetPrefs() { return getRequest().getClientInfo().getAcceptedCharacterSets(); }
/** * Returns the enriched list of encoding preferences. * * @return The enriched list of encoding preferences. */ protected List<Preference<Encoding>> getEncodingPrefs() { return getRequest().getClientInfo().getAcceptedEncodings(); }
@Override public void handle(Request request, Response response) { String entity = "Method : " + request.getMethod() + "\nResource URI : " + request.getResourceRef() + "\nIP address : " + request.getClientInfo().getAddress() + "\nAgent name : " + request.getClientInfo().getAgentName() + "\nAgent version: " + request.getClientInfo().getAgentVersion(); response.setEntity(entity, MediaType.TEXT_PLAIN); }
@Override public void handle(Request request, Response response) { String entity = "Method : " + request.getMethod() + "\nResource URI : " + request.getResourceRef() + "\nIP address : " + request.getClientInfo().getAddress() + "\nAgent name : " + request.getClientInfo().getAgentName() + "\nAgent version: " + request.getClientInfo().getAgentVersion(); response.setEntity(entity, MediaType.TEXT_PLAIN); }
/** * Returns the client-specific information. Creates a new instance if no one * has been set. * * @return The client-specific information. * @see Request#getClientInfo() */ public ClientInfo getClientInfo() { return getRequest() == null ? null : getRequest().getClientInfo(); }
@Override public void handle(Request request, Response response) { String entity = "Method : " + request.getMethod() + "\nResource URI : " + request.getResourceRef() + "\nIP address : " + request.getClientInfo().getAddress() + "\nAgent name : " + request.getClientInfo().getAgentName() + "\nAgent version: " + request.getClientInfo().getAgentVersion(); response.setEntity(entity, MediaType.TEXT_PLAIN); } };
@Get public Representation getIndexPageHtml(final Representation entity) throws ResourceException { this.checkAuthentication(BaseOasActions.WHOAMI_CHECK); Representation result = null; if(this.getRequest().getClientInfo().isAuthenticated()) { result = new StringRepresentation(this.getRequest().getClientInfo().getUser().getIdentifier()); } return result; }