Skip navigation links
SAP NetWeaver 7.50 SP 13 KMC

Package com.sapportals.wcm.util.uri

Contains interfaces and classes to handle uniform resource identifiers (uri).

See: Description

Package com.sapportals.wcm.util.uri Description

Contains interfaces and classes to handle uniform resource identifiers (uri).

Package Specification

The uri package handles the two worlds of RFC 2396 uris and WCM uris and how they interact.

RFC 2396 Uris

Internet Uris are defined in RFC 2396 - Uniform Resource Identifiers (URI): Generic Syntax. This RFC defines the following terms which are explained here for quick reference:

WCM URIs (Resource IDs)

WCM URIs, a better name would be Resource ID (RID), are used to identify WCM resources on a single server. In contrast to internet uris they What they have in common with internet uris: Examples: '/documents/report.doc' or '/tmp/W�hrung-in-�.txt'.

Query Part in WCM URIs

The string representation of a query part in WCM URIs is the same as in RFC 2396 URIs. The reason for this is that a string representation always needs escaped characters (to represent '=' in values for example), so the RFC 2397 method of encoding a query is applied to WCM URIs as well. The WCM URI class has access methods to get/set a query and handle the correct en-/decoding of query parameters internally. See URI for details.

Mapping of WCM to/from Internet Uris

This package provides mapping functionality to convert WCM uris to Internet uris and vice versa.
When a HTTP server/servlet wants to expose WCM URIs (resource ids) as HTTP uris, it just needs to know where in the HTTP uri hierarchy the WCM resources should be made available.
Example: A servlet resides at 'http://sapportals.com/apps/service' and wants to map request uris to WCM resources. The request for '/apps/service/info/index.txt' should be mapped to the WCM resource '/info/index.html'.
The servlet would do the following when servicing a request:
      HttpUrl m_servletUrl = new HttpUrl(
          m_request.getScheme(), m_request.getServerName(), m_request.getServerPort(), 
          m_request.getContextPath() + m_request.getServletPath(), null);

      IUriReference ref = new UriReference(m_request.getRequestURI(), 
                                           m_request.getQueryString(), null);
      URI uri = m_servletUrl.mapToWcmPath(ref);
      if (uri == null {
        // request uri outside servlet uri? Should not happen
      }
  
First, the http url of the servlet itself is determined. Note that your servlet can be accessible unter many different host names and ports, with or without https. So it is wise to calculate the servlet url on every request. Next the request uri and possible query string are placed in a IUriReference object. As the last step, the uri reference is resolved, using the servlet's uri as base, to the WCM URI (resource id).

The reverse mapping would also use the servlet url. Given a WCM URI, the servlet would either generate a http url or a absolute uri reference to hand out to the client (for example as href in a HTML document):

      URI wcmpath = resource.getURI();
      IUri url = m_servletUrl.mapToAbsoluteUri(wcmpath);
      // or
      IUriReference ref = m_servletUrl.toAbsolutePath(wcmpath);
  
This code would convert the resource id '/info/index.html', given the servlet url 'http://sapportals.com/apps/service' to:

See IHierarchicalUri for further information.

Related Documentation

Skip navigation links
SAP NetWeaver 7.50 SP 13 KMC

Copyright 2018 SAP AG Complete Copyright Notice