Class AppPathService
- java.lang.Object
-
- fr.paris.lutece.portal.service.util.AppPathService
-
public final class AppPathService extends java.lang.Objectthis class provides services for locate repository or url
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSESSION_BASE_URL
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static UrlItembuildRedirectUrlItem(java.lang.String strRootUrl, java.lang.String strUrlPropertySuffixKey)Build the url item to use for a url that includes the redirection parameter for reconnection.static java.lang.StringgetAbsolutePathFromRelativePath(java.lang.String strDirectory)Returns the absolute path of a repository from a relative pathstatic java.lang.StringgetAbsoluteUrl(javax.servlet.http.HttpServletRequest request, java.lang.String strUrl)Returns the absolute url corresponding to the given one, if the later was found to be relative.static java.lang.StringgetAdminMenuUrl()Returns the admin menu page relative url (jsp/admin/site/AdminMenu.jsp) defined in lutece.propertiesstatic java.lang.StringgetAdminPortalUrl()Returns the admin portal page relative url (jsp/admin/site/AdminSite.jsp) defined in lutece.propertiesstatic ReferenceListgetAvailableVirtualHosts()Gets available virtual hosts defined in the config.propertiesstatic java.lang.StringgetBaseUrl()Deprecated.UsegetBaseUrl(HttpServletRequest)insteadstatic java.lang.StringgetBaseUrl(javax.servlet.http.HttpServletRequest request)Return the url of the webapp, built from the requeststatic java.lang.StringgetPath(java.lang.String strKey)Returns the absolute path of a repository from a relative definition in properties filestatic java.lang.StringgetPath(java.lang.String strKey, java.lang.String strFilename)Returns the absolute path of file from its relative definition in properties file.static java.lang.StringgetPortalUrl()Returns the portal page relative url (jsp/site/Portal.jsp) defined in lutece.propertiesstatic java.lang.StringgetProdUrl(java.lang.String strBaseUrl)Return the webapp prod url.static java.lang.StringgetProdUrl(javax.servlet.http.HttpServletRequest request)Return the webapp prod url (or the base url if no prod url has been definied).static java.io.FileInputStreamgetResourceAsStream(java.lang.String strPath, java.lang.String strFilename)Gets a file as streamstatic java.lang.StringgetRootForwardUrl()Returns the forward URL for webapp's root path.static java.lang.StringgetSiteMessageUrl()Returns the Site Message relative url (jsp/site/SiteMessage.jsp) defined in lutece.propertiesstatic java.lang.StringgetSiteMessageUrl(javax.servlet.http.HttpServletRequest request)Return the url of the webapp, built from the requeststatic java.lang.StringgetVirtualHostKey(javax.servlet.http.HttpServletRequest request)Gets a Virtual Host Key if the request contains a virtual host keystatic java.lang.StringgetWebappInstance()Gets the webapp instance defined in the config.properties file with the key lutece.webapp.instancestatic java.lang.StringgetWebAppPath()Returns the webapp path from the properties filestatic voidinit(java.lang.String strWebAppPath)Initialize The webapppathstatic voidinit(javax.servlet.ServletContext context)Initialize The path servicestatic booleanisDefaultWebappInstance()Returns whether the current instance is the default webapp instancestatic UrlItemresolveRedirectUrl(javax.servlet.http.HttpServletRequest request, java.lang.String strDefaultRedirectUrl)Retrieve the url to redirect to after login.
-
-
-
Field Detail
-
SESSION_BASE_URL
public static final java.lang.String SESSION_BASE_URL
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public static void init(javax.servlet.ServletContext context)
Initialize The path service- Parameters:
context- The servlet context
-
init
public static void init(java.lang.String strWebAppPath)
Initialize The webapppath- Parameters:
strWebAppPath- The Webapp path
-
getPath
public static java.lang.String getPath(java.lang.String strKey)
Returns the absolute path of a repository from a relative definition in properties file- Parameters:
strKey- the repository key definied in properties file- Returns:
- the repository absolute path
-
getWebAppPath
public static java.lang.String getWebAppPath()
Returns the webapp path from the properties file- Returns:
- the webapp path
-
getPath
public static java.lang.String getPath(java.lang.String strKey, java.lang.String strFilename)Returns the absolute path of file from its relative definition in properties file.- Parameters:
strKey- the repository key defined in properties filestrFilename- The name of file- Returns:
- the absolute path of file
-
getResourceAsStream
public static java.io.FileInputStream getResourceAsStream(java.lang.String strPath, java.lang.String strFilename)Gets a file as stream- Parameters:
strPath- the pathstrFilename- The name of file- Returns:
- a FileInput Stream object
-
getAbsolutePathFromRelativePath
public static java.lang.String getAbsolutePathFromRelativePath(java.lang.String strDirectory)
Returns the absolute path of a repository from a relative path- Parameters:
strDirectory- the relative path- Returns:
- the repository absolute path
-
getBaseUrl
public static java.lang.String getBaseUrl(javax.servlet.http.HttpServletRequest request)
Return the url of the webapp, built from the request- Parameters:
request- The HttpServletRequest- Returns:
- strBase the webapp url
-
getBaseUrl
@Deprecated public static java.lang.String getBaseUrl()
Deprecated.UsegetBaseUrl(HttpServletRequest)insteadReturn the url of the webapp. The method should only be used out of request context (by daemons for example). If there is a request context, usegetBaseUrl(HttpServletRequest)instead.- Returns:
- The webapp url, or null if the 'lutece.base.url' property has not been set.
-
getProdUrl
public static java.lang.String getProdUrl(javax.servlet.http.HttpServletRequest request)
Return the webapp prod url (or the base url if no prod url has been definied).- Parameters:
request- The HTTP request- Returns:
- The prod url
-
getProdUrl
public static java.lang.String getProdUrl(java.lang.String strBaseUrl)
Return the webapp prod url. If no prod URL has been defined, then the base URL is returned- Parameters:
strBaseUrl- The base URL- Returns:
- The prod url
-
getSiteMessageUrl
public static java.lang.String getSiteMessageUrl(javax.servlet.http.HttpServletRequest request)
Return the url of the webapp, built from the request- Parameters:
request- The HttpServletRequest- Returns:
- strBase the webapp url
-
getPortalUrl
public static java.lang.String getPortalUrl()
Returns the portal page relative url (jsp/site/Portal.jsp) defined in lutece.properties- Returns:
- the Portal Url
-
getRootForwardUrl
public static java.lang.String getRootForwardUrl()
Returns the forward URL for webapp's root path. Default is (jsp/site/Portal.jsp) defined in lutece.properties- Returns:
- the Portal Root forward Url
-
getSiteMessageUrl
public static java.lang.String getSiteMessageUrl()
Returns the Site Message relative url (jsp/site/SiteMessage.jsp) defined in lutece.properties- Returns:
- the SiteMessage Url
-
getAdminPortalUrl
public static java.lang.String getAdminPortalUrl()
Returns the admin portal page relative url (jsp/admin/site/AdminSite.jsp) defined in lutece.properties- Returns:
- the Portal Url
-
getAdminMenuUrl
public static java.lang.String getAdminMenuUrl()
Returns the admin menu page relative url (jsp/admin/site/AdminMenu.jsp) defined in lutece.properties- Returns:
- the Admin Menu Url
-
getAvailableVirtualHosts
public static ReferenceList getAvailableVirtualHosts()
Gets available virtual hosts defined in the config.properties- Returns:
- A reference list containing the key and the description of each virtual host configuration. The list is empty if there is no configuration defined.
-
getVirtualHostKey
public static java.lang.String getVirtualHostKey(javax.servlet.http.HttpServletRequest request)
Gets a Virtual Host Key if the request contains a virtual host key- Parameters:
request- The HTTP request- Returns:
- A Virtual Host Key if present, otherwise null.
-
buildRedirectUrlItem
public static UrlItem buildRedirectUrlItem(java.lang.String strRootUrl, java.lang.String strUrlPropertySuffixKey)
Build the url item to use for a url that includes the redirection parameter for reconnection.- Parameters:
strRootUrl- the root part of the url, to build an absolute urlstrUrlPropertySuffixKey- The property suffix to retrieve the url- Returns:
- an absolute url, completed with the redirectUrl parameter (contains the relative part of the url), as an UrlItem
-
resolveRedirectUrl
public static UrlItem resolveRedirectUrl(javax.servlet.http.HttpServletRequest request, java.lang.String strDefaultRedirectUrl)
Retrieve the url to redirect to after login. It is given by the redirectUrl parameter if found. The request parameters are copied (except the login and acces code and token). This is to be used by the doLogin method of AdminLoginJspBean.- Parameters:
request- the http requeststrDefaultRedirectUrl- the default url to go to after login- Returns:
- an UrlItem corresponding to the url to redirect to after login.
-
getAbsoluteUrl
public static java.lang.String getAbsoluteUrl(javax.servlet.http.HttpServletRequest request, java.lang.String strUrl)Returns the absolute url corresponding to the given one, if the later was found to be relative. An url starting with "http://" is absolute. A relative url should be given relatively to the webapp root.- Parameters:
request- the http request (provides the base path if needed)strUrl- the url to transform- Returns:
- the corresonding absolute url
-
getWebappInstance
public static java.lang.String getWebappInstance()
Gets the webapp instance defined in the config.properties file with the key lutece.webapp.instance- Returns:
- The instance name
- Since:
- 4.1
-
isDefaultWebappInstance
public static boolean isDefaultWebappInstance()
Returns whether the current instance is the default webapp instance- Returns:
- true if default, otherwise false
-
-