Class MboxHelper

java.lang.Object
com.day.cq.analytics.testandtarget.util.MboxHelper

public class MboxHelper extends Object
  • Method Details

    • getMboxName

      public static String getMboxName(Resource rsrc)
      Returns a name for the Resource. As name the jcr:title with removed whitespaces is used if available. If no jcr:title is specified, a name is generated by getMboxId(Resource).
      Parameters:
      rsrc - Resource
      Returns:
      a name for the Resource
    • generateLocationName

      public static String generateLocationName(Resource currentResource, WCMMode wcmMode, 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 the WCMMode is WCMMode.DISABLED then it's omitted. If not, the "--author" suffix is used.
      Parameters:
      currentResource - the Resource representing the target component
      wcmMode - the WCMMode
      ambitMappings - Array of ambits
      Returns:
      the location name generated using the pattern described above
    • getMboxId

      public static 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 String qualifyMboxNameOrId(String mboxNameOrId, WCMMode wcmMode)
      Adds the WCM mode qualifier to the mbox name, if necessary
      Parameters:
      mboxNameOrId - the mbox name
      wcmMode - the WCMMode
      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 String qualifyMboxNameOrId(String mboxNameOrId, WCMMode wcmMode, String ambitName)
      Adds the necessary qualifiers (WCM Mode and the name of the ambit) to the mbox name
      Parameters:
      mboxNameOrId - the actual mbox name
      wcmMode - the WCMMode
      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 String getMboxId(String location)
      Generates an mbox ID from an mbox location.
      Slashes are replaced with dashes. If this location is a repository path then jcr:content is stripped from it.
      Parameters:
      location - the mbox location
      Returns:
      the mbox id
      See Also:
    • 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 String getCustomMboxJsPath(Resource resource, Page currentPage, ConfigurationManager cfgMgr) throws RepositoryException
      Returns the repository path to a custom mbox.js file for the current specified resource and currentPage
      Parameters:
      resource - Resource
      currentPage - current Page
      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 the resource has accurateTargeting enabled.
      Parameters:
      resource - Resource
      Returns:
      true if the mbox represented by the resource has accurateTargeting enabled.
      Throws:
      RepositoryException - RepositoryException
    • getClientContextParameterNames

      public static List<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 calls

      This method merges the directly defined parameter names with the parameters names inherited from a Adobe Target framework.

      Parameters:
      resource - the target resource
      pageProperties - InheritanceValueMap
      configurationManager - ConfigurationManager
      Returns:
      a list of parameter names, never null
      Throws:
      RepositoryException - RepositoryException
    • getMappedClientContextParameterNames

      public static Map<String,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 calls

      This 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 - the target resource
      pageProperties - InheritanceValueMap
      configurationManager - ConfigurationManager
      Returns:
      parameter mappings never null
      Throws:
      RepositoryException - RepositoryException
    • getStaticParameters

      public static Map<String,String> getStaticParameters(Resource resource)
      Returns the static parameters configured for this target component. These parameters are used when performing mbox calls.
      Parameters:
      resource - the Resource representing the target component
      Returns:
      a Map containing the mapped parameters