/** * A variation on {@link #getForLookupPath(String)} that accepts a full request * URL path (i.e. including context and servlet path) and returns the full request * URL path to expose for public use. * @param request the current request * @param requestUrl the request URL path to resolve * @return the resolved public URL path, or {@code null} if unresolved */ @Nullable public final String getForRequestUrl(HttpServletRequest request, String requestUrl) { int prefixIndex = getLookupPathIndex(request); int suffixIndex = getEndPathIndex(requestUrl); if (prefixIndex >= suffixIndex) { return null; } String prefix = requestUrl.substring(0, prefixIndex); String suffix = requestUrl.substring(suffixIndex); String lookupPath = requestUrl.substring(prefixIndex, suffixIndex); String resolvedLookupPath = getForLookupPath(lookupPath); return (resolvedLookupPath != null ? prefix + resolvedLookupPath + suffix : null); }
/** * A variation on {@link #getForLookupPath(String)} that accepts a full request * URL path (i.e. including context and servlet path) and returns the full request * URL path to expose for public use. * @param request the current request * @param requestUrl the request URL path to resolve * @return the resolved public URL path, or {@code null} if unresolved */ @Nullable public final String getForRequestUrl(HttpServletRequest request, String requestUrl) { int prefixIndex = getLookupPathIndex(request); int suffixIndex = getEndPathIndex(requestUrl); if (prefixIndex >= suffixIndex) { return null; } String prefix = requestUrl.substring(0, prefixIndex); String suffix = requestUrl.substring(suffixIndex); String lookupPath = requestUrl.substring(prefixIndex, suffixIndex); String resolvedLookupPath = getForLookupPath(lookupPath); return (resolvedLookupPath != null ? prefix + resolvedLookupPath + suffix : null); }
/** * A variation on {@link #getForLookupPath(String)} that accepts a full request * URL path (i.e. including context and servlet path) and returns the full request * URL path to expose for public use. * @param request the current request * @param requestUrl the request URL path to resolve * @return the resolved public URL path, or {@code null} if unresolved */ public final String getForRequestUrl(HttpServletRequest request, String requestUrl) { if (logger.isTraceEnabled()) { logger.trace("Getting resource URL for request URL \"" + requestUrl + "\""); } int prefixIndex = getLookupPathIndex(request); int suffixIndex = getEndPathIndex(requestUrl); if (prefixIndex >= suffixIndex) { return null; } String prefix = requestUrl.substring(0, prefixIndex); String suffix = requestUrl.substring(suffixIndex); String lookupPath = requestUrl.substring(prefixIndex, suffixIndex); String resolvedLookupPath = getForLookupPath(lookupPath); return (resolvedLookupPath != null ? prefix + resolvedLookupPath + suffix : null); }