protected boolean checkExtension(RequestPathInfo pathInfo, ValueMap properties) { return check(pathInfo.getExtension(), PN_ALLOWED_EXTENSIONS, PN_ALLOWED_EXTENSION_PATTERN, properties); }
@Override public boolean handleRequest(SlingHttpServletRequest request) { return request.getRequestPathInfo().getExtension().equals(CSV_EXTENSION); }
public static LibraryType fromRequest(SlingHttpServletRequest request) { String ext = request.getRequestPathInfo().getExtension(); if (ext.equals(JS_EXTENSION)) return JS; if (ext.equals(CSS_EXTENSION)) { return CSS; } return null; } }
@Override public String getExtension() { return isExtensionOverridden ? extension : getOriginal().getExtension(); }
protected boolean checkExtension(RequestPathInfo pathInfo, ValueMap properties) { return check(pathInfo.getExtension(), PN_ALLOWED_EXTENSIONS, PN_ALLOWED_EXTENSION_PATTERN, properties); }
@Override public String getExtension() { return isExtensionOverridden ? extension : getOriginal().getExtension(); }
@Override public boolean handleRequest(SlingHttpServletRequest request) { return request.getRequestPathInfo().getExtension().equals(JSON_EXTENSION); }
public String getExtension() { final ValueMap properties = resource.getValueMap(); if (properties != null) { if (properties.get(SLING_STATUS, -1) < 0) { // Internal redirect; so keep extension return requestPathInfo.getExtension(); } else { // External redirect; like 301 or 302 then kill the extension else it gets double added. Note this will also kill any selector addition. return null; } } else { return requestPathInfo.getExtension(); } }
/** * Check if this is an image request. * * @param request the current {@link SlingHttpServletRequest} * @return true if this request should deliver an image. */ private boolean isImageRequest(final SlingHttpServletRequest request) { if (StringUtils.isBlank(errorImagePath)) { log.warn("ACS AEM Commons error page handler enabled to handle error images, " + "but no error image path was provided."); return false; } final String extension = StringUtils.stripToEmpty(StringUtils.lowerCase( request.getRequestPathInfo().getExtension())); return ArrayUtils.contains(errorImageExtensions, extension); }
@Override public String getServletPath() { final RequestPathInfo pathInfo = getRequestPathInfo(); return pathInfo.getResourcePath() + "." + pathInfo.getExtension(); } }
/** * Check if this is an image request. * * @param request the current {@link SlingHttpServletRequest} * @return true if this request should deliver an image. */ private boolean isImageRequest(final SlingHttpServletRequest request) { if (StringUtils.isBlank(errorImagePath)) { log.warn("ACS AEM Commons error page handler enabled to handle error images, " + "but no error image path was provided."); return false; } final String extension = StringUtils.stripToEmpty(StringUtils.lowerCase( request.getRequestPathInfo().getExtension())); return ArrayUtils.contains(errorImageExtensions, extension); }
/** * Creates a <code>ResourceCollector</code> for the given * <code>request</code>. If the request is a GET or HEAD request, a * specialized instance is returned which also takes the request selectors * and request extension into account for finding servlet resources. * Otherwise an instance of this class itself is returned which just takes * the resource type and request method name into account. * * @param request The <code>SlingHttpServletRequest</code> for which to * return a <code>ResourceCollector</code>. * @return The <code>ResourceCollector</code> to find servlets and scripts * suitable for handling the <code>request</code>. */ public static ResourceCollector create( final SlingHttpServletRequest request, final String[] executionPaths, final String[] defaultExtensions) { final RequestPathInfo requestPathInfo = request.getRequestPathInfo(); final boolean isDefaultExtension = ArrayUtils.contains(defaultExtensions, requestPathInfo.getExtension()); return new ResourceCollector(request.getResource(), requestPathInfo.getExtension(), executionPaths, isDefaultExtension, request.getMethod(), requestPathInfo.getSelectors()); }
@Override public String getURL() { String pagePath = currentPage.getPath(); String extension = request.getRequestPathInfo().getExtension(); String url = externalizer.publishLink(resourceResolver, pagePath) + "." + extension; return url; }
private String buildUrl(Configuration config, SlingHttpServletRequest request) { final boolean synthetic = ResourceUtil.isSyntheticResource(request.getResource()); final Resource resource = request.getResource(); final StringBuilder builder = new StringBuilder(); final RequestPathInfo pathInfo = request.getRequestPathInfo(); final String resourcePath = pathInfo.getResourcePath(); builder.append(resourcePath); if (pathInfo.getSelectorString() != null) { builder.append('.').append(sanitize(pathInfo.getSelectorString())); } builder.append('.').append(config.getIncludeSelector()); builder.append('.').append(pathInfo.getExtension()); if (synthetic) { builder.append('/').append(resource.getResourceType()); } else { builder.append(sanitize(pathInfo.getSuffix())); } return builder.toString(); }
@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; }
@Override protected void doRun(final SlingHttpServletRequest request, final PostResponse response, final List<Modification> changes) throws PersistenceException { // SLING-3203: selectors, extension and suffix make no sense here and // might lead to deleting other resources than the one the user means. final RequestPathInfo rpi = request.getRequestPathInfo(); if( (rpi.getSelectors() != null && rpi.getSelectors().length > 0) || (rpi.getExtension() != null && rpi.getExtension().length() > 0) || (rpi.getSuffix() != null && rpi.getSuffix().length() > 0)) { response.setStatus( HttpServletResponse.SC_FORBIDDEN, "DeleteOperation request cannot include any selectors, extension or suffix"); return; } final VersioningConfiguration versioningConfiguration = getVersioningConfiguration(request); final boolean deleteChunks = isDeleteChunkRequest(request); final Iterator<Resource> res = getApplyToResources(request); if (res == null) { final Resource resource = request.getResource(); deleteResource(resource, changes, versioningConfiguration, deleteChunks); } else { while (res.hasNext()) { final Resource resource = res.next(); deleteResource(resource, changes, versioningConfiguration, deleteChunks); } } }
/** * The externally provided key may be wrapped to add more key elements in order * to restrict the cached object's scope to a specific component when safe mode is enabled. * * @return A request-state sensitive key in {@link Configuration#safeMode()}, the original key otherwise. */ private Object createSafeModeKey(Object key) { // Create a request-state sensitive key to scope the cached model to a request with specific parameters. final SlingHttpServletRequest request = this.requestHolder.get(); if (request == null) { return key; } final RequestPathInfo requestPathInfo = request.getRequestPathInfo(); return new Key(key, new Key(substringBefore(requestPathInfo.getResourcePath(), "/jcr:content"), requestPathInfo.getSelectorString(), requestPathInfo.getExtension(), requestPathInfo.getSuffix(), request.getQueryString())); }
@Override protected void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws IOException { Map<String, String> data = null; if (request.getRequestPathInfo().getSelectors().length > 0) { final String label = request.getRequestPathInfo().getSelectors()[0]; if (PROVIDER_LABEL.equals(label)) { data = this.getInfo(request); } } if (data == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Unknown Info Request"); } else { response.setHeader(CACHE_CONTROL_HEADER, CACHE_CONTROL_HEADER_VALUE); final String extension = request.getRequestPathInfo().getExtension(); if ("json".equals(extension)) { renderJson(response, data); } else if ("txt".equals(extension)) { renderPlainText(response, data); } else { // default to html renderHtml(response, data); } } }
throws ServletException, IOException { if ("html".equals(request.getRequestPathInfo().getExtension())) { response.setContentType("text/html"); } else {