Use the {@link org.opencms.file.wrapper.CmsObjectWrapper} to restore the link in the VFS.<p>

@param internalUri the internal URI to restore

@return the restored URI
343266
private String rewriteUri(String internalUri) {

        // if an object wrapper is used, rewrite the uri
        if (m_cms != null) {
            Object obj = m_cms.getRequestContext().getAttribute(CmsObjectWrapper.ATTRIBUTE_NAME);
            if (obj != null) {
                CmsObjectWrapper wrapper = (CmsObjectWrapper)obj;
                return wrapper.restoreLink(internalUri);
            }
        }

        return internalUri;
    }
1165178
@Override
    public URI rewriteURI(RequestContext rc) throws URISyntaxException {
        Request request = rc.request();
        BalancerMember member = selectBalancerMember(rc);
        logger.debug("Selected {}", member.getName());
        String path = request.path();
        if (!path.startsWith(prefix)) {
            return null;
        }

        return computeDestinationURI(
                request,
                path,
                member.proxyTo(),
                prefix
        );
    }
1154743
public static CMISObjectWrapper wrap(final GraphObject source, final String propertyFilter, final Boolean includeAllowableActions) throws FrameworkException {

		CMISObjectWrapper wrapper = null;
		if (source != null) {

			final CMISInfo cmisInfo = source.getCMISInfo();
			if (cmisInfo != null) {

				final BaseTypeId baseTypeId = cmisInfo.getBaseTypeId();
				if (baseTypeId != null) {

					switch (baseTypeId) {

						case CMIS_DOCUMENT:
							wrapper = new CMISDocumentWrapper(propertyFilter, includeAllowableActions);
							wrapper.initializeFrom(cmisInfo.getDocumentInfo());
							break;

						case CMIS_FOLDER:
							wrapper = new CMISFolderWrapper(propertyFilter, includeAllowableActions);
							wrapper.initializeFrom(cmisInfo.getFolderInfo());
							break;

						case CMIS_ITEM:
							wrapper = new CMISItemWrapper(propertyFilter, includeAllowableActions);
							wrapper.initializeFrom(cmisInfo.getItemInfo());
							break;

						case CMIS_POLICY:
							wrapper = new CMISPolicyWrapper(propertyFilter, includeAllowableActions);
							wrapper.initializeFrom(cmisInfo.getPolicyInfo());
							break;

						case CMIS_RELATIONSHIP:
							wrapper = new CMISRelationshipWrapper(propertyFilter, includeAllowableActions);
							wrapper.initializeFrom(cmisInfo.getRelationshipInfo());
							break;

						case CMIS_SECONDARY:
							wrapper = new CMISSecondaryWrapper(propertyFilter, includeAllowableActions);
							wrapper.initializeFrom(cmisInfo.getSecondaryInfo());
							break;
					}
				}
			}
		}

		return wrapper;
	}
1074226
@Nullable
  public static URL uriToUrl(@Nullable Uri uri) {
    if (uri == null) {
      return null;
    }

    try {
      return new URL(uri.toString());
    } catch (java.net.MalformedURLException e) {
      // This should never happen since we got a valid uri
      throw new RuntimeException(e);
    }
  }
946940
View<E> viewForUri(URI location) {
    Preconditions.checkNotNull(location, "Partition location cannot be null");
    PartitionView<E> view = getPartitionView(location);
    if (view == unbounded) {
      return this;
    }
    return view;
  }
493471
public UriComponentsBuilder uri(URI uri) {
		Assert.notNull(uri, "'uri' must not be null");
		this.scheme = uri.getScheme();
		if (uri.isOpaque()) {
			this.ssp = uri.getRawSchemeSpecificPart();
			resetHierarchicalComponents();
		}
		else {
			if (uri.getRawUserInfo() != null) {
				this.userInfo = uri.getRawUserInfo();
			}
			if (uri.getHost() != null) {
				this.host = uri.getHost();
			}
			if (uri.getPort() != -1) {
				this.port = String.valueOf(uri.getPort());
			}
			if (StringUtils.hasLength(uri.getRawPath())) {
				this.pathBuilder = new CompositePathComponentBuilder(uri.getRawPath());
			}
			if (StringUtils.hasLength(uri.getRawQuery())) {
				this.queryParams.clear();
				query(uri.getRawQuery());
			}
			resetSchemeSpecificPart();
		}
		if (uri.getRawFragment() != null) {
			this.fragment = uri.getRawFragment();
		}
		return this;
	}
4149
@Override
    public URI getURI() throws IOException {
        URL url = getURL();
        try {
            return ResourceUtils.toURI(url);
        } catch (URISyntaxException ex) {
            throw new RuntimeException("Invalid URI [" + url + "]", ex);
        }
    }
83
public static String resolveUriPrefix(URI serverURI)
      throws URISyntaxException {
    if (RESTLI_SCHEMES.contains(serverURI.getScheme())) {
      return new URI(serverURI.getScheme(), serverURI.getAuthority(), null, null, null).toString() + "/";
    }

    throw new RuntimeException("Unrecognized scheme for URI " + serverURI);
  }
244414
private String convertRelativeURIToURL(String relativeURI)
    {

        if (relativeURI == null)
        {
            throw new IllegalStateException();
        }
        else
        {
            relativeURI = relativeURI.trim();
        }

        // If the passed URI contains "://" before the query string then it is either an
        // absolute URL or invalid and cannot be converted anyway
        int indexOfSchemeDelimiter = relativeURI.indexOf("://");
        if (indexOfSchemeDelimiter != -1)
        {
            int indexOfQueryString = relativeURI.indexOf('?');

            // If "://" occurs after '?' then it's part of the query string.
            // Otherwise return this absolute (or invalid) URL
            if ((indexOfQueryString == -1) || (indexOfSchemeDelimiter < indexOfQueryString))
            {
                return relativeURI;
            }
        }

        String urlScheme = _request.getScheme();		
        if (com.ibm.ws.webcontainer.osgi.WebContainer.getServletContainerSpecLevel() >= 31) {
            if (relativeURI.startsWith("//")) {
                StringBuffer url = new StringBuffer(urlScheme);
                url.append(":"); // slash slash will be added from the relativeURI
                url.append(relativeURI);
                return url.toString();
            }
        }

        String webAppRootURI = null;
        boolean relativeToRootURI = false;
        try
        {
            webAppRootURI = getWebApp().getContextPath().trim();
            if (webAppRootURI.startsWith("/") == false)
            {
                webAppRootURI = ("/" + webAppRootURI);
            }
        }
        catch (Exception ex)
        {
            com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(ex, "com.ibm.ws.webcontainer.webapp.WebAppDispatcherResponse.convertRelativeURIToURL", "184", this);
            webAppRootURI = "/";
        }

        try
        {
            relativeToRootURI = relativeURI.startsWith("/");

            // If relative URI begins with "./" (current level in URL hierarchy) then remove it
            if (relativeURI.startsWith("./"))
                relativeURI = relativeURI.substring(2);

            IExtendedRequest request = _request;

            // 112000 - begin - there was no reason to have two schemes for handling relative to root vs.
            // not relative to root so redid the section below

            // add the server info to the front of the url
            int urlPort = request.getServerPort();

            StringBuffer url = new StringBuffer(urlScheme);
            url.append("://");
            url.append(request.getServerName());

            // Add the port to the URL if it is not the default one for the scheme
            if (((urlScheme.equals("http") == true) && (urlPort != 80)) || ((urlScheme.equals("https") == true) && (urlPort != 443)))
            {
                url.append(":");
                url.append(urlPort);
            }

            String redirectURL = null;
            if (relativeToRootURI)
            {
                // 115010 - begin
                // if the relative URI begins with '/' and we're in sendRedirect compatibility mode, then make uri 
                // relative to the context root...otherwise, make it relative to the server (no context root)
                if (com.ibm.ws.webcontainer.util.WebContainerSystemProps.getSendRedirectCompatibilty())
                {
                    // append webapp context and relative URI
                    url.append(webAppRootURI);
                    url.append(relativeURI);
                }
                else
                {
                    url.append(relativeURI);
                }
                // 115010 - end
                redirectURL = url.toString();
            }
            else
            {
                // not relative to webapp context root, but relative to the presently
                // invoked URL

                String requestString = HttpUtils.getRequestURL((HttpServletRequest) request).toString();
                String pathInfo = request.getPathInfo();
                // start PI22830
                if(!webAppRootURI.equals("/") && request.getRequestURI().equals(webAppRootURI)){
                    requestString = requestString + "/";
                    if(com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
                        logger.logp(Level.FINE, CLASS_NAME,"convertRelativeURIToURL", "appended / to requestString --> " + requestString);
                } // end PI22830

                if ((pathInfo != null) && (pathInfo.length() > 0))
                {
                    if (!pathInfo.startsWith("/"))
                    {
                        pathInfo = "/" + pathInfo;
                    }
                    //start PK23779

                    if(redirectWithPathInfo || (com.ibm.ws.webcontainer.osgi.WebContainer.getServletContainerSpecLevel() >= 31)){
                        requestString = requestString.substring(0, requestString.lastIndexOf("/"));
                    }
                    else{
                        // Remove the PathInfo from the request
                        requestString = requestString.substring(0, requestString.lastIndexOf(pathInfo));
                    }
                    //end PK23779
                    redirectURL = requestString + "/" + relativeURI;
                }
                else
                {
                    redirectURL = requestString.substring(0, requestString.lastIndexOf('/') + 1) + relativeURI;
                }
            }
            if (redirectURL.indexOf("..") > -1)
            { // only normalize where required.. this is expensive.
                int skip = new String(urlScheme + "://").length();
                int split = redirectURL.indexOf("/", skip);
                String serverString = redirectURL.substring(0, split);
                String uri = redirectURL.substring(split);
                uri = getWebApp().normalize(uri);
                if (uri != null)
                {
                    return serverString + uri;
                }
            }
            else
            { // return url since it is already normalized.
                return redirectURL;
            }
            // 112000 - end
        }
        catch (Exception ex)
        {
            com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(ex, "com.ibm.ws.webcontainer.webapp.WebAppDispatcherResponse.convertRelativeURIToURL", "256", this);
        }

        // Could not convert
        return relativeURI;
    }
1047707
public URI getURI() {
        final URI locationURI = getClasspathElementURI();
        final String resourcePath = getPathRelativeToClasspathElement();
        final String locationURIStr = locationURI.toString();
        // Check if this is a directory-based module (location URI will end in "/")
        final boolean isDir = locationURIStr.endsWith("/");
        try {
            return new URI((isDir || locationURIStr.startsWith("jar:") ? "" : "jar:") + locationURIStr
                    + (isDir ? "" : "!/") + resourcePath);
        } catch (final URISyntaxException e) {
            throw new IllegalArgumentException("Could not form URL for classpath element: " + locationURIStr
                    + " ; path: " + resourcePath + " : " + e);
        }
    }
864718
protected I_CmsCmisRepository getRepository(String repositoryId) {

        I_CmsCmisRepository result = OpenCms.getRepositoryManager().getRepository(
            repositoryId,
            I_CmsCmisRepository.class);
        if (result == null) {
            throw new CmisConnectionException("missing repository: " + repositoryId);
        }
        return result;
    }
1332540
protected CmsObjectWrapper getCms(SrvSession session, TreeConnection connection) throws CmsException {

        CmsJlanRepository repository = ((CmsJlanDeviceContext)connection.getContext()).getRepository();
        CmsObjectWrapper result = repository.getCms(session, connection);
        return result;
    }
964153
@Provides
    @Named(JanusConfig.PUB_URI)
    public static URI getPubURIAsURI() {
        final String v = getPUBURIAsString();
        try {
            return NetworkUtil.toURI(v);
        } catch (URISyntaxException e) {
            throw new IOError(e);
        }
    }
431117
@NonNull
    public static Uri getUri(@NonNull Context context, @NonNull File outPath) {
        Uri uri;
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
            uri = Uri.fromFile(outPath);
        } else {
            uri = CameraFileProvider.getUriForFile(context, CameraFileProvider.getProviderName(context), outPath);
        }
        return uri;
    }
726027
@Override
    URI getURI() {
        final URI uri = moduleRef.getLocation();
        if (uri == null) {
            // Some modules have no known module location (ModuleReference#location() can return null)
            throw new IllegalArgumentException("Module " + getModuleName() + " has a null location");
        }
        return uri;
    }
753120
private FedoraResource getResourceFromSubject(final String subjectUri) {
        final UriTemplate uriTemplate =
            new UriTemplate(uriInfo.getBaseUriBuilder().clone().path(FedoraLdp.class).toTemplate());
        final Map<String, String> values = new HashMap<>();
        uriTemplate.match(subjectUri, values);
        if (values.containsKey("path")) {
            try {
                return translator().convert(translator().toDomain(values.get("path")));
            } catch (final RuntimeException e) {
                if (e.getCause() instanceof PathNotFoundException) {
                    //there is at least one case (ie Time Map endpoints - aka /fcr:versions) where the underlying jcr
                    // node will not exist while the end point is visible to the user.
                    return null;
                } else {
                    throw e;
                }
            }
        }
        return null;
    }
104631
public static URI resolveBase(final URI baseURI, final Stack<URI> stack) throws XIncludeFatalException
    {
        final URI computedUri = XIncProcUtils.computeBase(stack);
        final URI resolvedUri = baseURI.resolve(computedUri);
        if (0 == resolvedUri.compareTo(baseURI))
        {
            throw new XIncludeFatalException("Inclusion loop error");
        }
        return resolvedUri;
    }