SilverStream eXtend
Director 4.0

com.sssw.portal.util
Class EboPortalUrlHelper

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

public class EboPortalUrlHelper
extends Object

Provides methods that 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$
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
          Portal substitution string $MYPORTAL_PATH$
static String PAGE_PATH_SUBST
          Portal substitution string $PAGE_PATH$
static String PORTAL_SERVLET_PATH_SUBST
          Portal substitution string $PORTAL_SERVLET_PATH$
static String PORTAL_SERVLET_URL_SUBST
          Portal substitution string $PORTAL_SERVLET_URL$
static String PORTAL_USERPAGE_NAME_SUBST
          Portal substitution string $PORTAL_SERVLET_PATH$
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_URL_SUBST
          Portal substitution string $THEME_URL$
 
Constructor Summary
EboPortalUrlHelper()
           
 
Method Summary
static String getContextURL(EbiPortalContext context)
          Build a fully qualified URL up through the context
static String getPortalUrl(EbiPortalContext context, String uri)
          Build a full URL based on a URI that may include portal substitution strings.
static String getPortalUrl(EbiPortalContext context, String uri, String baseUri)
          Build a full URL based on a URI that may include portal substitution strings.
static String getServletURL(EbiPortalContext context)
          Constructs the full URL of the current servlet request through 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 equivalent 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

CONTEXT_URL_SUBST

public static final String CONTEXT_URL_SUBST
Portal substitution string $CONTEXT_URL$

An 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$

An URL string beginning with the scheme up through the user's current theme.

Example: $THEME_URL$/edit.gif would be parsed and converted to http://host/context/resource/portal-theme/CurrentTheme where resource is the portal's resource servlet and CurrentTheme is the current user's theme.

Since:
v4.0

SERVLET_URL_SUBST

public static final String SERVLET_URL_SUBST
Portal substitution string $SERVLET_URL$

An 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
Portal substitution string $PORTAL_SERVLET_URL$

An URL string beginning with the scheme up through the portal's 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 is the resource path.

Since:
v4.0

REQUEST_URL_SUBST

public static final String REQUEST_URL_SUBST
Portal substitution string $REQUEST_URL$

An URL string beginning with the scheme up through the current servlet path and including the current request's 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

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 request's extra path info and 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:
v4.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 preceding 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.

The servlet path is the value returned from HttpServletRequest.getServletPath() excluding the preceding slash.

Since:
v4.0

PORTAL_SERVLET_PATH_SUBST

public static final String PORTAL_SERVLET_PATH_SUBST
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
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
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: 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

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/metallic/edit.gif where metallic 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 where the current request URL is http://host/context/main/MyPage/finance and 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 where the page in which the link is placed is http://host/context/main/MyPage/finance and 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 returned 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 scheme 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 that may include portal substitution strings.

Examples:

Parameters:
context - The HttpServletRequest from which the context path should be assembled.
uri - The path 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 that may include portal substitution strings.

Examples:

Parameters:
context - The HttpServletRequest from which the context path should be assembled.
uri - The path 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 fully qualified URL up through the context

Example: for current request URL = http://host/mycontext/servlet?action=delete returns 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 through 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.

Replaces all substitution strings with the runtime replacement.

For example: source = $CONTEXT_URL$ will render the result 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.

Replaces all substitution strings with the runtime replacement.

For example: source = $CONTEXT_URL$ will render the result 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 references so that the returned string can be used in well-formed XML -- &, <, ', " are replaced with &amp;, &lt;, &apos;, and &quot;.
Returns:
The modified string after replacements are made.
Since:
v4.0

SilverStream eXtend
Director 4.0