Example usage for java.net URI isOpaque

List of usage examples for java.net URI isOpaque

Introduction

In this page you can find the example usage for java.net URI isOpaque.

Prototype

public boolean isOpaque() 

Source Link

Document

Tells whether or not this URI is opaque.

Usage

From source file:de.betterform.xml.xforms.XFormsProcessorImpl.java

private String resolve(URI relative) throws XFormsException {
    if (relative.isAbsolute() || relative.isOpaque()) {
        return relative.toString();
    }/*from   w w  w.j a va2 s .c  o m*/

    if (this.baseURI == null) {
        throw new XFormsException("base uri not present");
    }

    try {
        return new URI(this.baseURI).resolve(relative).toString();
    } catch (URISyntaxException e) {
        throw new XFormsException(e);
    }
}

From source file:net.www_eee.portal.channels.ProxyChannel.java

/**
 * <p>//from   w w  w .  j  a  v  a2  s.  c  o m
 * Rewrite a <code>linkURI</code> associated with a <code>proxiedFileURL</code>, if required.
 * </p>
 * 
 * <p>
 * Technically, there are two types of links within a document. First, a link within a document can be to an
 * <em>external resource</em>, which is loaded automatically by the browser to augment that document (ie a link to an
 * image, style sheet, script, etc). Or, second, a link within a document can be a <em>hyperlink</em>, which, when
 * activated by the user, will cause the browser to stop displaying that document and navigate to displaying the
 * linked document instead.
 * </p>
 * 
 * <p>
 * If the portal is configured to display a website to clients through this <code>ProxyChannel</code>, it is generally
 * expected that if the client navigates a hyperlink from one document to another within the proxied site, that the
 * linked document would also be rendered within the channel ({@linkplain net.www_eee.portal.Channel.Mode#VIEW view
 * mode}), and that any external resource links will continue to resolve correctly. Link rewriting is required for
 * each of these two scenarios to work.
 * </p>
 * 
 * <p>
 * To continue rendering within {@linkplain net.www_eee.portal.Channel.Mode#VIEW view mode} while navigating between
 * website documents, any hyperlink from within a proxied document to another document within the
 * {@linkplain #getProxiedBaseURI(Page.Request) proxied site} will, by default, be rewritten to point back through
 * this channel (alternatively, hyperlinks may {@linkplain #isLinkRewritingHyperlinksToChannelDisabled(Page.Request)
 * optionally} be resolved into an {@linkplain URI#isAbsolute() absolute} link pointing directly back to their
 * {@linkplain #getProxiedBaseURI(Page.Request) origin/source location} instead).
 * </p>
 * 
 * <p>
 * If this channel were to blindly return unmodified source HTML from a proxied document for aggregation into a
 * {@link Page}, any relative link would break when it was incorrectly resolved relative to the
 * {@link net.www_eee.portal.ContentDef.Page.Key#getPageURI(UriInfo, Map, String, boolean) URL} of that page, instead
 * of relative to the {@linkplain #BASE_URI_PROP base URL} of the document providing it. To avoid this, any relative
 * link to an external resource from within a proxied document will, by default, be resolved into an
 * {@linkplain URI#isAbsolute() absolute} link pointing directly back to the
 * {@linkplain #getProxiedBaseURI(Page.Request) origin/source location} for that resource (alternatively, resource
 * links may {@linkplain #isLinkRewritingResourceLinksToChannelEnabled(Page.Request) optionally} be rewritten to point
 * back through this channel using {@linkplain net.www_eee.portal.Channel.Mode#RESOURCE resource mode} instead).
 * </p>
 * 
 * <p>
 * For link rewriting to work, the <code>ProxyChannel</code> obviously needs to know which attributes of a proxied
 * document constitute <em>links</em>. But since the implementation is generic, and doesn't actually understand any
 * particular dialect of markup language on it's own, <em>including HTML</em>, you will likely want to configure this
 * channel alongside a plugin which does, such as the
 * {@linkplain net.www_eee.portal.channelplugins.ProxyChannelHTMLSource HTML plugin}.
 * </p>
 * 
 * @param pageRequest The {@link net.www_eee.portal.Page.Request Request} currently being processed.
 * @param proxiedFileURL The {@linkplain #getProxiedFileURL(Page.Request, Channel.Mode, boolean) proxied file URL}.
 * @param linkURI The {@link URI} of the link to rewrite.
 * @param hyperlink Is the <code>linkURI</code> a hyperlink?
 * @param absoluteURLRequired Does the result need to be {@linkplain URI#isAbsolute() absolute}?
 * @return A Map.Entry containing the rewritten link value, and a Boolean specifying if the returned link points back
 * through the channel.
 * @throws WWWEEEPortal.Exception If a problem occurred while determining the result.
 * @see #isLinkRewritingHyperlinksToChannelDisabled(Page.Request)
 * @see #isLinkRewritingResourceLinksToChannelEnabled(Page.Request)
 * @see net.www_eee.portal.channelplugins.ProxyChannelHTMLSource
 */
public Map.Entry<URI, Boolean> rewriteProxiedFileLink(final Page.Request pageRequest, final URL proxiedFileURL,
        final @Nullable URI linkURI, final boolean hyperlink, final boolean absoluteURLRequired)
        throws WWWEEEPortal.Exception {

    if ((linkURI != null) && (linkURI.isOpaque())) {
        return new AbstractMap.SimpleImmutableEntry<URI, Boolean>(linkURI, Boolean.FALSE); // Leave all the opaque ones alone (stuff like "mailto" links, etc), as we can't do anything with those.
    }

    final @NonNull URL resolvedLinkURL; // First, resolve the URL for the link so we know what server+file we are actually talking about here.
    try {
        if (linkURI == null) {
            resolvedLinkURL = proxiedFileURL; // An empty (null) link is equivalent to one back to the same proxied file.
        } else if (linkURI.isAbsolute()) {
            resolvedLinkURL = linkURI.toURL();
        } else {
            resolvedLinkURL = new URL(proxiedFileURL, linkURI.toString()); // Resolve the link relative to the file it came from.
        }
    } catch (MalformedURLException mue) {
        throw new ContentManager.ContentException("Error resolving proxied link URL", mue);
    }

    if (((hyperlink) && (isLinkRewritingHyperlinksToChannelDisabled(pageRequest)))
            || ((!hyperlink) && (!isLinkRewritingResourceLinksToChannelEnabled(pageRequest)))) {
        // We are configured to not write this link back through the portal.
        return new AbstractMap.SimpleImmutableEntry<URI, Boolean>(
                rewriteProxiedFileLinkOutsideChannel(pageRequest, proxiedFileURL, linkURI, hyperlink,
                        absoluteURLRequired, resolvedLinkURL),
                Boolean.FALSE);
    }

    /*
     * At this point, in order to determine what modifications to the link might be required, we need to figure out if
     * the link points to something either within, or outside of, the channel base URI's folder?
     */

    if ((linkURI != null) && (linkURI.isAbsolute()) && (!equalHostAndPort(resolvedLinkURL, proxiedFileURL))) {
        // This is an absolute link which doesn't even point to the same server as the proxied file.
        return new AbstractMap.SimpleImmutableEntry<URI, Boolean>(
                rewriteProxiedFileLinkOutsideChannel(pageRequest, proxiedFileURL, linkURI, hyperlink,
                        absoluteURLRequired, resolvedLinkURL),
                Boolean.FALSE);
    }

    /*
     * At this point we know the link at least points to the same server as the proxied file, but is it within the
     * channel base URI's folder?
     */

    final String resolvedLinkPath = StringUtil.toString(StringUtil.mkNull(resolvedLinkURL.getPath()), "/");

    final URI baseURI = getProxiedBaseURI(pageRequest);

    final URI resolvedBaseURI;
    if (baseURI.isAbsolute()) {
        resolvedBaseURI = baseURI;
    } else {
        resolvedBaseURI = ConfigManager.getContextResourceLocalHostURI(pageRequest.getUriInfo(),
                baseURI.getPath(), NetUtil.getQueryParams(baseURI), baseURI.getFragment(), true);
    }

    final String baseURIPath = resolvedBaseURI.getPath();

    final String baseURIFolder;
    if ((baseURIPath.length() == 1) || (baseURIPath.charAt(baseURIPath.length() - 1) == '/')) {
        baseURIFolder = baseURIPath; // Path is a folder.
    } else {
        final int lastSlashIndex = baseURIPath.lastIndexOf('/');
        baseURIFolder = (lastSlashIndex > 0) ? baseURIPath.substring(0, lastSlashIndex + 1)
                : String.valueOf('/');
    }

    if (!resolvedLinkPath.startsWith(baseURIFolder)) {
        // We have determined this link is not within the channel base URI folder.
        return new AbstractMap.SimpleImmutableEntry<URI, Boolean>(
                rewriteProxiedFileLinkOutsideChannel(pageRequest, proxiedFileURL, linkURI, hyperlink,
                        absoluteURLRequired, resolvedLinkURL),
                Boolean.FALSE);
    }

    /*
     * At this point we know the link points to within the channel base URI's folder, and that we need to rewrite it to
     * point back through the channel.
     */

    final String linkChannelLocalPath = StringUtil.mkNull(resolvedLinkPath.substring(baseURIFolder.length()));

    final Mode channelMode = ((hyperlink) && (!isMaximizationDisabled(pageRequest))) ? Mode.VIEW
            : Mode.RESOURCE;

    final ContentDef.ChannelSpec<?> channelSpec = pageRequest.getChannelSpec(this);
    return new AbstractMap.SimpleImmutableEntry<URI, Boolean>(
            channelSpec.getKey().getChannelURI(pageRequest.getUriInfo(), channelMode, linkChannelLocalPath,
                    (linkURI != null) ? NetUtil.getQueryParams(linkURI) : null,
                    (linkURI != null) ? linkURI.getFragment() : null, absoluteURLRequired),
            Boolean.TRUE);
}

From source file:es.pode.publicacion.negocio.servicios.SrvPublicacionServiceImpl.java

private boolean recursoValido(String href) throws URISyntaxException {

    URI uri = new URI(href);
    if (uri != null && !uri.equals("")) {
        if (!uri.isOpaque()) {//Para quitar las URL-s de tipo mailto:java-net@java.sun.com
            if (logger.isDebugEnabled())
                logger.debug("El recurso con href [" + href + "] es valido");
            return true;
        } else {/*from  w  w  w  .  ja  v a 2  s .  c  om*/
            if (logger.isDebugEnabled())
                logger.debug("El recurso con href [" + href + "] NO es valido");
            return false;
        }
    }
    return false;
}

From source file:org.asynchttpclient.test.TestUtils.java

public static File resourceAsFile(String path) throws URISyntaxException, IOException {
    ClassLoader cl = TestUtils.class.getClassLoader();
    URI uri = cl.getResource(path).toURI();
    if (uri.isAbsolute() && !uri.isOpaque()) {
        return new File(uri);
    } else {//ww  w .  jav a2 s . c  o  m
        File tmpFile = File.createTempFile("tmpfile-", ".data", TMP_DIR);
        tmpFile.deleteOnExit();
        try (InputStream is = cl.getResourceAsStream(path)) {
            FileUtils.copyInputStreamToFile(is, tmpFile);
            return tmpFile;
        }
    }
}

From source file:org.gatein.pc.test.unit.protocol.response.InvokeMethodResponse.java

public InvokeMethodResponse(String uri) throws IllegalArgumentException {
    if (uri == null) {
        throw new IllegalArgumentException("Cannot invoke against a null URL");
    }/* w  w w .  jav a  2 s.  co  m*/

    //
    URI tmp;
    try {
        tmp = new URI(uri);
    } catch (URISyntaxException e) {
        IllegalArgumentException iae = new IllegalArgumentException("Wrong URI syntax");
        iae.initCause(e);
        throw iae;
    }

    //
    if (tmp.isOpaque()) {
        throw new IllegalArgumentException("No opaque URI accepted");
    }

    //
    this.uri = tmp;
    this.headers = new HashMap<String, Header>();
}

From source file:org.lockss.util.UrlUtil.java

/** Resolve child relative to base */
// This version is a wrapper for java.net.URI.resolve().  Java class has
// two undesireable behaviors: it resolves ("http://foo.bar", "a.html")
// to "http://foo.bara.html" (fails to supply missing "/" to base with no
// path), and it resolves ("http://foo.bar/xxx.php", "?foo=bar") to
// "http://foo.bar/?foo=bar" (in accordance with RFC 2396), while all the
// browsers resolve it to "http://foo.bar/xxx.php?foo=bar" (in accordance
// with RFC 1808).  This mimics enough of the logic of
// java.net.URI.resolve(URI, URI) to detect those two cases, and defers
// to the URI code for other cases.

private static java.net.URI resolveUri0(java.net.URI base, java.net.URI child) throws MalformedURLException {

    // check if child is opaque first so that NPE is thrown 
    // if child is null.
    if (child.isOpaque() || base.isOpaque()) {
        return child;
    }//from  w  ww .  j a v  a  2  s.c o m

    try {
        String scheme = base.getScheme();
        String authority = base.getAuthority();
        String path = base.getPath();
        String query = base.getQuery();
        String fragment = child.getFragment();

        // If base has null path, ensure authority is separated from path in
        // result.  (java.net.URI resolves ("http://foo.bar", "x.y") to
        // http://foo.barx.y)
        if (StringUtil.isNullString(base.getPath())) {
            path = "/";
            base = new java.net.URI(scheme, authority, path, query, fragment);
        }

        // Absolute child
        if (child.getScheme() != null)
            return child;

        if (child.getAuthority() != null) {
            // not relative, defer to URI
            return base.resolve(child);
        }

        // Fragment only, return base with this fragment
        if (child.getPath().equals("") && (child.getFragment() != null) && (child.getQuery() == null)) {
            if ((base.getFragment() != null) && child.getFragment().equals(base.getFragment())) {
                return base;
            }
            java.net.URI ru = new java.net.URI(scheme, authority, path, query, fragment);
            return ru;
        }

        query = child.getQuery();

        authority = base.getAuthority();

        if (StringUtil.isNullString(child.getPath())) {
            // don't truncate base path if child has no path
            path = base.getPath();
        } else if (child.getPath().charAt(0) == '/') {
            // Absolute child path
            path = child.getPath();
        } else {
            // normal relative path, defer to URI
            return base.resolve(child);
        }
        // create URI from relativized components
        java.net.URI ru = new java.net.URI(scheme, authority, path, query, fragment);
        return ru;
    } catch (URISyntaxException e) {
        throw newMalformedURLException(e);
    }
}

From source file:org.opencms.staticexport.CmsAdvancedLinkSubstitutionHandler.java

/**
 * @see org.opencms.staticexport.I_CmsLinkSubstitutionHandler#getRootPath(org.opencms.file.CmsObject, java.lang.String, java.lang.String)
 *//*from www. j  av  a2  s .  c o m*/
@Override
public String getRootPath(CmsObject cms, String targetUri, String basePath) {

    if (cms == null) {
        // required by unit test cases
        return targetUri;
    }

    URI uri;
    String path;
    String fragment;
    String query;
    String suffix;

    // malformed uri
    try {
        uri = new URI(targetUri);
        path = uri.getPath();

        fragment = uri.getFragment();
        if (fragment != null) {
            fragment = "#" + fragment;
        } else {
            fragment = "";
        }

        query = uri.getQuery();
        if (query != null) {
            query = "?" + query;
        } else {
            query = "";
        }
    } catch (Exception e) {
        if (LOG.isWarnEnabled()) {
            LOG.warn(Messages.get().getBundle().key(Messages.LOG_MALFORMED_URI_1, targetUri), e);
        }
        return null;
    }

    // concatenate fragment and query 
    suffix = fragment.concat(query);

    // opaque URI
    if (uri.isOpaque()) {
        return null;
    }

    // get the list of link excludes form the cache if possible
    CmsVfsMemoryObjectCache cache = CmsVfsMemoryObjectCache.getVfsMemoryObjectCache();
    @SuppressWarnings("unchecked")
    List<String> excludes = (List<String>) cache.getCachedObject(cms, LINK_EXCLUDE_DEFINIFITON_FILE);
    if (excludes == null) {
        // nothing found in cache, so read definition file and store the result in cache
        excludes = readLinkExcludes(cms);
        cache.putCachedObject(cms, LINK_EXCLUDE_DEFINIFITON_FILE, excludes);
    }
    // now check if the current link start with one of the exclude links
    for (int i = 0; i < excludes.size(); i++) {
        if (path.startsWith(excludes.get(i))) {
            return null;
        }
    }

    // absolute URI (i.e. URI has a scheme component like http:// ...)
    if (uri.isAbsolute()) {
        CmsSiteMatcher matcher = new CmsSiteMatcher(targetUri);
        if (OpenCms.getSiteManager().isMatching(matcher)) {
            if (path.startsWith(OpenCms.getSystemInfo().getOpenCmsContext())) {
                path = path.substring(OpenCms.getSystemInfo().getOpenCmsContext().length());
            }
            if (OpenCms.getSiteManager().isWorkplaceRequest(matcher)) {
                // workplace URL, use current site root
                // this is required since the workplace site does not have a site root to set 
                return cms.getRequestContext().addSiteRoot(path + suffix);
            } else {
                // add the site root of the matching site
                return cms.getRequestContext()
                        .addSiteRoot(OpenCms.getSiteManager().matchSite(matcher).getSiteRoot(), path + suffix);
            }
        } else {
            return null;
        }
    }

    // relative URI (i.e. no scheme component, but filename can still start with "/") 
    String context = OpenCms.getSystemInfo().getOpenCmsContext();
    if ((context != null) && path.startsWith(context)) {
        // URI is starting with opencms context
        String siteRoot = null;
        if (basePath != null) {
            siteRoot = OpenCms.getSiteManager().getSiteRoot(basePath);
        }

        // cut context from path
        path = path.substring(context.length());

        if (siteRoot != null) {
            // special case: relative path contains a site root, i.e. we are in the root site                
            if (!path.startsWith(siteRoot)) {
                // path does not already start with the site root, we have to add this path as site prefix
                return cms.getRequestContext().addSiteRoot(siteRoot, path + suffix);
            } else {
                // since path already contains the site root, we just leave it unchanged
                return path + suffix;
            }
        } else {
            // site root is added with standard mechanism
            return cms.getRequestContext().addSiteRoot(path + suffix);
        }
    }

    // URI with relative path is relative to the given relativePath if available and in a site, 
    // otherwise invalid
    if (CmsStringUtil.isNotEmpty(path) && (path.charAt(0) != '/')) {
        if (basePath != null) {
            String absolutePath;
            int pos = path.indexOf("../../galleries/pics/");
            if (pos >= 0) {
                // HACK: mixed up editor path to system gallery image folder
                return CmsWorkplace.VFS_PATH_SYSTEM + path.substring(pos + 6) + suffix;
            }
            absolutePath = CmsLinkManager.getAbsoluteUri(path, cms.getRequestContext().addSiteRoot(basePath));
            if (OpenCms.getSiteManager().getSiteRoot(absolutePath) != null) {
                return absolutePath + suffix;
            }
            // HACK: some editor components (e.g. HtmlArea) mix up the editor URL with the current request URL 
            absolutePath = CmsLinkManager.getAbsoluteUri(path,
                    cms.getRequestContext().getSiteRoot() + CmsWorkplace.VFS_PATH_EDITORS);
            if (OpenCms.getSiteManager().getSiteRoot(absolutePath) != null) {
                return absolutePath + suffix;
            }
            // HACK: same as above, but XmlContent editor has one path element more
            absolutePath = CmsLinkManager.getAbsoluteUri(path,
                    cms.getRequestContext().getSiteRoot() + CmsWorkplace.VFS_PATH_EDITORS + "xmlcontent/");
            if (OpenCms.getSiteManager().getSiteRoot(absolutePath) != null) {
                return absolutePath + suffix;
            }
        }

        return null;
    }

    // relative URI (= VFS path relative to currently selected site root)
    if (CmsStringUtil.isNotEmpty(path)) {
        return cms.getRequestContext().addSiteRoot(path) + suffix;
    }

    // URI without path (typically local link)
    return suffix;
}

From source file:org.opencms.staticexport.CmsDefaultLinkSubstitutionHandler.java

/**
 * @see org.opencms.staticexport.I_CmsLinkSubstitutionHandler#getRootPath(org.opencms.file.CmsObject, java.lang.String, java.lang.String)
 *//*from w ww .j a  va 2  s  .c  om*/
public String getRootPath(CmsObject cms, String targetUri, String basePath) {

    if (cms == null) {
        // required by unit test cases
        return targetUri;
    }

    URI uri;
    String path;
    String fragment;
    String query;
    String suffix;

    // malformed uri
    try {
        uri = new URI(targetUri);
        path = uri.getPath();

        fragment = uri.getFragment();
        if (fragment != null) {
            fragment = "#" + fragment;
        } else {
            fragment = "";
        }

        query = uri.getQuery();
        if (query != null) {
            query = "?" + query;
        } else {
            query = "";
        }
    } catch (Exception e) {
        if (LOG.isWarnEnabled()) {
            LOG.warn(Messages.get().getBundle().key(Messages.LOG_MALFORMED_URI_1, targetUri), e);
        }
        return null;
    }

    // concatenate query and fragment 
    suffix = query.concat(fragment);

    // opaque URI
    if (uri.isOpaque()) {
        return null;
    }

    // absolute URI (i.e. URI has a scheme component like http:// ...)
    if (uri.isAbsolute()) {
        CmsSiteMatcher matcher = new CmsSiteMatcher(targetUri);
        if (OpenCms.getSiteManager().isMatching(matcher)) {
            if (path.startsWith(OpenCms.getSystemInfo().getOpenCmsContext())) {
                path = path.substring(OpenCms.getSystemInfo().getOpenCmsContext().length());
            }
            boolean isWorkplaceServer = OpenCms.getSiteManager().isWorkplaceRequest(matcher);
            if (isWorkplaceServer) {
                String pathForCurrentSite = cms.getRequestContext().addSiteRoot(path);
                String pathForMatchedSite = cms.getRequestContext()
                        .addSiteRoot(OpenCms.getSiteManager().matchSite(matcher).getSiteRoot(), path);
                String originalSiteRoot = cms.getRequestContext().getSiteRoot();
                String selectedPath = pathForCurrentSite;
                try {
                    cms.getRequestContext().setSiteRoot("");
                    // the path for the current site normally is preferred, but if it doesn't exist and the path for the matched site
                    // does exist, then use the path for the matched site 
                    if (!cms.existsResource(pathForCurrentSite, CmsResourceFilter.ALL)
                            && cms.existsResource(pathForMatchedSite, CmsResourceFilter.ALL)) {
                        selectedPath = pathForMatchedSite;
                    }
                } finally {
                    cms.getRequestContext().setSiteRoot(originalSiteRoot);
                }
                return selectedPath + suffix;
            } else {
                // add the site root of the matching site
                return cms.getRequestContext()
                        .addSiteRoot(OpenCms.getSiteManager().matchSite(matcher).getSiteRoot(), path + suffix);
            }
        } else {
            return null;
        }
    }

    // relative URI (i.e. no scheme component, but filename can still start with "/") 
    String context = OpenCms.getSystemInfo().getOpenCmsContext();
    if ((context != null) && path.startsWith(context)) {
        // URI is starting with opencms context
        String siteRoot = null;
        if (basePath != null) {
            siteRoot = OpenCms.getSiteManager().getSiteRoot(basePath);
        }

        // cut context from path
        path = path.substring(context.length());

        if (siteRoot != null) {
            // special case: relative path contains a site root, i.e. we are in the root site                
            if (!path.startsWith(siteRoot)) {
                // path does not already start with the site root, we have to add this path as site prefix
                return cms.getRequestContext().addSiteRoot(siteRoot, path + suffix);
            } else {
                // since path already contains the site root, we just leave it unchanged
                return path + suffix;
            }
        } else {
            // site root is added with standard mechanism
            return cms.getRequestContext().addSiteRoot(path + suffix);
        }
    }

    // URI with relative path is relative to the given relativePath if available and in a site, 
    // otherwise invalid
    if (CmsStringUtil.isNotEmpty(path) && (path.charAt(0) != '/')) {
        if (basePath != null) {
            String absolutePath;
            int pos = path.indexOf("../../galleries/pics/");
            if (pos >= 0) {
                // HACK: mixed up editor path to system gallery image folder
                return CmsWorkplace.VFS_PATH_SYSTEM + path.substring(pos + 6) + suffix;
            }
            absolutePath = CmsLinkManager.getAbsoluteUri(path, cms.getRequestContext().addSiteRoot(basePath));
            if (OpenCms.getSiteManager().getSiteRoot(absolutePath) != null) {
                return absolutePath + suffix;
            }
            // HACK: some editor components (e.g. HtmlArea) mix up the editor URL with the current request URL 
            absolutePath = CmsLinkManager.getAbsoluteUri(path,
                    cms.getRequestContext().getSiteRoot() + CmsWorkplace.VFS_PATH_EDITORS);
            if (OpenCms.getSiteManager().getSiteRoot(absolutePath) != null) {
                return absolutePath + suffix;
            }
            // HACK: same as above, but XmlContent editor has one path element more
            absolutePath = CmsLinkManager.getAbsoluteUri(path,
                    cms.getRequestContext().getSiteRoot() + CmsWorkplace.VFS_PATH_EDITORS + "xmlcontent/");
            if (OpenCms.getSiteManager().getSiteRoot(absolutePath) != null) {
                return absolutePath + suffix;
            }
        }

        return null;
    }

    // relative URI (= VFS path relative to currently selected site root)
    if (CmsStringUtil.isNotEmpty(path)) {
        return cms.getRequestContext().addSiteRoot(path) + suffix;
    }

    // URI without path (typically local link)
    return suffix;
}

From source file:org.semanticweb.owlapi.model.IRI.java

/**
 * @param s the IRI stirng to be resolved
 * @return s resolved against this IRI (with the URI::resolve() method, unless this IRI is
 *         opaque)/*from w  w  w. j a va 2 s  .com*/
 */
public IRI resolve(String s) {
    // shortcut: checking absolute and opaque here saves the creation of an
    // extra URI object
    URI uri = URI.create(s);
    if (uri.isAbsolute() || uri.isOpaque()) {
        return create(uri);
    }
    return create(toURI().resolve(uri));
}