Search in sources :

Example 1 with WebdavRequestContext

use of org.apache.jackrabbit.webdav.WebdavRequestContext in project jackrabbit by apache.

the class AbstractReport method normalizeResourceHref.

/**
 * Normalize the resource {@code href}. For example, remove contextPath prefix if found.
 * @param href resource href
 * @return normalized resource {@code href}
 */
protected String normalizeResourceHref(final String href) {
    if (href == null) {
        return href;
    }
    final WebdavRequestContext requestContext = WebdavRequestContextHolder.getContext();
    final WebdavRequest request = (requestContext != null) ? requestContext.getRequest() : null;
    if (request == null) {
        log.error("WebdavRequest is unavailable in the current execution context.");
        return href;
    }
    final String contextPath = request.getContextPath();
    if (!contextPath.isEmpty() && href.startsWith(contextPath)) {
        return href.substring(contextPath.length());
    }
    return href;
}
Also used : WebdavRequest(org.apache.jackrabbit.webdav.WebdavRequest) WebdavRequestContext(org.apache.jackrabbit.webdav.WebdavRequestContext)

Example 2 with WebdavRequestContext

use of org.apache.jackrabbit.webdav.WebdavRequestContext in project jackrabbit by apache.

the class AbstractResource method normalizeResourceHref.

/**
 * Normalize the resource {@code href}. For example, remove contextPath prefix if found.
 * @param href resource href
 * @return normalized resource {@code href}
 */
protected String normalizeResourceHref(final String href) {
    if (href == null) {
        return href;
    }
    final WebdavRequestContext requestContext = WebdavRequestContextHolder.getContext();
    final WebdavRequest request = (requestContext != null) ? requestContext.getRequest() : null;
    if (request == null) {
        log.error("WebdavRequest is unavailable in the current execution context.");
        return href;
    }
    final String contextPath = request.getContextPath();
    if (!contextPath.isEmpty() && href.startsWith(contextPath)) {
        return href.substring(contextPath.length());
    }
    return href;
}
Also used : WebdavRequest(org.apache.jackrabbit.webdav.WebdavRequest) WebdavRequestContext(org.apache.jackrabbit.webdav.WebdavRequestContext)

Aggregations

WebdavRequest (org.apache.jackrabbit.webdav.WebdavRequest)2 WebdavRequestContext (org.apache.jackrabbit.webdav.WebdavRequestContext)2