Interface PortalPolicyFilter

  • All Superinterfaces:
    java.lang.Comparable, PluginComponent, PolicyFilter
    All Known Implementing Classes:
    BasicPortalPolicyFilter

    public interface PortalPolicyFilter
    extends PolicyFilter
    This class allow developers to put hooks to change portal mechanism behaviour. The standard behaviours of display.jsp call hooks in specificl order: Portal discovery:
    1. Before
      • filterDisplayContext()
      • checkCtxCategories()
      • checkCategory()
      • checkPublication()
    2. During
      • checkPortal()
      • checkWorkingCategories()
    3. After
      1. checkDisplay()
      2. checkWorkspace()
      3. checkDisplayContext()
      4. checkRedirect()
    To get more information about the current request in hooks, the method Channel#getCurrentJcmsContext() must be called.
    Since:
    jcms-5.5.0
    Version:
    $Revision: 129031 $
    Author:
    Jean-Philippe Encausse
    • Method Detail

      • getHomeCategory

        Category getHomeCategory​(Category jcmsChoice,
                                 Member loggedMember)
        Hook called by PortalManager to compute the home Category of the given logged Member.
        It is called by PortalPolicyManager.getHomeCategory(Category, Member).
        Parameters:
        jcmsChoice - the jcms standard response
        loggedMember - the logged member
        Returns:
        the home Category
        Since:
        jcms-7.1.2
      • filterDisplayContext

        void filterDisplayContext​(PortalManager.DisplayContextParameters dcp)
        Hook called by PortalManager to compute display context parameters. It is called first before portal resolution. The given PortalManager.DisplayContextParameters contains all computed request parameters. Usage: - This filter may be used to completly update the elements of the request
        Parameters:
        dcp - PortalManager.DisplayContextParameters
      • checkCategory

        Category checkCategory​(Category workingCategory,
                               Member loggedMember)
        Hook called by display.jsp to update the working category. It is called before portal resolution. Usage: - Replace a given category referenced with "display.jsp?id=catid" by an other. - To do kind of dynamic alias
        Parameters:
        workingCategory - the previous computed category
        loggedMember - the logged member
        Returns:
        the new working publication
      • checkPublication

        Publication checkPublication​(Publication workingPublication,
                                     Member loggedMember,
                                     boolean isPreview)
        Hook called by display.jsp to update the working publication. It is called before portal resolution. Usage: - Replace a given publication referenced with "display.jsp?id=pubid" by an other. - Handle reader notes - Defaults on publication's reviews or other sub publications.
        Parameters:
        workingPublication - the previous computed publication
        loggedMember - the logged member
        isPreview - boolean indicate preview mode
        Returns:
        the new working publication
      • checkCtxCategories

        void checkCtxCategories​(java.util.List ctxCategories)
        Hook called by doInitPortal.jsp to update the contextual category list. It is called during page initialisation Usage: - Add/Remove/Reorder contextual categories for all page processing (Contextual categories are used by lots of portal mechanism)
        Parameters:
        ctxCategories - the previous computed ctx categories
        Since:
        jcms-5.6.0
        See Also:
        PortalManager.getCtxCategories(HttpServletRequest)
      • checkPortal

        boolean checkPortal​(PortalInterface portal,
                            Publication pub,
                            DisplayContext context,
                            Member loggedMember,
                            boolean skipRedirect,
                            boolean skipExact,
                            boolean modePreview,
                            boolean jcmsChoice)
        Hook called by PortalManager to decide if the given portal may be used to display information.

        It is called:

        • for each Portal
        • for each Category tree
        Usage:
        - Accept or Reject a given Portal

        Hook:
        - since JCMS-7812, iterated category can be retrieved using: Category itCat = request.getAttribute(PortalManager.CHECK_PORTAL_CATEGORY_ATTR)

        Parameters:
        portal - the portal to check
        pub - the current publication if we work on a publication
        context - the display context
        loggedMember - the logged member
        skipRedirect - true for display portal, false for display or redirect portal
        skipExact - true no to check "exact" feature
        modePreview - is preview mode activated
        jcmsChoice - the jcms standard response
        Returns:
        boolean true if the given portal may be used
        See Also:
        PortalManager.checkPortal(Category, DisplayContext, Member, boolean, boolean)
      • checkWorkingCategories

        void checkWorkingCategories​(java.util.List workingCategories,
                                    Publication pub,
                                    Member loggedMember,
                                    boolean skipRedirect,
                                    boolean skipExact,
                                    boolean modePreview,
                                    Category[] ctxCategories)
        Hook called by PortalManager to change the order between categories of a given publication. Default behaviour use first publication categories descendant of contextual categories or channel properties. Note: Since JCMS 5.7.3 This method is called with an empty workingCategories List if the publication do not have valid categories. In this case the method will be called twice: before (without categories) and after sort If the methods stils returns empty workingCategories then use workspace categories Usage: - Update workingCategories List to modify the iteration order. - Set a custom category branch priority - Since JCMS 5.7.3: Add categories for publication without categories
        Parameters:
        pub - the current publication
        workingCategories - a sorted list of starting categories to work with
        loggedMember - the logged member
        skipRedirect - true for display portal, false for display or redirect portal
        skipExact - true no to check "exact" feature
        modePreview - is preview mode activated
        ctxCategories - the contextual categories in request parameters
        See Also:
        PortalManager.findPortal(Publication, DisplayContext, Member, boolean, boolean, boolean, Category[])
      • checkDisplay

        void checkDisplay​(DisplayContext context,
                          Category cat,
                          Member loggedMember)
        Hook called by getDisplayContext() to update the content of context. It is called after portal resolution. Usage: - Update the computed context for the given category
        Parameters:
        context - the computed data
        cat - the requested category
        loggedMember - the current logged member
      • checkDisplay

        void checkDisplay​(DisplayContext context,
                          Publication pub,
                          Member loggedMember)
        Hook called by getDisplayContext() to update the content of context. It is called after portal resolution. Usage: - Update the computed context for the given publication
        Parameters:
        context - the computed data
        pub - the requested publication
        loggedMember - the current logged member
      • checkDisplay

        void checkDisplay​(DisplayContext context,
                          Member member,
                          Category home,
                          Member loggedMember)
        Hook called by getDisplayContext() to update the content of context. It is called after portal resolution. Usage: - Update the computed context for the given member
        Parameters:
        context - the computed data
        member - the requested member
        home - the home category used in redirect url
        loggedMember - the current logged member
      • checkWorkspace

        Workspace checkWorkspace​(DisplayContext context,
                                 Workspace workspace,
                                 Member loggedMember)
        Hook called by handleDisplayRequest() (in display.jsp) to update the working worskpace. It is called after portal resolution. Usage: - Default behavior use Portal workspace as working workspace. This hook will change this behavior.
        Parameters:
        context - the computed data
        workspace - The workspace
        loggedMember - the logged member
        Returns:
        Workspace the workspace to use
      • checkDisplayContext

        void checkDisplayContext​(DisplayContext context)
        Hook called by display.jsp to create the display context if it is null otherwise sendForbidden. It is called after portal resolution. Usage: - If context is null a sendForbidden() is sent. - Context may be created or changed to display anything - Set/Remove redirect url
        Parameters:
        context - the computed context or null if forbidden
      • checkRedirect

        java.lang.String checkRedirect​(java.lang.String redirectUrl,
                                       PortalRedirect redirect,
                                       DisplayContext context,
                                       Member loggedMember)
        Hook called by display.jsp to update the redirect url of PortletRedirect. It is not called for simple redirection error It is called after portal resolution
        Parameters:
        redirectUrl - The redirect url
        redirect - the PortalRedirect
        context - the computed history
        loggedMember - the logged member
        Returns:
        String the redirect URL
      • checkPermalink

        java.lang.String checkPermalink​(java.lang.String permalink,
                                        Data data)
        Hook called by PortalManager.getPermalink() to update the way to render permalinks
        Parameters:
        permalink - the computed permanent link
        data - the working data
        Returns:
        the permanling of the specified data
      • checkPermalink

        java.lang.String checkPermalink​(java.lang.String permalink,
                                        Data data,
                                        java.util.Locale userLocale)
        Hook called by PortalManager.getPermalink() to update the way to render permalinks
        Parameters:
        permalink - the computed permanent link
        data - the working data
        Returns:
        the permanling of the specified data
        Since:
        jcms-7.1.1
      • getDescriptiveURLText

        java.lang.String getDescriptiveURLText​(java.lang.String descriptiveURLtext,
                                               Data data,
                                               java.util.Locale locale)
        Returns the textual part of a descriptive URL built for the given Data. As the textual part is optional, this method is called only when the property descriptive-urls.text.enabled is set to "true". The given descriptiveURLtext is null or represents a custom descriptiveURLtext. If the methods returns null then compute the default descriptive URL text
        Parameters:
        data - the Data for which the URL is built.
        descriptiveURLtext - null or a custom descriptive url
        locale - the Locale to use I18N and localized operation
        Returns:
        the textual part of the descriptive URL, or null if you want to let JCMS generate it.
        Since:
        jcms-5.7.0
      • getDescriptiveURLPath

        java.lang.String getDescriptiveURLPath​(Data data,
                                               java.util.Locale locale)
        Returns the path of the descriptive URL to use for the specified Data and Locale.

        IMPORTANT : This method is provided for extreme customization of the descriptive URL, but it might break internal features if not modified properly.
        Ensure to implement method getDescriptiveURLId(String, String) at the same time.

        Instead of implementing this method, the easiest way to modify descriptive URL is to implement getDescriptiveURLText(String, Data, Locale) in order to change the textual part of the descriptive URL and let JCMS perform all the rest.

        Parameters:
        data - the Data for which the URL is built, might be null.
        locale - the Locale to use I18N and localized operation
        Returns:
        the path of the data, relative to the Display Servlet root mapping (usually /jcms/) and without '/' at begining, for example my-unique-data-title Return null if you want to let JCMS generate it, eg : id/my-data-title.
        Since:
        jcms-6.1.1
      • getDescriptiveURLId

        java.lang.String getDescriptiveURLId​(java.lang.String descriptiveUrl,
                                             java.lang.String id)
        Retrieve the Data to display from the specified descriptive URL.

        You only need to implement this method if you have modified getDescriptiveURLPath(Data, Locale).

        Parameters:
        descriptiveUrl - a descriptive URL such as /jcms/id_42/some-text or anything starting with the DisplayServlet root mapping (usually /jcms/) and followed by value computed through getDescriptiveURLPath(Data, Locale)
        id - the ID already computed by JCMS (or null if none was found)
        Returns:
        a Data id, if null or invalid, URL will not be resolved to display any Data.
        Since:
        jcms-6.1.1
      • getDescriptiveURLLanguage

        java.lang.String getDescriptiveURLLanguage​(java.lang.String descriptiveUrl,
                                                   java.lang.String lang)
        Retrieve the language in which to display the Data from the specified descriptive URL.

        You only need to implement this method if you have modified getDescriptiveURLPath(Data, Locale).

        Parameters:
        descriptiveUrl - a descriptive URL such as /jcms/id_42/en/some-text or anything starting with the DisplayServlet root mapping (usually /jcms/) and followed by value computed through getDescriptiveURLPath(Data, Locale)
        lang - the language already computed by JCMS (or null if none was found in the path, in which case default user language is used)
        Returns:
        a ISO-639 language code, must be a valid value configured in Channel.getLanguageList()
        Since:
        jcms-7.1.0
      • fillDescriptiveURLParameterMap

        void fillDescriptiveURLParameterMap​(java.util.Map<java.lang.String,​java.lang.String> paramMap,
                                            Data data)
        Fill the given map with custom parameters to be added to the descriptive URL
        Parameters:
        paramMap - the parameter map
        data - the Data for which the URL is built, might be null.
        Since:
        jcms-7.0.0
      • getFieldValue

        java.lang.Object getFieldValue​(JcmsJspContext ctxt,
                                       java.lang.String fieldName,
                                       Data data,
                                       java.lang.Object computedValue)
        Returns an alternate value for the given field and given Data. The return value might be a String id of a Storable that might be resolved. The original value can be retrieve by calling Data.getFieldValue(String)
        Parameters:
        ctxt - the JCmsJspContext
        fieldName - the name of the called field
        data - the Data object to work with
        computedValue - the already computed value (using extra data)
        Returns:
        Object the alternate value
      • getIntFieldValue

        int getIntFieldValue​(JcmsJspContext ctxt,
                             java.lang.String fieldName,
                             Data data,
                             int computedValue)
        Returns an alternate value for the given int field and given Data. The original value can be retrieve by calling Data.getIntFieldValue(String)
        Parameters:
        ctxt - the JCmsJspContext
        fieldName - the name of the called field
        data - the Data object to work with
        computedValue - the already computed value (using extra data)
        Returns:
        int the alternate value
        Since:
        jcms-6.0.0
      • getLongFieldValue

        long getLongFieldValue​(JcmsJspContext ctxt,
                               java.lang.String fieldName,
                               Data data,
                               long computedValue)
        Returns an alternate value for the given long field and given Data. The original value can be retrieve by calling Data.getLongFieldValue(String)
        Parameters:
        ctxt - the JCmsJspContext
        fieldName - the name of the called field
        data - the Data object to work with
        computedValue - the already computed value (using extra data)
        Returns:
        long the alternate value
        Since:
        jcms-6.0.2, jcms-6.1.1
      • getDoubleFieldValue

        double getDoubleFieldValue​(JcmsJspContext ctxt,
                                   java.lang.String fieldName,
                                   Data data,
                                   double computedValue)
        Returns an alternate value for the given double field and given Data. The original value can be retrieve by calling Data.getDoubleFieldValue(String)
        Parameters:
        ctxt - the JCmsJspContext
        fieldName - the name of the called field
        data - the Data object to work with
        computedValue - the already computed value (using extra data)
        Returns:
        double the alternate value
        Since:
        jcms-6.0.2, jcms-6.1.1
      • getBooleanFieldValue

        boolean getBooleanFieldValue​(JcmsJspContext ctxt,
                                     java.lang.String fieldName,
                                     Data data,
                                     boolean computedValue)
        Returns an alternate value for the given boolean field and given Data. The original value can be retrieve by calling Data.getBooleanFieldValue(String)
        Parameters:
        ctxt - the JCmsJspContext
        fieldName - the name of the called field
        data - the Data object to work with
        computedValue - the already computed value (using extra data)
        Returns:
        boolean the alternate value
        Since:
        jcms-6.0.2, jcms-6.1.1
      • getCategoryFieldValue

        java.util.TreeSet<Category> getCategoryFieldValue​(JcmsJspContext ctxt,
                                                          java.lang.String fieldName,
                                                          Data data,
                                                          java.util.TreeSet<Category> computedValue)
        Returns an alternate value for the given Category field and given Data. The original value can be retrieve by calling Data.getCategoryFieldValue(String, Member)
        Parameters:
        ctxt - the JCmsJspContext
        fieldName - the name of the called field
        data - the Data object to work with
        computedValue - the already computed value (using extra data)
        Returns:
        a TreeSet of Category the alternate value
        Since:
        jcms-6.0.2, jcms-6.1.1
      • initHeaders

        void initHeaders​(java.util.Map header,
                         java.lang.String key,
                         JcmsJspContext context)
        Initialise header data to include in HTML headers in the Front and Back Office. This method is called during the first initialisation of the header. Portlets and Plugins might add header during page construction Topics might be:
        • CSS_HEADER (Css Files / Media)
        • STYLE_HEADER (Css Content / Media)
        • CUSTOM_HEADER (Content / null)
        • BODY_HEADER (Body attribute / value)
        • HTTPEQUIV_HEADER (name / value)
        • HTTPNAME_HEADER (name / value)
        Parameters:
        header - the jcms Map header
        key - the topic key (for javascript, css, ...)
        context - the calling JcmsJspContext
        Since:
        jcms-5.7.0
      • setupHeaders

        void setupHeaders​(java.util.Map header,
                          java.lang.String key,
                          JcmsJspContext context)
        Setup header data to include in HTML headers in the Front and Back Office. This method is called before printing header (done by doEmptyHeader.jsp). Headers contains all elements that will be printed. Topics might be:
        • CSS_HEADER (Css Files / Media)
        • STYLE_HEADER (Css Content / Media)
        • CUSTOM_HEADER (Content / null)
        • BODY_HEADER (Body attribute / value)
        • HTTPEQUIV_HEADER (name / value)
        • HTTPNAME_HEADER (name / value)
        Parameters:
        header - the jcms Map header
        key - the topic key (for javascript, css, ...)
        context - the calling JcmsJspContext
        Since:
        jcms-5.7.0
      • initJavaScriptSet

        void initJavaScriptSet​(java.util.Set<java.lang.String> jsSet,
                               JcmsJspContext context)
        Setup the javascript files to be included for current page.
        Parameters:
        jsSet - a set of relative file path (e.g. "js/custom/myfile.js")
        context - the calling JcmsJspContext
      • initJavaScriptCodeSet

        void initJavaScriptCodeSet​(java.util.Set<java.lang.String> jsCodeSet,
                                   JcmsJspContext context)
        Setup the javascript codes to be invoked on page load for current page.
        Parameters:
        jsCodeSet - a set of javascript code (e.g. "if (true) { alert('page loaded'); }")
        context - the calling JcmsJspContext