Novell exteNd
Director 5.2 API

com.sssw.portal.util
Class EboPortalUrlHelper

java.lang.Object
 |
 +--com.sssw.portal.util.EboPortalUrlHelper

public class EboPortalUrlHelper
extends Object

Provides methods which help retrieve and parse portal URLs

Since:
v4.0

Field Summary
static String COMP_PATH_SUBST
          Portal substitution string $COMP_PATH$
static String COMPONENT_ID_SUBST
          Portal substitution string $COMPONENT_ID$
static String COMPONENT_INSTANCE_ID_SUBST
          Portal substitution string $COMPONENT_INSTANCE_ID$
static String COMPONENT_PATH_SUBST
          Portal substitution string $COMPONENT_PATH$
static String CONTEXT_PATH_SUBST
          Portal substitution string $CONTEXT_PATH$
static String CONTEXT_SUBST
          Portal substitution string $context$ Example: $context$/jsp/PropertySheet.jsp would be parsed and converted to http://host/context/jsp/PropertySheet.jsp Note: This is equivelent to $CONTEXT_URL$ This string is used for compatibility with 3.0, $CONTEXT_URL$ should be used in its place going forward.
static String CONTEXT_URL_SUBST
          Portal substitution string $CONTEXT_URL$
static String ENCODED_REQUEST_URL_SUBST
          Portal substitution string $ENCODED_REQUEST_URL$
static String HOST_PORT_SUBST
          Portal substitution string $HOSTP_PORT$
static String HOST_SUBST
          Portal substitution string $HOST$
static String MYPORTAL_PATH_SUBST
          Deprecated. No Replacement
static String PAGE_PATH_SUBST
          Portal substitution string $PAGE_PATH$
static String PORTAL_SERVLET_PATH_SUBST
          Deprecated. No Replacement
static String PORTAL_SERVLET_URL_SUBST
          Deprecated. No Replacement
static String PORTAL_URL_SUBST
          Portal substitution string $PORTAL_URL$
static String PORTAL_USERPAGE_NAME_SUBST
          Deprecated. No Replacement
static String PORTLET_PATH_SUBST
          Portal substitution string $PORTLET_PATH$
static String REQUEST_URI_SUBST
          Portal substitution string $REQUEST_URI$
static String REQUEST_URL_SUBST
          Portal substitution string $REQUEST_URL$
static String RESOURCE_URL_SUBST
          Portal substitution string $RESOURCE_URL$
static String SCHEME_SUBST
          Portal substitution string $SCHEME$
static String SERVLET_PATH_SUBST
          Portal substitution string $SERVLET_PATH$
static String SERVLET_URL_SUBST
          Portal substitution string $SERVLET_URL$
static String THEME_ID_SUBST
          Portal substitution string $THEME_ID$
static String THEME_PATH_SUBST
          Portal substitution string $THEME_PATH$
static String THEME_URL_SUBST
          Portal substitution string $THEME_URL$
 
Constructor Summary
EboPortalUrlHelper()
           
 
Method Summary
static Document addUtilityNode(EbiPortalContext context, Document doc)
          Adds a portal URL utility node to the passed XML document.
static String getContextURL(EbiPortalContext context)
          Build a fullly qualified URL up through the context
static String getPortalUrl(EbiPortalContext context, String uri)
          Build a full URL based on a URI which may include portal substitution strings.
static String getPortalUrl(EbiPortalContext context, String uri, String baseUri)
          Build a full URL based on a URI which may include portal substitution strings.
static String getServletURL(EbiPortalContext context)
          Constructs the full url of the current servlet request trhought the servlet path.
static String replaceAllKeywordStrings(EbiPortalContext context, String source)
          Replaces all keyword strings
static String replaceAllKeywordStrings(EbiPortalContext context, String source, boolean replaceEntityRefs)
          Replaces all keyword strings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_SUBST

public static final String CONTEXT_SUBST
Portal substitution string $context$ Example: $context$/jsp/PropertySheet.jsp would be parsed and converted to http://host/context/jsp/PropertySheet.jsp Note: This is equivelent to $CONTEXT_URL$ This string is used for compatibility with 3.0, $CONTEXT_URL$ should be used in its place going forward.
See Also:
EboPortalUrlHelper.CONTEXT_URL_SUBST
Since:
v4.0

PORTAL_URL_SUBST

public static final String PORTAL_URL_SUBST
Portal substitution string $PORTAL_URL$

A URL string beginning with the scheme up through the path to the portal. Example: $PORTAL_URL$/pg/PortalHomePage would be parsed and converted to http://host:8008/context/portal/pg/PortalHomePage

Since:
v5.0

CONTEXT_URL_SUBST

public static final String CONTEXT_URL_SUBST
Portal substitution string $CONTEXT_URL$

A URL string beginning with the scheme up through the current web application context Example: $CONTEXT_URL$/jsp/PropertySheet.jsp would be parsed and converted to http://host/context/jsp/PropertySheet.jsp

Since:
v4.0

THEME_URL_SUBST

public static final String THEME_URL_SUBST
Portal substitution string $THEME_URL$

A URL string beginning with the scheme up through the users current theme Example: $THEME_URL$/edit.gif would be parsed and converted to http://host/context/resource/portal-theme/CurrentTheme where resource is teh portal's resource servlet and CurrentTheme is the current user's theme.

Since:
v4.0

THEME_PATH_SUBST

public static final String THEME_PATH_SUBST
Portal substitution string $THEME_PATH$

An absolute path string beginning with the context up through the users current theme directory Example: $THEME_PATH$/edit.gif would be parsed and converted to /context/resource/portal-theme/CurrentTheme where resource is the portal's resource servlet and CurrentTheme is the current user's theme.

Since:
v5.0

SERVLET_URL_SUBST

public static final String SERVLET_URL_SUBST
Portal substitution string $SERVLET_URL$

A URL string beginning with the scheme up through current servlet path Example: $SERVLET_URL$ would be parsed and converted to http://host/context/servletPath

Since:
v4.0

PORTAL_SERVLET_URL_SUBST

public static final String PORTAL_SERVLET_URL_SUBST
Deprecated. No Replacement

Portal substitution string $PORTAL_SERVLET_URL$

A URL string beginning with the scheme up through the portals controller servlet path specified by the web.xml context-param entry "PortalControllerServletPath". Example: $PORTAL_SERVLET_URL$ would be parsed and converted to http://host/context/main where main is the default servlet path of the portal controller servlet.

Since:
v4.0

RESOURCE_URL_SUBST

public static final String RESOURCE_URL_SUBST
Portal substitution string $RESOURCE_URL$

A string representing the fully qualified URL to the resource servlet Example: $RESOURCE_URL$/portal-general/images/Hello.gif would be parsed and converted to http://host/ResourceSet/resource/portal-general/images/Hello.gif where "ResourceSet" is the context of the resource set servlet and "resource" the resource path.

Since:
v4.0

REQUEST_URL_SUBST

public static final String REQUEST_URL_SUBST
Portal substitution string $REQUEST_URL$

A URL string beginning with the scheme up through the current servlet path and including the current requests extra path info and query information. Example: $REQUEST_URL$?mode=new to http://host/context/edit.jsp?mode=new Where http://host/context/edit.jsp is the value returned from the method getRequestURL() off of the current request.

Since:
v4.0

REQUEST_URI_SUBST

public static final String REQUEST_URI_SUBST
Portal substitution string $REQUEST_URI$

A absolute path string beginning with the context path through the current servlet path and including the current requests extra path info.

This uri will also be encoded with teh jsession id if the browsers does not support in-memory cookies

Example: $REQUEST_URI$?mode=new to /context/edit.jsp?mode=new

or (for cookieless browsers) to /context/edit.jsp;jsessionid=7812412471244?mode=new

Where /context/edit.jsp is the value returned from the method getRequestURI() off of the current request.

Since:
v4.0

ENCODED_REQUEST_URL_SUBST

public static final String ENCODED_REQUEST_URL_SUBST
Portal substitution string $ENCODED_REQUEST_URL$

An URL encoded URL string beginning with the scheme up through the current servlet path and including the current requests extra path info but not the query information. Example: http://host/catalog?callingpage=$ENCODED_REQUEST_URL$ to http://host/catalog/callingpage=http%3A%2F%2Flocalhost%2FPortal%2Fmain%2FMyPortal%2FMyProfile Where http://host/context/edit.jsp is the value returned from HttpServletRequest.getRequestURL().

Since:
v5.0

CONTEXT_PATH_SUBST

public static final String CONTEXT_PATH_SUBST
Portal substitution string $CONTEXT_PATH$

Example: http://host/$CONTEXT_PATH$/main to http://host/Portal/main where Portal is the value returned from HttpServletRequest.getContextPath() excluding the preceeding slash.

Since:
v4.0

SERVLET_PATH_SUBST

public static final String SERVLET_PATH_SUBST
Portal substitution string $SERVLET_PATH$

Example: $CONTEXT_URL$/$SERVLET_PATH$ to http://host/context/custom.jsp In this case the servlet path is the value returned from HttpServletRequest.getServletPath() excluding the preceeding slash.

Since:
v4.0

PORTAL_SERVLET_PATH_SUBST

public static final String PORTAL_SERVLET_PATH_SUBST
Deprecated. No Replacement

Portal substitution string $PORTAL_SERVLET_PATH$

Example: $CONTEXT_URL$/$PORTAL_SERVLET_PATH$/comp/HelloWorld would be parsed and converted to http://host/context/main/comp/HelloWorld The portal servlet path is the main path to the portal controller servlet. Specified by the context param "PortalControllerServletPath"

Since:
v4.0

PORTAL_USERPAGE_NAME_SUBST

public static final String PORTAL_USERPAGE_NAME_SUBST
Deprecated. No Replacement

Portal substitution string $PORTAL_SERVLET_PATH$

The name of the Portal User Page (e.g. MyFinance) Example: $PORTAL_USERPAGE_NAME$ would be parsed and converted to MyFinance (or whatever the current User Page is) The portal user page name is the name given to a page created by a user.

Since:
v4.0

MYPORTAL_PATH_SUBST

public static final String MYPORTAL_PATH_SUBST
Deprecated. No Replacement

Portal substitution string $MYPORTAL_PATH$

Example: $CONTEXT_URL$/$PORTAL_SERVLET_PATH$/$MYPORTAL_PATH$ to http://host/context/main/myportal Where "myportal" is the extra path information off of the controller servlet that tells the servlet to serve the user's personalized pages specified by the web.xml context param "PortalPathMyPortalKey"

Since:
v4.0

PAGE_PATH_SUBST

public static final String PAGE_PATH_SUBST
Portal substitution string $PAGE_PATH$

Example: $CONTEXT_URL$/$PORTAL_SERVLET_PATH$/$PAGE_PATH$/helloWorldPID.html to http://host/context/main/page/helloWorldPID.html Where "page" is the extra path information off of the controller servlet that tells the servlet to serve the PID pages specified by the web.xml context param "PortalPathPagesKey"

Since:
v4.0

COMPONENT_PATH_SUBST

public static final String COMPONENT_PATH_SUBST
Portal substitution string $COMPONENT_PATH$

Example: $CONTEXT_URL$/$PORTAL_SERVLET_PATH$/$COMPONENT_PATH$/HelloWorldComponent to http://host/context/main/component/HelloWorldComponent Where "component" is the extra path information off of the controller servlet that tells the servlet to serve a single decorated component specified by the web.xml context param "PortalPathComponentKey"

Since:
v4.0

COMP_PATH_SUBST

public static final String COMP_PATH_SUBST
Portal substitution string $COMP_PATH$

Example: $CONTEXT_URL$/$PORTAL_SERVLET_PATH$/$COMPONENT_PATH$/HelloWorldComponent to http://host/context/main/comp/HelloWorldComponent Where "comp" is the extra path information off of the controller servlet that tells the servlet to serve a single non-decorated component specified by the web.xml context param "PortalPathCompKey"

Since:
v4.0

PORTLET_PATH_SUBST

public static final String PORTLET_PATH_SUBST
Portal substitution string $PORTLET_PATH$

Example: $PORTLET_PATH$/HelloWorldPortlet to http://host/context/portal/portlet/HelloWorldPortlet Where "portlet" is the extra path information off of the controller servlet that tells the portal to serve a single non-decorated portlet specified by the web.xml context param "PortalPathPortletKey"

Since:
v5.0

THEME_ID_SUBST

public static final String THEME_ID_SUBST
Portal substitution string $THEME_ID$

The theme ID of the user's currently selecetd theme. If no user is logged in or the user does not have a selected theme the portal's default theme will be used. The default theme is specified by the web.xml context param "PortalDefaultTheme" Example: $CONTEXT_URL$/$PORTAL_SERVLET_PATH$/$RESOURCE_PATH$/portal-theme/$THEMEID$/edit.gif to http://host/context/main/resource/portal-theme/metalic/edit.gif Where "metalic" is the user's current theme ID

Since:
v4.0

COMPONENT_ID_SUBST

public static final String COMPONENT_ID_SUBST
Portal substitution string $COMPONENT_ID$

The currently executing componentID retrieved from EbiPortalContext.getComponentID() Example: ?ss_action=remove&ss_comp=$COMPONENT_ID$&ss_instance=$COMPONENT_INSTANCE_ID$ to http://host/context/main/MyPage/finance?ss_action=remove&ss_comp=HelloWorld&ss_instance=123145 Assuming the current request URL is http://host/context/main/MyPage/finance Where "HelloWorld" is the current component

Since:
v4.0

COMPONENT_INSTANCE_ID_SUBST

public static final String COMPONENT_INSTANCE_ID_SUBST
Portal substitution string $COMPONENT_INSTANCE_ID$

The currently executing component instance retrieved from EbiPortalContext.getComponentInstanceName() Example: ?ss_action=remove&ss_comp=$COMPONENT_ID$&ss_instance=$COMPONENT_INSTANCE_ID$ to http://host/context/main/MyPage/finance?ss_action=remove&ss_comp=HelloWorld&ss_instance=123456 Assuming the page in which the link is placed us http://host/context/main/MyPage/finance Where "123456" is the current component instance ID This replacement string might be used in a component or option descriptor.

Since:
v4.0

SCHEME_SUBST

public static final String SCHEME_SUBST
Portal substitution string $SCHEME$

Example: $SCHEME$://host to http://host Where http is the string returned from HttpServeltRequest.getScheme() off of the current request

Since:
v4.0

HOST_SUBST

public static final String HOST_SUBST
Portal substitution string $HOST$

Example: $SCHEME$://$HOST$ to http://myhost Where myhost is the string retruned from HttpServeltRequest.getServerName() for the current request

Since:
v4.0

HOST_PORT_SUBST

public static final String HOST_PORT_SUBST
Portal substitution string $HOSTP_PORT$

Example: $SCHEME$://$HOST_PORT$ to http://myhost:9090 Where myhost is the string returned from HttpServeltRequest.getServerName() and 9090 is the string returned from a call to HttpServletRequest.getServerPort() for the current request If the current port is a default for the shceme specified, then the port will be left out

Since:
v4.0
Constructor Detail

EboPortalUrlHelper

public EboPortalUrlHelper()
Method Detail

getPortalUrl

public static String getPortalUrl(EbiPortalContext context,
                                  String uri)
Build a full URL based on a URI which may include portal substitution strings.

Example: "?action=test" resolves to the current requests URL with this value appended "/test.html" resolves to http://host/test.html where host is the current machine host "http://host/test.html" since this is already a valid http URL no resolution is performed the result is "http://host/test.html"

Parameters:
context - - the EbiPortalContext from which the path should be assembled
uri - - the path which we'll use to create a full URL path
Returns:
A fully qualified URL
Since:
v4.0

getPortalUrl

public static String getPortalUrl(EbiPortalContext context,
                                  String uri,
                                  String baseUri)
Build a full URL based on a URI which may include portal substitution strings.

Example: "action=test" resolves to the base URI with this value appended "/test.html" resolves to http://host/test.html where host is the current machine host "http://host/test.html" since this is already a valid http URL no resolution is performed the result is "http://host/test.html"

Parameters:
req - - the HttpServletRequest from which the context path should be assembled
uri - - the path which we'll use to create a full URL path
baseUri - - The path which will be used as the base URI if the URI does not start with "/" or "http://" for relative references.
Returns:
A fully qualified URL

getContextURL

public static String getContextURL(EbiPortalContext context)
Build a fullly qualified URL up through the context

Example: for current request URL = http://host/mycontext/servlet?action=delete return http://host/mycontext

Parameters:
context - - the current portal context
Returns:
A fully qualified string URL
Since:
v4.0

getServletURL

public static String getServletURL(EbiPortalContext context)
Constructs the full url of the current servlet request trhought the servlet path.

Example: for current request URL = http://host/mycontext/servlet?action=delete return http://host/mycontext/servlet

Returns:
A fully qualified URL string
Since:
v4.0

replaceAllKeywordStrings

public static String replaceAllKeywordStrings(EbiPortalContext context,
                                              String source)
Replaces all keyword strings

Replace all substitution strings with the runtime replacement. For example: source = $CONTEXT_URL$ will render a result of http://host/context where host is the current host (req.getServlerName()) from the request and context is the current context from the request (req.getServletContext())

Parameters:
context - - the portal context
source - - The original string
Returns:
the modified string after replacements are made
Since:
v4.0

replaceAllKeywordStrings

public static String replaceAllKeywordStrings(EbiPortalContext context,
                                              String source,
                                              boolean replaceEntityRefs)
Replaces all keyword strings

Replace all substitution strings with the runtime replacement. For example: source = $CONTEXT_URL$ will render a result of http://host/context where host is the current host (req.getServlerName()) from the request and context is the current context from the request (req.getServletContext()) All &'s are replaced with the & entity reference so that the returned value can be added to a well formed xml document for parsing.

Parameters:
context - - the portal context
source - - The original string
replaceEntityRefs - - if true replaces entity refs so that the returned string can be used in well formed xml &, <, ', " are replaced with &, <, ', and "
Returns:
the modified string after replacements are made
Since:
v4.0

addUtilityNode

public static Document addUtilityNode(EbiPortalContext context,
                                      Document doc)
                               throws EboFactoryException
Adds a portal URL utility node to the passed XML document.

This method will create an node in the passed XML document. This utility node contains many prortal URL values that XSL writers may find useful when writing XSL for components. An example of the s3-utility node follows: DocumentCheckouts Checkouts1 /pages/PmcDocumentCheckouts.html /dlite/main/pages/PmcDocumentCheckouts.html http localhost 8080 /main http://localhost:8080/dlite http://localhost:8080 http://localhost:8080/dlite/resource

Parameters:
context - - the portal context
doc - - the original XML document
Returns:
the modified XML document
Since:
firewater-phase1

Novell exteNd
Director 5.2 API