public static void updatePath(Message m, String path) { String baseAddress = getBaseAddress(m); boolean pathSlash = path.startsWith("/"); boolean baseSlash = baseAddress.endsWith("/"); if (pathSlash && baseSlash) { path = path.substring(1); } else if (!pathSlash && !baseSlash) { path = "/" + path; } m.put(Message.REQUEST_URI, baseAddress + path); m.remove(REQUEST_PATH_TO_MATCH); m.remove(REQUEST_PATH_TO_MATCH_SLASH); }
public static void updatePath(Message m, String path) { String baseAddress = getBaseAddress(m); boolean pathSlash = path.startsWith("/"); boolean baseSlash = baseAddress.endsWith("/"); if (pathSlash && baseSlash) { path = path.substring(1); } else if (!pathSlash && !baseSlash) { path = "/" + path; } m.put(Message.REQUEST_URI, baseAddress + path); m.remove(REQUEST_PATH_TO_MATCH); m.remove(REQUEST_PATH_TO_MATCH_SLASH); }
public static String getPathToMatch(Message m, boolean addSlash) { String var = addSlash ? REQUEST_PATH_TO_MATCH_SLASH : REQUEST_PATH_TO_MATCH; String pathToMatch = (String)m.get(var); if (pathToMatch != null) { return pathToMatch; } String requestAddress = getProtocolHeader(m, Message.REQUEST_URI, "/"); if (m.get(Message.QUERY_STRING) == null) { int index = requestAddress.lastIndexOf('?'); if (index > 0 && index < requestAddress.length()) { m.put(Message.QUERY_STRING, requestAddress.substring(index + 1)); requestAddress = requestAddress.substring(0, index); } } String baseAddress = getBaseAddress(m); pathToMatch = getPathToMatch(requestAddress, baseAddress, addSlash); m.put(var, pathToMatch); return pathToMatch; }
public Response checkMetadataRequest(Message m, UriInfo ui) { String originalRequestURI = (String)m.get(Message.REQUEST_URI); String query = (String)m.get(Message.QUERY_STRING); if (query != null && query.contains(WadlGenerator.WADL_QUERY)) { String requestURI = getValueWithoutSlash(originalRequestURI); String baseAddress = getValueWithoutSlash(HttpUtils.getBaseAddress(m)); if (baseAddress.equals(requestURI)) { return handleMetadataRequest(m); } } else if (originalRequestURI != null && (originalRequestURI.endsWith(SCHEMA_EXTENSION) || originalRequestURI.endsWith(WADL_EXTENSION))) { // trying WADLGenerator which may be caching schema resources won't // interfere with custom schema handlers if any return handleMetadataRequest(m); } return null; }
public static String getPathToMatch(Message m, boolean addSlash) { String var = addSlash ? REQUEST_PATH_TO_MATCH_SLASH : REQUEST_PATH_TO_MATCH; String pathToMatch = (String)m.get(var); if (pathToMatch != null) { return pathToMatch; } String requestAddress = getProtocolHeader(m, Message.REQUEST_URI, "/"); if (m.get(Message.QUERY_STRING) == null) { int index = requestAddress.lastIndexOf('?'); if (index > 0 && index < requestAddress.length()) { m.put(Message.QUERY_STRING, requestAddress.substring(index + 1)); requestAddress = requestAddress.substring(0, index); } } String baseAddress = getBaseAddress(m); pathToMatch = getPathToMatch(requestAddress, baseAddress, addSlash); m.put(var, pathToMatch); return pathToMatch; }