Package org.ametys.web
Class URIPrefixHandler
- java.lang.Object
-
- org.ametys.web.URIPrefixHandler
-
- All Implemented Interfaces:
Component
,Contextualizable
,Serviceable
public class URIPrefixHandler extends Object implements Serviceable, Contextualizable, Component
Component providing base paths for computing URIs.
-
-
Field Summary
Fields Modifier and Type Field Description private Context
_context
private RenderingContextHandler
_renderingContexthandler
private SiteManager
_siteManager
static String
ROLE
Avalon role
-
Constructor Summary
Constructors Constructor Description URIPrefixHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
contextualize(Context context)
String
getAbsoluteUriPrefix()
Get the absolutized version of the context path.String
getAbsoluteUriPrefix(String siteName)
Get an absolutized version of the workspace context path.String
getUriPrefix()
Get the application context path.String
getUriPrefix(String siteName)
Get the full path to the workspace with site name.void
service(ServiceManager manager)
-
-
-
Field Detail
-
_renderingContexthandler
private RenderingContextHandler _renderingContexthandler
-
_siteManager
private SiteManager _siteManager
-
-
Constructor Detail
-
URIPrefixHandler
public URIPrefixHandler()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getUriPrefix
public String getUriPrefix()
Get the application context path. Can be empty if the application resides in the root context. Use it to create a link beginning with the application root.- Returns:
- The application context path.
- See Also:
Request.getContextPath()
-
getUriPrefix
public String getUriPrefix(String siteName)
Get the full path to the workspace with site name. If the current workspace is the default one, the workspace path part will be empty. Use it when creating site-dependent links, such as page URIs.- Parameters:
siteName
- the current site name.- Returns:
- The workspace context path with site name.
-
getAbsoluteUriPrefix
public String getAbsoluteUriPrefix()
Get the absolutized version of the context path. Use it to create an absolute link beginning with the application root, for instance when sending a mail linking to the application.- Returns:
- The absolute context path.
-
getAbsoluteUriPrefix
public String getAbsoluteUriPrefix(String siteName)
Get an absolutized version of the workspace context path. Use it when linking to a page or an URI from outside the server, for instance when sending a link to a specific page in an e-mail.- Parameters:
siteName
- The name of the current site.- Returns:
- The absolute workspace context path.
-
-