public String preprocess(Message m, UriInfo u) { handleExtensionMappings(m, u); handleLanguageMappings(m, u); MultivaluedMap<String, String> queries = u.getQueryParameters(); handleTypeQuery(m, queries); handleCType(m, queries); handleMethod(m, queries, new HttpHeadersImpl(m)); return new UriInfoImpl(m, null).getPath(); }
private void handleLanguageMappings(Message m, UriInfo uriInfo) { if (languageMappings.isEmpty()) { return; } PathSegmentImpl ps = new PathSegmentImpl(uriInfo.getPath(false), false); String path = ps.getPath(); for (Map.Entry<?, ?> entry : languageMappings.entrySet()) { if (path.endsWith("." + entry.getKey())) { updateAcceptLanguageHeader(m, entry.getValue().toString()); updatePath(m, path, entry.getKey().toString(), ps.getMatrixString()); break; } } }
private void handleTypeQuery(Message m, MultivaluedMap<String, String> queries) { String type = queries.getFirst(ACCEPT_QUERY); if (type != null) { if (MEDIA_TYPE_SHORTCUTS.containsKey(type)) { type = MEDIA_TYPE_SHORTCUTS.get(type); } updateAcceptTypeHeader(m, type); } }
private void handleExtensionMappings(Message m, UriInfo uriInfo) { if (extensionMappings.isEmpty()) { return; } PathSegmentImpl ps = new PathSegmentImpl(uriInfo.getPath(false), false); String path = ps.getPath(); for (Map.Entry<?, ?> entry : extensionMappings.entrySet()) { String key = entry.getKey().toString(); if (path.endsWith("." + key)) { updateAcceptTypeHeader(m, entry.getValue().toString()); updatePath(m, path, key, ps.getMatrixString()); if ("wadl".equals(key)) { // the path has been updated and Accept was not necessarily set to // WADL type (xml or json or html - other options) String query = (String)m.get(Message.QUERY_STRING); if (StringUtils.isEmpty(query)) { query = WadlGenerator.WADL_QUERY; } else if (!query.contains(WadlGenerator.WADL_QUERY)) { query += "&" + WadlGenerator.WADL_QUERY; } m.put(Message.QUERY_STRING, query); } break; } } }
new RequestPreprocessor(languageMappings, extensionMappings)); ep.put(Bus.class.getName(), getBus()); if (documentLocation != null) {
rp.preprocess(message, new UriInfoImpl(message, null));
private void handleExtensionMappings(Message m, UriInfo uriInfo) { if (extensionMappings.isEmpty()) { return; } PathSegmentImpl ps = new PathSegmentImpl(uriInfo.getPath(false), false); String path = ps.getPath(); if (PATHS_TO_SKIP.contains(path)) { return; } for (Map.Entry<?, ?> entry : extensionMappings.entrySet()) { String key = entry.getKey().toString(); if (path.endsWith("." + key)) { updateAcceptTypeHeader(m, entry.getValue().toString()); updatePath(m, path, key, ps.getMatrixString()); if ("wadl".equals(key)) { // the path has been updated and Accept was not necessarily set to // WADL type (xml or json or html - other options) String query = (String)m.get(Message.QUERY_STRING); if (StringUtils.isEmpty(query)) { query = "_wadl"; } else if (!query.contains("_wadl")) { query += "&_wadl"; } m.put(Message.QUERY_STRING, query); } break; } } }
factory.setApplicationProvider(appProvider); factory.setRequestPreprocessor( new RequestPreprocessor(languageMappings, extensionMappings)); ep.put(Bus.class.getName(), getBus()); if (documentLocation != null) {
rp.preprocess(message, new UriInfoImpl(message, null)); if (message.getExchange().get(Response.class) != null) { return;
public String preprocess(Message m, UriInfo u) { handleExtensionMappings(m, u); handleLanguageMappings(m, u); MultivaluedMap<String, String> queries = u.getQueryParameters(); handleTypeQuery(m, queries); handleCType(m, queries); handleMethod(m, queries, new HttpHeadersImpl(m)); Response r = checkMetadataRequest(m, u); if (r != null) { m.getExchange().put(Response.class, r); } return new UriInfoImpl(m, null).getPath(); }
private void handleLanguageMappings(Message m, UriInfo uriInfo) { if (languageMappings.isEmpty()) { return; } PathSegmentImpl ps = new PathSegmentImpl(uriInfo.getPath(false), false); String path = ps.getPath(); for (Map.Entry<?, ?> entry : languageMappings.entrySet()) { if (path.endsWith("." + entry.getKey())) { updateAcceptLanguageHeader(m, entry.getValue().toString()); updatePath(m, path, entry.getKey().toString(), ps.getMatrixString()); break; } } }
private void handleTypeQuery(Message m, MultivaluedMap<String, String> queries) { String type = queries.getFirst(ACCEPT_QUERY); if (type != null) { if (SHORTCUTS.containsKey(type)) { type = SHORTCUTS.get(type); } updateAcceptTypeHeader(m, type); } }