Class PagePersonalizationUtil


  • public class PagePersonalizationUtil
    extends Object
    Provides utility methods for the Page Personalization service.
    Since:
    10.2.0
    Version:
    $Revision: 22800 $ $Date: 2019-06-03 18:36:25 -0300 (Mon, 03 Jun 2019) $
    • Field Detail

      • PROPERTY_HOLDER_PERSONALIZED_BY_CONTENT

        public static final 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 String getWidgetInstanceHolderInterfaceInstanceId​(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​(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 String getHolderContentId​(String holderServiceInterfaceInstanceId,
                                                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 String encodeHtmlEditorControl​(String html)
                                              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:
        10.4.0
      • renderWidgetInHtml

        public static String renderWidgetInHtml​(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 orignal 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
      • processWidgetInstaceInHtmlDelete

        public static void processWidgetInstaceInHtmlDelete​(Collection<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​(String newHtml,
                                                            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​(Collection<String> oldWidgetInstancesIds,
                                                Collection<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​(Collection<String> oldWidgetInstancesIds,
                                         Collection<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