Class OfferHelper


  • public class OfferHelper
    extends Object
    • Constructor Detail

      • OfferHelper

        public OfferHelper()
    • Method Detail

      • getOfferName

        public static String getOfferName​(String path)
        Returns an Offer name constructed by concatenating the path and replacing slashes (/) with dashes (-).
        Parameters:
        path - path
        Returns:
        offername constructed by path
      • getOfferName

        public static String getOfferName​(Page offerPage,
                                          WCMMode wcmMode)
        Returns the offer name based on this offer's location. If this offer doesn't have a location then this method calls getOfferName(String)
        Parameters:
        offerPage - the offer page
        wcmMode - the WCM mode. This is required to determine the offer location
        Returns:
        the offer name
      • getOfferName

        public static String getOfferName​(Page offerPage,
                                          WCMMode wcmMode,
                                          String ambitName)
        Returns the offer name based on this offer's location. If this offer doesn't have a location then this method calls getOfferName(String)
        Parameters:
        offerPage - the offer page
        wcmMode - the WCM mode. This is required to determine the offer location
        ambitName - the name of the ambit that this offer is part of.
        Returns:
        the offer name, following this pattern - {location-name}--{wcm mode}-{ambit-name}-{experience name}-{offer page name}. If the WCM mode is WCMMode.DISABLED then it's ommited. If the ambit name is PersonalizationConstants.AMBIT_DEFAULT_NAME then it's omitted.
      • getCampaignName

        public static String getCampaignName​(String path)
        Returns a campaign name based on a repository path, following the same rules as getOfferName(String)
        Parameters:
        path - path
        Returns:
        the campaign name
      • setConfigurationPath

        public static void setConfigurationPath​(String path,
                                                Page page)
                                         throws RepositoryException
        Saves the configuration reference to the campaign page
        Parameters:
        path - Configuration path
        page - Current offer page
        Throws:
        RepositoryException - in case an error occurs when node property is set
      • getCampaign

        public static Page getCampaign​(Page page)
        Returns a page with resource type 'cq/personalization/components/campaignpage' or null. The method walks ascending up the hierarchy until a page with the corresponding resource type is found.
        Parameters:
        page - Page with resource type 'cq/personalization/components/campaignpage' or initially provided page.
        Returns:
        page with campaignpage resourcetype or null
      • getOfferLocation

        public static String getOfferLocation​(Page offerPage,
                                              WCMMode wcmMode)
        Returns the offer location as it should be sent to Adobe Target
        Parameters:
        offerPage - The offer page from CQ
        wcmMode - The mode for which the location is calculated . Used to create different locations for author and publish environments
        Returns:
        the offer location or "* display mbox *" if no location property is found in the offerPage
      • getOfferLocation

        public static String getOfferLocation​(Page offerPage,
                                              WCMMode wcmMode,
                                              String ambitName)
        Returns the offer location as it should be sent to Adobe Target
        Parameters:
        offerPage - The offer page from CQ
        wcmMode - The mode for which the location is calculated . Used to create different locations for author and publish environments
        ambitName - the name of the MSM ambit that this offer is part of
        Returns:
        the offer location or "* display mbox *" if no location property is found in the offerPage
      • getOfferId

        public static long getOfferId​(Page offerPage)
        Returns the offer id from Target
        Parameters:
        offerPage - the offer page from CQ
        Returns:
        a value of type long representing the Id, or 0 if the id is not present.
      • getOfferId

        public static long getOfferId​(Page offerPage,
                                      WCMMode wcmMode)
        Returns the id of the offer set by Target. The id is one of the two *externalId properties of the offer page
        Parameters:
        offerPage - the offer page from AEM
        wcmMode - the WCMMode. If the WCMMode is WCMMode.EDIT then the id value is read from the cq:authorExternalId property, otherwise the value of the cq:publishExternalId property is returned
        Returns:
        a value of type long representing the Id, or 0 if the id is not present.