Class MboxHelper
- java.lang.Object
-
- com.day.cq.analytics.testandtarget.util.MboxHelper
-
public class MboxHelper extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
generateLocationName(Resource currentResource, WCMMode wcmMode, java.lang.String... ambitMappings)
Generates the location name used by this location in Adobe Target.static java.util.List<java.lang.String>
getClientContextParameterNames(Resource resource, InheritanceValueMap pageProperties, ConfigurationManager configurationManager)
Returns the names of the ClientContext parameters which should be sent as part of mbox callsstatic java.lang.String
getCustomMboxJsPath(Resource resource, Page currentPage, ConfigurationManager cfgMgr)
Returns the repository path to a custommbox.js
file for the current specifiedresource
andcurrentPage
static java.util.Map<java.lang.String,java.lang.String>
getMappedClientContextParameterNames(Resource resource, InheritanceValueMap pageProperties, ConfigurationManager configurationManager)
Returns the names and mapped values of the ClientContext parameters which should be sent as part of mbox callsstatic java.lang.String
getMboxId(java.lang.String location)
Generates an mbox ID from an mbox location.static java.lang.String
getMboxId(Resource rsrc)
Generates an mbox ID.static java.lang.String
getMboxName(Resource rsrc)
Returns a name for theResource
.static java.util.Map<java.lang.String,java.lang.String>
getStaticParameters(Resource resource)
Returns the static parameters configured for this target component.static boolean
isAccurateRendering(Resource resource)
Returns true if the mbox represented by theresource
has accurateTargeting enabled.static java.lang.String
qualifyMboxNameOrId(java.lang.String mboxNameOrId, WCMMode wcmMode)
Adds the WCM mode qualifier to the mbox name, if necessarystatic java.lang.String
qualifyMboxNameOrId(java.lang.String mboxNameOrId, WCMMode wcmMode, java.lang.String ambitName)
Adds the necessary qualifiers (WCM Mode and the name of the ambit) to the mbox namestatic Resource
searchStartElement(Resource resource)
Search the start element for the current element type.
-
-
-
Method Detail
-
getMboxName
public static java.lang.String getMboxName(Resource rsrc)
Returns a name for theResource
. As name the jcr:title with removed whitespaces is used if available. If no jcr:title is specified, a name is generated bygetMboxId(Resource)
.
-
generateLocationName
public static java.lang.String generateLocationName(Resource currentResource, WCMMode wcmMode, java.lang.String... ambitMappings)
Generates the location name used by this location in Adobe Target. The location name uses the following pattern: {location-name-in-aem}-{the non-master ambit names joined by # and hashed using MD5}--{wcm mode}. If theWCMMode
isWCMMode.DISABLED
then it's omitted. If not, the "--author" suffix is used.
-
getMboxId
public static java.lang.String getMboxId(Resource rsrc)
Generates an mbox ID. The ID is generated by replacing slashes and removing jcr:content from the resource path of the start element. If the corresponding start element can not be found the provided element is used.- Parameters:
rsrc
- Resource of start/end element- Returns:
- an MboxId for the
Resource
-
qualifyMboxNameOrId
public static java.lang.String qualifyMboxNameOrId(java.lang.String mboxNameOrId, WCMMode wcmMode)
Adds the WCM mode qualifier to the mbox name, if necessary- Parameters:
mboxNameOrId
- the mbox namewcmMode
- theWCMMode
- Returns:
- the mbox name containing the WCM mode, if necessary. It the WCM mode is
WCMMode.DISABLED
then the return value is the one passed in the mboxNameOrId parameter
-
qualifyMboxNameOrId
public static java.lang.String qualifyMboxNameOrId(java.lang.String mboxNameOrId, WCMMode wcmMode, java.lang.String ambitName)
Adds the necessary qualifiers (WCM Mode and the name of the ambit) to the mbox name- Parameters:
mboxNameOrId
- the actual mbox namewcmMode
- theWCMMode
ambitName
- the name of the ambit, if this mbox belongs to a site using MSM- Returns:
- the location name containing the ambit name and the wcm mode, if necessary. If the WCM mode is
WCMMode.DISABLED
and the ambit name is "master" then the return value is the one passed on the mboxNameOrId parameter
-
getMboxId
public static java.lang.String getMboxId(java.lang.String location)
Generates an mbox ID from an mbox location.
Slashes are replaced with dashes. If this location is a repository path thenjcr:content
is stripped from it.- Parameters:
location
- the mbox location- Returns:
- the mbox id
- See Also:
getMboxId(Resource)
-
searchStartElement
public static Resource searchStartElement(Resource resource)
Search the start element for the current element type.- Parameters:
resource
-Resource
- Returns:
- start element for the current element type
-
getCustomMboxJsPath
public static java.lang.String getCustomMboxJsPath(Resource resource, Page currentPage, ConfigurationManager cfgMgr) throws RepositoryException
Returns the repository path to a custommbox.js
file for the current specifiedresource
andcurrentPage
- Parameters:
resource
-Resource
currentPage
- currentPage
cfgMgr
-ConfigurationManager
- Returns:
- the path to the custom
mbox.js
file or null if the default one should be used - Throws:
RepositoryException
-RepositoryException
-
isAccurateRendering
public static boolean isAccurateRendering(Resource resource) throws RepositoryException
Returns true if the mbox represented by theresource
has accurateTargeting enabled.- Parameters:
resource
-Resource
- Returns:
- true if the mbox represented by the
resource
has accurateTargeting enabled. - Throws:
RepositoryException
-RepositoryException
-
getClientContextParameterNames
public static java.util.List<java.lang.String> getClientContextParameterNames(Resource resource, InheritanceValueMap pageProperties, ConfigurationManager configurationManager) throws RepositoryException
Returns the names of the ClientContext parameters which should be sent as part of mbox callsThis method merges the directly defined parameter names with the parameters names inherited from a Adobe Target framework.
- Parameters:
resource
- thetarget
resourcepageProperties
-InheritanceValueMap
configurationManager
-ConfigurationManager
- Returns:
- a list of parameter names, never null
- Throws:
RepositoryException
-RepositoryException
-
getMappedClientContextParameterNames
public static java.util.Map<java.lang.String,java.lang.String> getMappedClientContextParameterNames(Resource resource, InheritanceValueMap pageProperties, ConfigurationManager configurationManager) throws RepositoryException
Returns the names and mapped values of the ClientContext parameters which should be sent as part of mbox callsThis method merges the directly defined parameter names with the parameters names inherited from a Adobe Target framework.
The mapped values are usually defined by the
Framework
. In case they are defined statically on the component the property name is transformed by transforming all slashes ('/') to dots ('.').- Parameters:
resource
- thetarget
resourcepageProperties
-InheritanceValueMap
configurationManager
-ConfigurationManager
- Returns:
- parameter mappings never null
- Throws:
RepositoryException
-RepositoryException
-
getStaticParameters
public static java.util.Map<java.lang.String,java.lang.String> getStaticParameters(Resource resource)
Returns the static parameters configured for this target component. These parameters are used when performing mbox calls.- Parameters:
resource
- theResource
representing the target component- Returns:
- a
Map
containing the mapped parameters
-
-