Class OfferHelper
- java.lang.Object
-
- com.day.cq.analytics.testandtarget.util.OfferHelper
-
public class OfferHelper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringPN_LOCATIONMbox location property namestatic StringPN_TESTANDTARGETCONFIGAccount-Reference property namestatic StringPN_THIRDPARTYIDThird-Party property namestatic StringRT_CAMPAIGNCampaign resource typestatic StringRT_EXPERIENCEExperience resource typestatic StringRT_OFFER_PROXYOffer proxy resource typestatic StringRT_TEASEROffer resource type
-
Constructor Summary
Constructors Constructor Description OfferHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PagegetCampaign(Page page)Returns a page with resource type 'cq/personalization/components/campaignpage' ornull.static StringgetCampaignName(String path)Returns a campaign name based on a repository path, following the same rules asgetOfferName(String)static longgetOfferId(Page offerPage)Returns the offer id from Targetstatic longgetOfferId(Page offerPage, WCMMode wcmMode)Returns the id of the offer set by Target.static StringgetOfferLocation(Page offerPage, WCMMode wcmMode)Returns the offer location as it should be sent to Adobe Targetstatic StringgetOfferLocation(Page offerPage, WCMMode wcmMode, String ambitName)Returns the offer location as it should be sent to Adobe Targetstatic StringgetOfferName(Page offerPage, WCMMode wcmMode)Returns the offer name based on this offer's location.static StringgetOfferName(Page offerPage, WCMMode wcmMode, String ambitName)Returns the offer name based on this offer's location.static StringgetOfferName(String path)Returns an Offer name constructed by concatenating the path and replacing slashes (/) with dashes (-).static StringgetThirdPartyCampaignId(Node contentResourceNode)Returns the third party id for a campaign page's resource nodestatic StringgetThirdPartyID(Node node)Returns the third party ID of a Node if property exists, otherwise one is generated in Timestamp format.static voidsetConfigurationPath(String path, Page page)Saves the configuration reference to the campaign pagestatic voidsetThirdPartyID(Node node, String operation, String thirdpartyid)Saves or deletes the third party ID property in the providedNodeaccording to the executed operation.
-
-
-
Field Detail
-
PN_THIRDPARTYID
public static final String PN_THIRDPARTYID
Third-Party property name- See Also:
- Constant Field Values
-
RT_CAMPAIGN
public static final String RT_CAMPAIGN
Campaign resource type- See Also:
- Constant Field Values
-
RT_EXPERIENCE
public static final String RT_EXPERIENCE
Experience resource type- See Also:
- Constant Field Values
-
RT_TEASER
public static final String RT_TEASER
Offer resource type- See Also:
- Constant Field Values
-
RT_OFFER_PROXY
public static final String RT_OFFER_PROXY
Offer proxy resource type- See Also:
- Constant Field Values
-
PN_TESTANDTARGETCONFIG
public static final String PN_TESTANDTARGETCONFIG
Account-Reference property name- See Also:
- Constant Field Values
-
PN_LOCATION
public static final String PN_LOCATION
Mbox location property name- See Also:
- Constant Field Values
-
-
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 callsgetOfferName(String)- Parameters:
offerPage- the offer pagewcmMode- 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 callsgetOfferName(String)- Parameters:
offerPage- the offer pagewcmMode- the WCM mode. This is required to determine the offer locationambitName- 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.DISABLEDthen it's ommited. If the ambit name isPersonalizationConstants.AMBIT_DEFAULT_NAMEthen it's omitted.
-
getCampaignName
public static String getCampaignName(String path)
Returns a campaign name based on a repository path, following the same rules asgetOfferName(String)- Parameters:
path- path- Returns:
- the campaign name
-
setThirdPartyID
public static void setThirdPartyID(Node node, String operation, String thirdpartyid) throws RepositoryException
Saves or deletes the third party ID property in the providedNodeaccording to the executed operation.- Parameters:
node-Nodeoperation- operationthirdpartyid- thirdpartyid- Throws:
RepositoryException-RepositoryException
-
getThirdPartyID
public static 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 String getThirdPartyCampaignId(Node contentResourceNode) throws RepositoryException
Returns the third party id for a campaign page's resource node- Parameters:
contentResourceNode-Nodeof pages contentresourcenode- Returns:
- the third party id
- Throws:
RepositoryException-RepositoryException
-
setConfigurationPath
public static void setConfigurationPath(String path, Page page) throws RepositoryException
Saves the configuration reference to the campaign page- Parameters:
path- Configuration pathpage- 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' ornull. 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 CQwcmMode- 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 CQwcmMode- The mode for which the location is calculated . Used to create different locations for author and publish environmentsambitName- 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 AEMwcmMode- theWCMMode. If theWCMModeisWCMMode.EDITthen 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.
-
-