private Locator(String prefix, String resourcePath, DavLocatorFactory factory) { this.prefix = prefix; this.factory = factory; // remove trailing '/' that is not part of the resourcePath except for the root item. if (resourcePath.endsWith("/") && !"/".equals(resourcePath)) { resourcePath = resourcePath.substring(0, resourcePath.length()-1); } this.resourcePath = resourcePath; href = prefix + Text.escapePath(resourcePath); }
private String getRootURI(SessionInfo sessionInfo) { StringBuilder sb = new StringBuilder(getWorkspaceURI(sessionInfo)); sb.append(Text.escapePath(JcrRemotingConstants.ROOT_ITEM_RESOURCEPATH)); return sb.toString(); }
SlingResourceLocator(String prefix, String workspaceName, String resourcePath, SlingLocatorFactory factory) { this.prefix = prefix; this.workspaceName = workspaceName; this.resourcePath = resourcePath; this.factory = factory; StringBuffer buf = new StringBuffer(prefix); buf.append(Text.escapePath(resourcePath)); int length = buf.length(); if (length > 0 && buf.charAt(length - 1) != '/') { buf.append("/"); } href = buf.toString(); }
private String getRootURI(SessionInfo sessionInfo) { StringBuilder sb = new StringBuilder(getWorkspaceURI(sessionInfo)); sb.append(Text.escapePath(JcrRemotingConstants.ROOT_ITEM_RESOURCEPATH)); return sb.toString(); }
String getRootItemUri(String workspaceName) { return getWorkspaceUri(workspaceName) + Text.escapePath(JcrRemotingConstants.ROOT_ITEM_RESOURCEPATH); }
String getRootItemUri(String workspaceName) { return getWorkspaceUri(workspaceName) + Text.escapePath(JcrRemotingConstants.ROOT_ITEM_RESOURCEPATH); }
public ContinuumBuildAgentDavResourceLocator( String prefix, String resourcePath, DavLocatorFactory davLocatorFactory, int projectId ) { this.prefix = prefix; this.davLocatorFactory = davLocatorFactory; this.projectId = projectId; String escapedPath = Text.escapePath( resourcePath ); String hrefPrefix = prefix; // Ensure no extra slashes when href is joined if ( hrefPrefix.endsWith( "/" ) && escapedPath.startsWith( "/" ) ) { hrefPrefix = hrefPrefix.substring( 0, hrefPrefix.length() - 1 ); } href = hrefPrefix + escapedPath; String path = resourcePath; if ( !resourcePath.startsWith( "/" ) ) { path = "/" + resourcePath; } //Remove trailing slashes otherwise Text.getRelativeParent fails if ( resourcePath.endsWith( "/" ) && resourcePath.length() > 1 ) { path = resourcePath.substring( 0, resourcePath.length() - 1 ); } this.resourcePath = path; }
public ArchivaDavResourceLocator( String prefix, String resourcePath, String repositoryId, DavLocatorFactory davLocatorFactory ) { this.prefix = prefix; this.repositoryId = repositoryId; this.davLocatorFactory = davLocatorFactory; String path = resourcePath; if ( !resourcePath.startsWith( "/" ) ) { path = "/" + resourcePath; } String escapedPath = Text.escapePath( resourcePath ); String hrefPrefix = prefix; // Ensure no extra slashes when href is joined if ( hrefPrefix.endsWith( "/" ) && escapedPath.startsWith( "/" ) ) { hrefPrefix = hrefPrefix.substring( 0, hrefPrefix.length() - 1 ); } href = hrefPrefix + escapedPath; this.origResourcePath = path; //Remove trailing slashes otherwise Text.getRelativeParent fails if ( resourcePath.endsWith( "/" ) && resourcePath.length() > 1 ) { path = resourcePath.substring( 0, resourcePath.length() - 1 ); } this.resourcePath = path; }
private String getURI(Path path, SessionInfo sessionInfo) throws RepositoryException { StringBuilder sb = new StringBuilder(getRootURI(sessionInfo)); String jcrPath = getNamePathResolver(sessionInfo).getJCRPath(path); sb.append(Text.escapePath(jcrPath)); return sb.toString(); }
private String getURI(Path path, SessionInfo sessionInfo) throws RepositoryException { StringBuilder sb = new StringBuilder(getRootURI(sessionInfo)); String jcrPath = getNamePathResolver(sessionInfo).getJCRPath(path); sb.append(Text.escapePath(jcrPath)); return sb.toString(); }
/** * @return the link to an image variation for non asset nodes containing a binary */ public String getImageVariationLinkFromBinary(Node binaryContent, String rendition) { if (binaryContent == null || rendition == null) { return null; } try { String link = getImagingSupport().createLink(binaryContent.getProperty(JcrConstants.JCR_DATA), rendition); // URL encode the path because the user name node (=email address for ResearchAnt) in the path may contain illegal // URL characters (like '+'). Fix for: https://jira.info.nl/browse/TOKUE-319 // for background info see: http://wiki.apache.org/jackrabbit/EncodingAndEscaping return Text.escapePath(link); } catch (Exception e) { throw new DamException("AssetRendition exception", e) { }; } }
private String getValueURI() throws RepositoryException { Path propertyPath = pFactory.create(getCurrentNodeInfo().getPath(), name, true); StringBuffer sb = new StringBuffer(rootURI); sb.append(Text.escapePath(resolver.getJCRPath(propertyPath))); return sb.toString(); } }
private String getValueURI() throws RepositoryException { Path propertyPath = pFactory.create(getCurrentNodeInfo().getPath(), name, true); StringBuffer sb = new StringBuffer(rootURI); sb.append(Text.escapePath(resolver.getJCRPath(propertyPath))); return sb.toString(); } }
@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 Path getPath(ItemId itemId, SessionInfo sessionInfo, String workspaceName) throws RepositoryException { if (itemId.denotesNode()) { Path p = itemId.getPath(); String uid = itemId.getUniqueID(); if (uid == null) { return p; } else { NamePathResolver resolver = getNamePathResolver(sessionInfo); String uri = super.getItemUri(itemId, sessionInfo, workspaceName); String rootUri = getRootURI(sessionInfo); String jcrPath; if (uri.startsWith(rootUri)) { jcrPath = uri.substring(rootUri.length()); } else { log.warn("ItemURI " + uri + " doesn't start with rootURI (" + rootUri + ")."); // fallback: // calculated uri does not start with the rootURI // -> search /jcr:root and start sub-string behind. String rootSegment = Text.escapePath(JcrRemotingConstants.ROOT_ITEM_RESOURCEPATH); jcrPath = uri.substring(uri.indexOf(rootSegment) + rootSegment.length()); } jcrPath = Text.unescape(jcrPath); return resolver.getQPath(jcrPath); } } else { PropertyId pId = (PropertyId) itemId; Path parentPath = getPath(pId.getParentId(), sessionInfo, workspaceName); return getPathFactory().create(parentPath, pId.getName(), true); } }
private Path getPath(ItemId itemId, SessionInfo sessionInfo, String workspaceName) throws RepositoryException { if (itemId.denotesNode()) { Path p = itemId.getPath(); String uid = itemId.getUniqueID(); if (uid == null) { return p; } else { NamePathResolver resolver = getNamePathResolver(sessionInfo); String uri = super.getItemUri(itemId, sessionInfo, workspaceName); String rootUri = getRootURI(sessionInfo); String jcrPath; if (uri.startsWith(rootUri)) { jcrPath = uri.substring(rootUri.length()); } else { log.warn("ItemURI " + uri + " doesn't start with rootURI (" + rootUri + ")."); // fallback: // calculated uri does not start with the rootURI // -> search /jcr:root and start sub-string behind. String rootSegment = Text.escapePath(JcrRemotingConstants.ROOT_ITEM_RESOURCEPATH); jcrPath = uri.substring(uri.indexOf(rootSegment) + rootSegment.length()); } jcrPath = Text.unescape(jcrPath); return resolver.getQPath(jcrPath); } } else { PropertyId pId = (PropertyId) itemId; Path parentPath = getPath(pId.getParentId(), sessionInfo, workspaceName); return getPathFactory().create(parentPath, pId.getName(), true); } }
smartImages[index] = baseResourcePath + DOT + selector + DOT + jpegQuality + DOT + width + DOT + extension + (inTemplate ? Text.escapePath(templateRelativePath) : "") + (lastModifiedDate > 0 ? "/" + lastModifiedDate + (StringUtils.isNotBlank(imageName) ? "/" + imageName : "") + DOT + extension : ""); src += extension; src += (inTemplate ? Text.escapePath(templateRelativePath) : "") + (lastModifiedDate > 0 ? "/" + lastModifiedDate + (StringUtils.isNotBlank(imageName) ? "/" + imageName : "") + DOT + extension : ""); if (!isDecorative) {
smartSizes = new int[supportedRenditionWidths.size()]; int index = 0; String escapedResourcePath = Text.escapePath(resource.getPath()); for (Integer width : supportedRenditionWidths) { smartImages[index] = request.getContextPath() + escapedResourcePath + DOT + AdaptiveImageServlet.DEFAULT_SELECTOR + DOT +
uriBuffer.append("/"); uriBuffer.append(Text.escapePath(jcrPath));
uriBuffer.append("/"); uriBuffer.append(Text.escapePath(jcrPath));