Class PagePersonalizationUtil


  • public class PagePersonalizationUtil
    extends java.lang.Object
    Provides utility methods for the Page Personalization service.
    Since:
    10.2.0
    Version:
    $Revision: 26318 $ $Date: 2024-04-11 16:45:43 -0300 (Thu, 11 Apr 2024) $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PROPERTY_HOLDER_PERSONALIZED_BY_CONTENT
      Name of holder's service interface instance custom property that contains a boolean value indicating if that holder is personalized by content.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addNewWidgets​(java.util.Collection<java.lang.String> oldWidgetInstancesIds, java.util.Collection<java.lang.String> updateWidgetInstancesIds, ISourceField field, SourcePreUpdateDataEvent event)
      Compare two list of widgets instances and process the widgets whom exists on the updated list and does not exist on the other list.
      static java.lang.String encodeHtmlEditorControl​(java.lang.String html, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
      Method that receives a html string, search for widget instance pattern and encode it with data.
      static java.lang.String getHolderContentId​(java.lang.String holderServiceInterfaceInstanceId, java.lang.String contentId)
      Returns the identifier of the content the holder is personalized for.
      static java.lang.String getWidgetInstanceHolderInterfaceInstanceId​(java.lang.String interfaceInstanceId)
      Returns the widget holder's interface instance id for a widget instance that corresponds to the specified interface instance only if it's a holder widget instance.
      static boolean isHolderPersonalizedByContent​(java.lang.String holderInterfaceInstanceId)
      Returns whether a widget holder is configured to be personalized by content.
      static void processWidgetInstaceInHtmlAdded​(java.lang.String html, ISourceField field, SourcePostAddDataEvent event)
      Process the html field widget instance after it be added.
      static void processWidgetInstaceInHtmlDelete​(java.util.Collection<java.lang.String> itemIds)
      Process the html field widget instance to be deleted.
      static void processWidgetInstaceInHtmlUpdate​(java.lang.String newHtml, java.lang.String originalHtml, ISourceField field, SourcePreUpdateDataEvent event)
      Process the html field widget instance to be updated.
      static void removeDeletedWidgets​(java.util.Collection<java.lang.String> oldWidgetInstancesIds, java.util.Collection<java.lang.String> updateWidgetInstancesIds)
      Compare a list of old widgets and a updated list of widget instances and remove de widgets instances that does not exists in the updated list.
      static java.lang.String renderWidget​(HttpServletRequest httpServletRequest, IServiceInterfaceRenderRequest originalRenderRequest, HttpServletResponse httpServletResponse, java.lang.String widgetInstanceId, boolean processPaths)
      Renders a widget.
      static java.lang.String renderWidgetInHtml​(java.lang.String html, HttpServletRequest httpServletRequest, IServiceInterfaceRenderRequest originalRenderRequest, HttpServletResponse httpServletResponse)
      Method that create a request to get html from a widget instance in a html content field and substitute the dummy widget instance for his html content.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PROPERTY_HOLDER_PERSONALIZED_BY_CONTENT

        public static final java.lang.String PROPERTY_HOLDER_PERSONALIZED_BY_CONTENT
        Name of holder's service interface instance custom property that contains a boolean value indicating if that holder is personalized by content.
        Since:
        10.2.0
        See Also:
        Constant Field Values
    • Constructor Detail

      • PagePersonalizationUtil

        public PagePersonalizationUtil()
    • Method Detail

      • getWidgetInstanceHolderInterfaceInstanceId

        public static java.lang.String getWidgetInstanceHolderInterfaceInstanceId​(java.lang.String interfaceInstanceId)
        Returns the widget holder's interface instance id for a widget instance that corresponds to the specified interface instance only if it's a holder widget instance.
        Parameters:
        interfaceInstanceId - the widget instance's interface instance identifier.
        Returns:
        the widget holder's interface instance identifier.
        Since:
        10.2.0
      • isHolderPersonalizedByContent

        public static boolean isHolderPersonalizedByContent​(java.lang.String holderInterfaceInstanceId)
                                                     throws PortalException
        Returns whether a widget holder is configured to be personalized by content.
        Parameters:
        holderInterfaceInstanceId - the holder's service interface instance identifier.
        Returns:
        true if the holder is configured to be personalized by content, false otherwise.
        Throws:
        PortalException
        Since:
        10.2.0
      • getHolderContentId

        public static java.lang.String getHolderContentId​(java.lang.String holderServiceInterfaceInstanceId,
                                                          java.lang.String contentId)
                                                   throws PortalException
        Returns the identifier of the content the holder is personalized for.
        Parameters:
        holderServiceInterfaceInstanceId - the holder's service interface instance identifier.
        contentId - the content identifier provided in the request being processed.
        Returns:
        the content identifier, or null if the holder is not configured to be personalized for content or if the request does not specify a valid content to base the holder on.
        Throws:
        PortalException
        Since:
        10.2.0
      • encodeHtmlEditorControl

        public static java.lang.String encodeHtmlEditorControl​(java.lang.String html,
                                                               HttpServletRequest httpServletRequest,
                                                               HttpServletResponse httpServletResponse)
                                                        throws PortalException
        Method that receives a html string, search for widget instance pattern and encode it with data.
        Parameters:
        html -
        Returns:
        the encoded Html
        Throws:
        PortalException
        Since:
        15.0.0
      • renderWidgetInHtml

        public static java.lang.String renderWidgetInHtml​(java.lang.String html,
                                                          HttpServletRequest httpServletRequest,
                                                          IServiceInterfaceRenderRequest originalRenderRequest,
                                                          HttpServletResponse httpServletResponse)
                                                   throws PortalException
        Method that create a request to get html from a widget instance in a html content field and substitute the dummy widget instance for his html content.
        Parameters:
        html - the original content html
        httpServletRequest - the http servlet request
        originalRenderRequest - the original render request
        httpServletResponse - the http servlet Response
        Returns:
        return the content html with widget html
        Throws:
        PortalException
        Since:
        10.4.0
      • renderWidget

        public static java.lang.String renderWidget​(HttpServletRequest httpServletRequest,
                                                    IServiceInterfaceRenderRequest originalRenderRequest,
                                                    HttpServletResponse httpServletResponse,
                                                    java.lang.String widgetInstanceId,
                                                    boolean processPaths)
                                             throws PortalException
        Renders a widget.
        Parameters:
        httpServletRequest - the http servlet request to be used in the context of this renderization.
        originalRenderRequest - the original interface render request. If set some of its attributes are used.
        httpServletResponse - the http servlet response to be used in the context of this renderization.
        widgetInstanceId - the identfier of the widget instance to be rendered.
        processPaths - true if the paths in the HTML are to be post processed, or false if the processing of paths is to be disabled during this renderization.
        Returns:
        return the HTML rendered for the widget.
        Throws:
        PortalException
        Since:
        15.0.0
      • processWidgetInstaceInHtmlDelete

        public static void processWidgetInstaceInHtmlDelete​(java.util.Collection<java.lang.String> itemIds)
                                                     throws PortalException
        Process the html field widget instance to be deleted.
        Parameters:
        itemId - the content version item identifier
        Throws:
        PortalException
        Since:
        10.4.0
      • processWidgetInstaceInHtmlUpdate

        public static void processWidgetInstaceInHtmlUpdate​(java.lang.String newHtml,
                                                            java.lang.String originalHtml,
                                                            ISourceField field,
                                                            SourcePreUpdateDataEvent event)
                                                     throws PortalException
        Process the html field widget instance to be updated.
        Parameters:
        newHtml - the new html field
        originalHtml - the original html field
        event - the pre update event
        Throws:
        PortalException
        Since:
        10.4.0
      • removeDeletedWidgets

        public static void removeDeletedWidgets​(java.util.Collection<java.lang.String> oldWidgetInstancesIds,
                                                java.util.Collection<java.lang.String> updateWidgetInstancesIds)
                                         throws PortalException
        Compare a list of old widgets and a updated list of widget instances and remove de widgets instances that does not exists in the updated list.
        Parameters:
        oldWidgetInstancesIds - list of old widgets instances
        updateWidgetInstancesIds - list of widgets instances updated
        Throws:
        PortalException
        Since:
        10.4.0
      • addNewWidgets

        public static void addNewWidgets​(java.util.Collection<java.lang.String> oldWidgetInstancesIds,
                                         java.util.Collection<java.lang.String> updateWidgetInstancesIds,
                                         ISourceField field,
                                         SourcePreUpdateDataEvent event)
                                  throws PortalException
        Compare two list of widgets instances and process the widgets whom exists on the updated list and does not exist on the other list.
        Parameters:
        oldWidgetInstancesIds - the list of old widgets instances
        updateWidgetInstancesIds - the updated list of widgets instances
        event - the pre update event
        Throws:
        PortalException
        Since:
        10.4.0
      • processWidgetInstaceInHtmlAdded

        public static void processWidgetInstaceInHtmlAdded​(java.lang.String html,
                                                           ISourceField field,
                                                           SourcePostAddDataEvent event)
                                                    throws PortalException
        Process the html field widget instance after it be added.
        Parameters:
        html - the html field
        event - the post add event
        Throws:
        PortalException
        Since:
        10.4.0