org.apache.jackrabbit.util.Text.escapePath()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中org.apache.jackrabbit.util.Text.escapePath()方法的一些代码示例,展示了Text.escapePath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Text.escapePath()方法的具体详情如下:
包路径:org.apache.jackrabbit.util.Text
类名称:Text
方法名:escapePath

Text.escapePath介绍

[英]Does a URL encoding of the path. The characters that don't need encoding are those defined 'unreserved' in section 2.3 of the 'URI generic syntax' RFC 2396. In contrast to the #escape(String) method, not the entire path string is escaped, but every individual part (i.e. the slashes are not escaped).
[中]对path进行URL编码。不需要编码的字符是“URI通用语法”RFC 2396第2.3节中定义的“未保留”字符。与#escape(String)方法不同,不是对整个路径字符串进行转义,而是对每个单独的部分(即斜线不转义)。

代码示例

代码示例来源:origin: apache/jackrabbit

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);
}

代码示例来源:origin: apache/jackrabbit

private String getRootURI(SessionInfo sessionInfo) {
  StringBuilder sb = new StringBuilder(getWorkspaceURI(sessionInfo));
  sb.append(Text.escapePath(JcrRemotingConstants.ROOT_ITEM_RESOURCEPATH));
  return sb.toString();
}

代码示例来源:origin: org.apache.sling/org.apache.sling.jcr.webdav

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();
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2dav

private String getRootURI(SessionInfo sessionInfo) {
  StringBuilder sb = new StringBuilder(getWorkspaceURI(sessionInfo));
  sb.append(Text.escapePath(JcrRemotingConstants.ROOT_ITEM_RESOURCEPATH));
  return sb.toString();
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2dav

String getRootItemUri(String workspaceName) {
  return getWorkspaceUri(workspaceName) + Text.escapePath(JcrRemotingConstants.ROOT_ITEM_RESOURCEPATH);
}

代码示例来源:origin: apache/jackrabbit

String getRootItemUri(String workspaceName) {
  return getWorkspaceUri(workspaceName) + Text.escapePath(JcrRemotingConstants.ROOT_ITEM_RESOURCEPATH);
}

代码示例来源:origin: org.apache.continuum/continuum-buildagent-webdav

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;
}

代码示例来源:origin: apache/archiva

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;
}

代码示例来源:origin: apache/jackrabbit

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();
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2dav

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();
}

代码示例来源:origin: info.magnolia/magnolia-module-standard-templating-kit

/**
 * @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) {
    };
  }
}

代码示例来源:origin: apache/jackrabbit

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();
  }
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2dav

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();
  }
}

代码示例来源:origin: adobe/aem-core-wcm-components

@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;
}

代码示例来源:origin: apache/jackrabbit

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);
  }
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2dav

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);
  }
}

代码示例来源:origin: adobe/aem-core-wcm-components

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) {

代码示例来源:origin: Adobe-Marketing-Cloud/aem-guides

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 +

代码示例来源:origin: apache/jackrabbit

uriBuffer.append("/");
uriBuffer.append(Text.escapePath(jcrPath));

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2dav

uriBuffer.append("/");
uriBuffer.append(Text.escapePath(jcrPath));

相关文章