Class ResourceHelper

java.lang.Object
com.jalios.jcms.ResourceHelper
All Implemented Interfaces:
JPropertiesListener

public class ResourceHelper extends Object implements JPropertiesListener
Helper class used to retrieve relative paths of jsp/servlet or icons used for various features of JCMS.
Since:
jcms-5.7.0
  • Field Details

  • Method Details

    • canBeAccessed

      public static boolean canBeAccessed(String jspRelativePath, JcmsJspContext jcmsContext)
      Check if the specified JSP is authorized to be accessed (either directly or through dynamic include).

      This check is performed only if enabled through following property :
      jcms.resource.prevent-access-to-overriden-jsp: true

      As of current version, this method enforce the following rules :

      • access to JSP that can be modified though ResourceHelper and that were overriden by in properties are forbidden.
        Unless a property {original-resource-property-name}.authorize-original-jsp-access: true is declared to exclude the JSP from this behavior, (see front/logout.jsp in the example below)
      • All other JSP can be accessed (which does not mean that each JSP will not apply other specific verification regarding authorization).

      Example :
      jcms.prop contains the following properties :

       jcms.resource.prevent-access-to-overriden-jsp: true
       
       jcms.resource.login:  front/login.jsp
       jcms.resource.logout: front/logout.jsp
       jcms.resource.logout.authorize-original-jsp-access: true
       
      And a plugin overrides some of them as follow :
       jcms.resource.login:  plugins/MyPlugin/jsp/login.jsp
       jcms.resource.logout: plugins/MyPlugin/jsp/logout.jsp
       
      In such case, access to front/login.jsp is forbidden, while front/logout.jsp is still authorized.
      Parameters:
      jspRelativePath - the relative path of the JSP being accessed, path may or may not start with a slash, e.g : "/front/login.jsp" or "front/login.jsp"
      jcmsContext - current JcmsJspContext (optional)
      Returns:
      true if JSP can be acccessed, false otherwise
      Since:
      jcms-8.0.2, jcms-9.0 (JCMS-3288)
    • getLogin

      public static String getLogin()
      Retrieve the relative path of the "login" jsp/servlet that should be used when accessing a site.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.0
    • getForbidden

      public static String getForbidden()
      Retrieve the relative path of the "forbidden" jsp/servlet that should be used when accessing a site.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-10.0.3
    • getMailPassword

      public static String getMailPassword()
      Retrieve the relative path of the "mail password" jsp/servlet that should be used when providing a way for a user to retrieve its password.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.0
    • getPrivateLogin

      public static String getPrivateLogin()
      Retrieve the relative path of the "private login" jsp/servlet that should be used when accessing a private site (where authentication is required).
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.0
    • getPrivateMailPassword

      public static String getPrivateMailPassword()
      Retrieve the relative path of the "private mail password" jsp/servlet that should be used when providing a way for a user to retrieve its password when the site is private (where authentication is required).
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.0
    • getLogout

      public static String getLogout()
      Retrieve the relative path of the "logout" jsp/servlet that should be used when quitting a site.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.0
    • getWorkspaceWizard

      public static String getWorkspaceWizard()
      Retrieve the relative path of the "workspaceWizard" jsp/servlet.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.3
    • getWorkspacesList

      public static String getWorkspacesList()
      Retrieve the relative path of the "workspacesList" jsp/servlet .
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.3
    • getDefaultSkin

      public static String getDefaultSkin()
      Retrieve the relative path of the "default skin" jsp/servlet .
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.3
    • getDefaultTemplate

      public static String getDefaultTemplate(String usage)
      Retrieve the relative path of the "default template" jsp/servlet .
      Parameters:
      usage - the usage or null
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-6.0.0
    • getTopbar

      public static String getTopbar()
    • getSiteTopbar

      public static String getSiteTopbar()
    • getWorkTopbar

      public static String getWorkTopbar()
    • getAdminTopbar

      public static String getAdminTopbar()
    • getPublicationAction

      public static String getPublicationAction()
    • getSidebar

      public static String getSidebar()
    • getSignUp

      public static String getSignUp()
    • getSignUpV

      public static String getSignUpV()
    • getSearch

      public static String getSearch()
      Retrieve the relative path of the "search" jsp/servlet that should be used to provide the advanced search form.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.0
    • getSearchWork

      public static String getSearchWork()
      Retrieve the relative path of the BO "search" jsp/servlet that should be used to provide the advanced search form.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-9.0.1
    • getRefine

      public static String getRefine()
      Retrieve the relative path of the "search" jsp/servlet that should be used to provide the refine search form.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.0
    • getQuery

      public static String getQuery()
      Retrieve the relative path of the "query" jsp/servlet that should be used to perform a search and display the results.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.0
    • getQueryXml

      public static String getQueryXml()
      Retrieve the relative path of the "query" jsp/servlet that should be used to perform a search and display the results as XML content.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-6.0.1
    • getQueryCsv

      public static String getQueryCsv()
      Retrieve the relative path of the "query" jsp/servlet that should be used to perform a search and display the results as CSV content.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-6.0.1
    • getQueryWork

      public static String getQueryWork()
      Retrieve the relative path of the "query" jsp/servlet that should be used to perform a search and display the results in BO.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-9.0.1
    • getMemberDisplay

      public static String getMemberDisplay()
      Retrieve the relative path of the "member display" jsp/servlet that should be used to display a member's information.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.2
    • getMemberProfile

      public static String getMemberProfile()
      Retrieve the relative path of the "member profile" jsp/servlet that should be used to display a member's profile.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-5.7.2
    • getMemberProfileEditor

      public static String getMemberProfileEditor()
      Retrieve the relative path of the "member profile editor" jsp/servlet that should be used to display a member's profile.
      Returns:
      a path relative to the webapp (no starting slash).
      Since:
      jcms-9.0.3
    • getMemberAdminIcon

      public static String getMemberAdminIcon()
      Retrieve the path of admins' member icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getMemberWsAdminIcon

      public static String getMemberWsAdminIcon()
      Retrieve the path of workspace admins' member icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getMemberWriterIcon

      public static String getMemberWriterIcon()
      Retrieve the path of the default members' icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getMemberDefaultIcon

      public static String getMemberDefaultIcon()
      Retrieve the path of the default members' icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getMemberLdapAdminIcon

      public static String getMemberLdapAdminIcon()
      Retrieve the path of admins' ldap member icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getMemberLdapWsAdminIcon

      public static String getMemberLdapWsAdminIcon()
      Retrieve the path of ldap workspace admins' ldap member icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getMemberLdapWriterIcon

      public static String getMemberLdapWriterIcon()
      Retrieve the path of ldap writers' member icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getMemberLdapDefaultIcon

      public static String getMemberLdapDefaultIcon()
      Retrieve the path of the default ldap members' icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getLoginIcon

      public static String getLoginIcon()
      Retrieve the path of the login icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-6.1.1
    • getLogoutIcon

      public static String getLogoutIcon()
      Retrieve the path of the logout icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-6.1.1
    • getLogbackIcon

      public static String getLogbackIcon()
      Retrieve the path of the logback icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-6.1.1
    • getMemberContactIcon

      public static String getMemberContactIcon()
      Retrieve the path of the contact members' icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-6.1.0
    • getDBMemberDefaultIcon

      public static String getDBMemberDefaultIcon()
      Retrieve the path of the default DB members' icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-6.1
    • getDBMemberLdapDefaultIcon

      public static String getDBMemberLdapDefaultIcon()
      Retrieve the path of the default ldap DBMembers' icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-10.0.1 JCMS-6340
    • getGroupDefaultIcon

      public static String getGroupDefaultIcon()
      Retrieve the path of groups' icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getGroupParentIcon

      public static String getGroupParentIcon()
      Retrieve the path of parent groups' icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getGroupLdapDefaultIcon

      public static String getGroupLdapDefaultIcon()
      Retrieve the path of ldap groups icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getGroupLdapParentIcon

      public static String getGroupLdapParentIcon()
      Retrieve the path of ldap parent groups' icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-5.7.0
    • getNotificationEmailHtml

      public static String getNotificationEmailHtml()
      Retrieve the path to the jsp which produce the notification mail
      Returns:
      the path to the jsp which produce the notification mail
      Since:
      jcms-8.0.0
    • getTooltipIcon

      public static String getTooltipIcon()
      Retrieve the path of tooltip icon.
      Returns:
      an image path relative to the webapp (no starting slash), e.g. "images/something.gif" .
      Since:
      jcms-6.0.0
    • getFirebaseAccount

      public static String getFirebaseAccount()
      Retrieve the path of firebase account json file informations.
      Returns:
      an the path to the firebase account json file
      Since:
      jcms-10.0.4
    • getFirebaseWebAccount

      public static String getFirebaseWebAccount()
      Retrieve the path of firebase web account json file informations.
      Returns:
      an the path to the firebase account json file
      Since:
      jcms-10.0.4
    • getSpecificEdit

      public static String getSpecificEdit(Class<?> clazz)
      Gives the JSP really used when a call to edit.jsp is done.
      Parameters:
      clazz - the Java sub class of Data for which a specific edit JSP is mandatory
      Returns:
      the specific Edit JSP
    • getSpecificEdit

      public static String getSpecificEdit(Data data)
      Gives the JSP really used when a call to edit.jsp is done.
      Parameters:
      data - the Data for which a specific edit JSP is mandatory
      Returns:
      the specific Edit JSP
    • getInstance

      public static ResourceHelper getInstance()
      Returns the singleton. Caution: This method is not thread-safe.
      Returns:
      the singleton.
      Since:
      jcms-7.1.0
    • propertiesChange

      public void propertiesChange(JProperties properties)
      Description copied from interface: JPropertiesListener
      Invoked after properties have been modified in JCMS and save on disk.

      You cannot alter the value received in parameters.

      Note that properties parameter may be null, a limited set of site properties, or all site properties.

      To check that a property has been modified, reload the "current" property instead using channel.getProperties or channel.getProperty.

      Specified by:
      propertiesChange in interface JPropertiesListener
      Parameters:
      properties - the properties which have been submitted to change
    • getHTTPEquivHeaderMap

      public Map<String,String> getHTTPEquivHeaderMap()
    • getHTTPNameHeaderMap

      public Map<String,String> getHTTPNameHeaderMap()
    • getHTTPCSSHeaderMap

      public Map<String,String> getHTTPCSSHeaderMap()
    • getHTTPJSHeaderMap

      public Map<String,String> getHTTPJSHeaderMap()
    • getHTTPJSModuleHeaderMap

      public Map<String,String> getHTTPJSModuleHeaderMap()
    • getLESSMap

      public Map<String,String> getLESSMap()
    • compileLESS

      public void compileLESS(boolean force)
      Request compilation of LESS file declare in current webapp.
      Parameters:
      force - set true to force compilation of less file, even when there is an existing generated file more recent than the sources. set to false to compile only if source is more recent than generated file.
    • getPublicPaths

      protected static Collection<String> getPublicPaths()
    • isPublicPath

      public static boolean isPublicPath(String path)
      Check if the specified path is allowed to be accessed without authentication when the site is private.
      Parameters:
      path - the resource path
      Returns:
      true if the specified path can always be accessed, false if an authentication is required.
    • getNonTransactionalPaths

      protected static Set<String> getNonTransactionalPaths()
    • isNonTransactionalPath

      public static boolean isNonTransactionalPath(String path)
      Check if the specified path requires or not an Hibernate transaction when accessed.
      Parameters:
      path - the resource path
      Returns:
      true if path can be accessed without hibernate transaction. false if an hibernate transaction is required.
      Since:
      jcms-10.0.2 / JCMS-7125
    • getJspOverride

      public static String getJspOverride(String jspPath)
      Retrieve the path of the JSP to use instead of the specified JSP, if any.

      You can override a JSP by declaring it in property :

       jsp.override./path/to/overriden.jsp: /path/of/overriding.jsp
       
      Parameters:
      jspPath - the JSP being run for which override is being verified, for example path/of/some.jsp
      Returns:
      a JSP path if specified JSP has been overriden in property, or null or JSP is not overriden
      Since:
      jcms-10.0.5 / JCMS-8486