Class OfferHelper


  • public class OfferHelper
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PN_LOCATION
      Mbox location property name
      static java.lang.String PN_TESTANDTARGETCONFIG
      Account-Reference property name
      static java.lang.String PN_THIRDPARTYID
      Third-Party property name
      static java.lang.String RT_CAMPAIGN
      Campaign resource type
      static java.lang.String RT_EXPERIENCE
      Experience resource type
      static java.lang.String RT_OFFER_PROXY
      Offer proxy resource type
      static java.lang.String RT_TEASER
      Offer resource type
    • Constructor Summary

      Constructors 
      Constructor Description
      OfferHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Page getCampaign​(Page page)
      Returns a page with resource type 'cq/personalization/components/campaignpage' or null.
      static java.lang.String getCampaignName​(java.lang.String path)
      Returns a campaign name based on a repository path, following the same rules as getOfferName(String)
      static long getOfferId​(Page offerPage)
      Returns the offer id from Target
      static long getOfferId​(Page offerPage, WCMMode wcmMode)
      Returns the id of the offer set by Target.
      static java.lang.String getOfferLocation​(Page offerPage, WCMMode wcmMode)
      Returns the offer location as it should be sent to Adobe Target
      static java.lang.String getOfferLocation​(Page offerPage, WCMMode wcmMode, java.lang.String ambitName)
      Returns the offer location as it should be sent to Adobe Target
      static java.lang.String getOfferName​(Page offerPage, WCMMode wcmMode)
      Returns the offer name based on this offer's location.
      static java.lang.String getOfferName​(Page offerPage, WCMMode wcmMode, java.lang.String ambitName)
      Returns the offer name based on this offer's location.
      static java.lang.String getOfferName​(java.lang.String path)
      Returns an Offer name constructed by concatenating the path and replacing slashes (/) with dashes (-).
      static java.lang.String getThirdPartyCampaignId​(Node contentResourceNode)
      Returns the third party id for a campaign page's resource node
      static java.lang.String getThirdPartyID​(Node node)
      Returns the third party ID of a Node if property exists, otherwise one is generated in Timestamp format.
      static void setConfigurationPath​(java.lang.String path, Page page)
      Saves the configuration reference to the campaign page
      static void setThirdPartyID​(Node node, java.lang.String operation, java.lang.String thirdpartyid)
      Saves or deletes the third party ID property in the provided Node according to the executed operation.
      • Methods inherited from class java.lang.Object

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

      • PN_THIRDPARTYID

        public static final java.lang.String PN_THIRDPARTYID
        Third-Party property name
        See Also:
        Constant Field Values
      • RT_CAMPAIGN

        public static final java.lang.String RT_CAMPAIGN
        Campaign resource type
        See Also:
        Constant Field Values
      • RT_EXPERIENCE

        public static final java.lang.String RT_EXPERIENCE
        Experience resource type
        See Also:
        Constant Field Values
      • RT_TEASER

        public static final java.lang.String RT_TEASER
        Offer resource type
        See Also:
        Constant Field Values
      • RT_OFFER_PROXY

        public static final java.lang.String RT_OFFER_PROXY
        Offer proxy resource type
        See Also:
        Constant Field Values
      • PN_TESTANDTARGETCONFIG

        public static final java.lang.String PN_TESTANDTARGETCONFIG
        Account-Reference property name
        See Also:
        Constant Field Values
      • PN_LOCATION

        public static final java.lang.String PN_LOCATION
        Mbox location property name
        See Also:
        Constant Field Values
    • Constructor Detail

      • OfferHelper

        public OfferHelper()
    • Method Detail

      • getOfferName

        public static java.lang.String getOfferName​(java.lang.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 java.lang.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 java.lang.String getOfferName​(Page offerPage,
                                                    WCMMode wcmMode,
                                                    java.lang.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 java.lang.String getCampaignName​(java.lang.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
      • setThirdPartyID

        public static void setThirdPartyID​(Node node,
                                           java.lang.String operation,
                                           java.lang.String thirdpartyid)
                                    throws RepositoryException
        Saves or deletes the third party ID property in the provided Node according to the executed operation.
        Parameters:
        node - Node
        operation - operation
        thirdpartyid - thirdpartyid
        Throws:
        RepositoryException - RepositoryException
      • getThirdPartyID

        public static java.lang.String getThirdPartyID​(Node node)
                                                throws RepositoryException
        Returns the third party ID of a Node if property exists, otherwise one is generated in Timestamp format.
        Parameters:
        node - Offer node
        Returns:
        Third-Party ID
        Throws:
        RepositoryException - RepositoryException
      • getThirdPartyCampaignId

        public static java.lang.String getThirdPartyCampaignId​(Node contentResourceNode)
                                                        throws RepositoryException
        Returns the third party id for a campaign page's resource node
        Parameters:
        contentResourceNode - Node of pages contentresourcenode
        Returns:
        the third party id
        Throws:
        RepositoryException - RepositoryException
      • setConfigurationPath

        public static void setConfigurationPath​(java.lang.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 java.lang.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 java.lang.String getOfferLocation​(Page offerPage,
                                                        WCMMode wcmMode,
                                                        java.lang.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.