Class OfferHelper
- java.lang.Object
-
- com.day.cq.analytics.testandtarget.util.OfferHelper
-
public class OfferHelper extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPN_LOCATIONMbox location property namestatic java.lang.StringPN_TESTANDTARGETCONFIGAccount-Reference property namestatic java.lang.StringPN_THIRDPARTYIDThird-Party property namestatic java.lang.StringRT_CAMPAIGNCampaign resource typestatic java.lang.StringRT_EXPERIENCEExperience resource typestatic java.lang.StringRT_OFFER_PROXYOffer proxy resource typestatic java.lang.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 java.lang.StringgetCampaignName(java.lang.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 java.lang.StringgetOfferLocation(Page offerPage, WCMMode wcmMode)Returns the offer location as it should be sent to Adobe Targetstatic java.lang.StringgetOfferLocation(Page offerPage, WCMMode wcmMode, java.lang.String ambitName)Returns the offer location as it should be sent to Adobe Targetstatic java.lang.StringgetOfferName(Page offerPage, WCMMode wcmMode)Returns the offer name based on this offer's location.static java.lang.StringgetOfferName(Page offerPage, WCMMode wcmMode, java.lang.String ambitName)Returns the offer name based on this offer's location.static java.lang.StringgetOfferName(java.lang.String path)Returns an Offer name constructed by concatenating the path and replacing slashes (/) with dashes (-).static java.lang.StringgetThirdPartyCampaignId(Node contentResourceNode)Returns the third party id for a campaign page's resource nodestatic java.lang.StringgetThirdPartyID(Node node)Returns the third party ID of a Node if property exists, otherwise one is generated in Timestamp format.static voidsetConfigurationPath(java.lang.String path, Page page)Saves the configuration reference to the campaign pagestatic voidsetThirdPartyID(Node node, java.lang.String operation, java.lang.String thirdpartyid)Saves or deletes the third party ID property in the providedNodeaccording to the executed operation.
-
-
-
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
-
-
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 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 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 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 java.lang.String getCampaignName(java.lang.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, java.lang.String operation, java.lang.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 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-Nodeof pages contentresourcenode- Returns:
- the third party id
- Throws:
RepositoryException-RepositoryException
-
setConfigurationPath
public static void setConfigurationPath(java.lang.String path, Page page) throws RepositoryExceptionSaves 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 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 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 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 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.
-
-