Package org.sakaiproject.portal.util
Class ToolUtils
- java.lang.Object
-
- org.sakaiproject.portal.util.ToolUtils
-
public class ToolUtils extends Object
A set of utilities provided by the portal for use by tools. Some of the methods pull the HttpServletRequest from ThreadLocal. This means they will fail badly if called before the RequestFilter is run. Generally this means that the calls are safe in core tool code.
-
-
Field Summary
Fields Modifier and Type Field Description static StringPORTAL_INLINE_EXPERIMENTALstatic booleanPORTAL_INLINE_EXPERIMENTAL_DEFAULT
-
Constructor Summary
Constructors Constructor Description ToolUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SitePagegetPageForTool(Site site, String toolId)Look through the pages in a site and find the page that corresponds to a tool.static StringgetPageUrl(HttpServletRequest req, Site site, SitePage page)Captures the rules for getting the URL of a page suitable for a GET requeststatic StringgetPageUrl(HttpServletRequest req, Site site, SitePage page, String portalPrefix)Captures the rules for getting the URL of a page suitable for a GET requeststatic StringgetPageUrl(HttpServletRequest req, Site site, SitePage page, String portalPrefix, boolean reset, String effectiveSiteId, String pageAlias)Captures the rules for getting the URL of a page suitable for a GET requeststatic StringgetPageUrl(Site site, SitePage page)Captures the rules for getting the URL of a page suitable for a GET request (call only from the tool)static StringgetPageUrlForTool(HttpServletRequest req, Site site, ToolConfiguration pageTool)Look through the pages in a site and get the page URL for a tool.static HttpServletRequestgetRequestFromThreadLocal()Get the servlet request from thread local - call only after RequestFilter has runstatic StringgetRequestParameter(String key)Retriece a request parameter from ThreadLocal (only works after RequestFilter runs)static StringgetToolBaseUrl()Get the base URL for tools not including the ToolId (only works in tools)static StringgetToolBaseUrl(HttpServletRequest req)Get the base URL for tools not including the ToolIdstatic StringgetToolBorderlessBaseUrl()Get the base URL for tools with no "border" - (i.e. within an iframe)static StringgetToolPopupUrl(ToolConfiguration pageTool)Captures the rules for the various tools and when they want a popupstatic booleanisInlineRequest(HttpServletRequest req)Determine if this is an inline request.static booleanisPortletPlacement(Placement placement)Determine if a particular placement is a JSR-168 portlet placement
-
-
-
Field Detail
-
PORTAL_INLINE_EXPERIMENTAL
public static final String PORTAL_INLINE_EXPERIMENTAL
- See Also:
- Constant Field Values
-
PORTAL_INLINE_EXPERIMENTAL_DEFAULT
public static final boolean PORTAL_INLINE_EXPERIMENTAL_DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
isInlineRequest
public static boolean isInlineRequest(HttpServletRequest req)
Determine if this is an inline request.- Type Parameters:
code- req The request object. If you have no access to the request object, you can leave this null and we will try to pull the request from ThreadLocal - if we fail it is a RunTime exception.- Returns:
- True if this is a request where a tool will be inlined.
-
getPageUrl
public static String getPageUrl(Site site, SitePage page)
Captures the rules for getting the URL of a page suitable for a GET request (call only from the tool)- Type Parameters:
code- site The site that contains the pagecode- page The page URL. If this has a logged in session, we use it to set the default prefix if available. This will use the default prefix if called without a session (i.e. through /direct).
-
getPageUrl
public static String getPageUrl(HttpServletRequest req, Site site, SitePage page)
Captures the rules for getting the URL of a page suitable for a GET request- Type Parameters:
code- req The request object. If you have no access to the request object, you can leave this null and we will try to pull the request from ThreadLocal - if we fail it is a RunTime exception.code- site The site that contains the pagecode- page The page URL. If this has a logged in session, we use it to set the default prefix if available. This will use the default prefix if called without a session (i.e. through /direct).
-
getPageUrl
public static String getPageUrl(HttpServletRequest req, Site site, SitePage page, String portalPrefix)
Captures the rules for getting the URL of a page suitable for a GET request- Type Parameters:
code- req The request object.code- site The site that contains the pagecode- page The pagecode- portalPrefix The controlling portal. Typically "site". No slashes should be included
-
getPageUrl
public static String getPageUrl(HttpServletRequest req, Site site, SitePage page, String portalPrefix, boolean reset, String effectiveSiteId, String pageAlias)
Captures the rules for getting the URL of a page suitable for a GET request- Type Parameters:
code- req The request object. If you have no access to the request object, you can leave this null and we will try to pull the request from ThreadLocal - if we fail it is a RunTime exception.code- site The site that contains the pagecode- page The pagecode- portalPrefix The controlling portal. Typically "site". No slashes should be includedcode- reset Should we reset the tool as part of this GET reference (typically true)code- effectiveSiteId The effective site IDcode- pageAlias The alias for the page (typically null)- Returns:
- The url for the page.
-
getToolPopupUrl
public static String getToolPopupUrl(ToolConfiguration pageTool)
Captures the rules for the various tools and when they want a popup- Type Parameters:
code- pageTool The tools configuration object.- Returns:
- The url to be uded in the popup of null of there is no tool-requested popup.
-
getPageForTool
public static SitePage getPageForTool(Site site, String toolId)
Look through the pages in a site and find the page that corresponds to a tool.- Type Parameters:
code- site The sitecode- toolId The placement / tool ID- Returns:
- The page if found otherwise null.
-
getPageUrlForTool
public static String getPageUrlForTool(HttpServletRequest req, Site site, ToolConfiguration pageTool)
Look through the pages in a site and get the page URL for a tool.- Type Parameters:
code- req The request object. If you have no access to the request object, you can leave this null and we will try to pull the request from ThreadLocal - if we fail it is a RunTime exception.code- site The sitecode- pageTool The placement / tool configuration- Returns:
- The page if found otherwise null.
-
isPortletPlacement
public static boolean isPortletPlacement(Placement placement)
Determine if a particular placement is a JSR-168 portlet placement- Type Parameters:
code- placement The actual placement.- Returns:
- Returns true for JSR_168 portlets
-
getToolBorderlessBaseUrl
public static String getToolBorderlessBaseUrl()
Get the base URL for tools with no "border" - (i.e. within an iframe)
-
getToolBaseUrl
public static String getToolBaseUrl()
Get the base URL for tools not including the ToolId (only works in tools)
-
getToolBaseUrl
public static String getToolBaseUrl(HttpServletRequest req)
Get the base URL for tools not including the ToolId- Type Parameters:
code- req The request object. If you have no access to the request object, you can leave this null and we will try to pull the request from ThreadLocal - if we fail it is a RunTime exception.- Returns:
- Returns true for JSR_168 portlets
-
getRequestFromThreadLocal
public static HttpServletRequest getRequestFromThreadLocal()
Get the servlet request from thread local - call only after RequestFilter has run- Returns:
- Returns the current servlet request or throws runtime error
-
-