/** * Given a {@link Page}, this method returns the correct URL, taking into account that the provided {@code page} might provide a * vanity URL. * * @param request the current request, used to determine the server's context path * @param page the page * @return the URL of the page identified by the provided {@code path}, or the original {@code path} if this doesn't identify a * {@link Page} */ @Nonnull public static String getURL(@Nonnull SlingHttpServletRequest request, @Nonnull Page page) { String vanityURL = page.getVanityUrl(); return StringUtils.isEmpty(vanityURL) ? request.getContextPath() + page.getPath() + ".html" : request.getContextPath() + vanityURL; }
private Attributes rebuildAttributes(final AttributesImpl newAttributes, final int index, final String path, final LibraryType libraryType, final SlingHttpServletRequest request) { final String contextPath = request.getContextPath(); String libraryPath = path; if (StringUtils.isNotBlank(contextPath)) { libraryPath = path.substring(contextPath.length()); } String versionedPath = this.getVersionedPath(libraryPath, libraryType, request.getResourceResolver()); if (StringUtils.isNotBlank(versionedPath)) { if(StringUtils.isNotBlank(contextPath)) { versionedPath = contextPath + versionedPath; } log.debug("Rewriting to: {}", versionedPath); newAttributes.setValue(index, versionedPath); } else { log.debug("Versioned Path could not be created properly"); } return newAttributes; }
path = StringUtils.defaultString(request.getContextPath()) + path; //NOPMD
@PostConstruct private void initModel() { FormStructureHelper formStructureHelper = formStructureHelperFactory.getFormStructureHelper(resource); request.setAttribute(FormsHelper.REQ_ATTR_FORM_STRUCTURE_HELPER, formStructureHelper); this.action = Utils.getURL(request, currentPage); if (StringUtils.isBlank(id)) { id = FormsHelper.getFormId(request); } this.name = id; this.dropAreaResourceType += "/new"; if (redirect != null) { String contextPath = request.getContextPath(); if (StringUtils.isNotBlank(contextPath) && redirect.startsWith("/")) { redirect = contextPath + redirect; } } if (!StringUtils.equals(request.getRequestPathInfo().getExtension(), ExporterConstants.SLING_MODEL_EXTENSION)) { runActionTypeInit(formStructureHelper); } }
@Nullable private String getRedirectLocation(SlingHttpServletRequest request, long lastModifiedEpoch) { RequestPathInfo requestPathInfo = request.getRequestPathInfo(); if (request.getResource().isResourceType(IMAGE_RESOURCE_TYPE)) { return Joiner.on('.').join(Text.escapePath(request.getContextPath() + requestPathInfo.getResourcePath()), requestPathInfo.getSelectorString(), requestPathInfo.getExtension() + "/" + lastModifiedEpoch, requestPathInfo.getExtension()); } long lastModifiedSuffix = getRequestLastModifiedSuffix(request.getPathInfo()); String resourcePath = lastModifiedSuffix > 0 ? ResourceUtil.getParent(request.getPathInfo()) : request.getPathInfo(); String extension = FilenameUtils.getExtension(resourcePath); if (StringUtils.isNotEmpty(resourcePath)) { if (StringUtils.isNotEmpty(extension)) { resourcePath = resourcePath.substring(0, resourcePath.length() - extension.length() - 1); } return request.getContextPath() + Text.escapePath(resourcePath) + "/" + lastModifiedEpoch + "." + requestPathInfo.getExtension(); } return null; }
private String getProxyPath(ClientLibrary lib) { String path = lib.getPath(); if (lib.allowProxy()) { for (String searchPath : request.getResourceResolver().getSearchPath()) { if (path.startsWith(searchPath)) { path = request.getContextPath() + "/etc.clientlibs/" + path.replaceFirst(searchPath, ""); } } } else { if (request.getResourceResolver().getResource(lib.getPath()) == null) { path = null; } } if (path != null) { path = path + "/resources"; } return path; }
response.sendRedirect(request.getContextPath() + currentPage.getPath() + ".html/" + suffix);
String escapedResourcePath = Text.escapePath(resource.getPath()); for (Integer width : supportedRenditionWidths) { smartImages[index] = request.getContextPath() + escapedResourcePath + DOT + AdaptiveImageServlet.DEFAULT_SELECTOR + DOT + width + DOT + extension + (!wcmmode.isDisabled() && lastModifiedDate > 0 ? "/" + lastModifiedDate + DOT + extension : ""); src = request.getContextPath() + escapedResourcePath + DOT + AdaptiveImageServlet.DEFAULT_SELECTOR + DOT + extension + (!wcmmode.isDisabled() && lastModifiedDate > 0 ? "/" + lastModifiedDate + DOT + extension : ""); } else if (smartSizes.length == 1) { src = request.getContextPath() + escapedResourcePath + DOT + AdaptiveImageServlet.DEFAULT_SELECTOR + DOT + smartSizes[0] + DOT + extension + (!wcmmode.isDisabled() && lastModifiedDate > 0 ? "/" + lastModifiedDate + DOT + extension : "");
response.sendRedirect(request.getContextPath() + currentPage.getPath() + ".html/" + suffix);