Class TemplateEditorManagerClient

java.lang.Object
org.apache.sling.testing.clients.AbstractSlingClient
org.apache.sling.testing.clients.SlingClient
com.adobe.cq.testing.client.CQClient
com.adobe.cq.testing.client.TemplateEditorManagerClient
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.client.HttpClient

public final class TemplateEditorManagerClient extends CQClient
Client to create and update the page template. To create a default template use createDefaultTemplate(String configPath, String title, String Description) To create a template with give type use createTemplate(String configPath, String templateType, String title, String Description) To create Default Container on top level of a template use createTopLevelDefaultContainer(String templatePath, String name) To create a Default container in a template use createDefaultContainer(String templatePath, String location, String name)
  • Constructor Details

    • TemplateEditorManagerClient

      public TemplateEditorManagerClient(org.apache.http.impl.client.CloseableHttpClient http, org.apache.sling.testing.clients.SlingClientConfig config) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
    • TemplateEditorManagerClient

      public TemplateEditorManagerClient(URI serverUrl, String user, String password) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
  • Method Details

    • createDefaultTemplate

      public String createDefaultTemplate(String configPath, String title, String description) throws org.apache.sling.testing.clients.ClientException, IOException
      Creates a default page template of type HTML5
      Parameters:
      configPath - path of config to be used to create a page template
      title - title of the template
      description - description of the template
      Returns:
      created template path
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request fails
      IOException - if json parsing fails
    • createTemplate

      public String createTemplate(String configPath, String templateType, String title, String description) throws org.apache.sling.testing.clients.ClientException, IOException
      Creates a page template with given template type
      Parameters:
      configPath - path of config to be used to create a page template
      templateType - type of the template
      title - title of the template
      description - description of the template
      Returns:
      created template path
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request fails
      IOException - if json parsing fails
    • createDefaultContainer

      public String createDefaultContainer(String templatePath, String location, String nameHint) throws org.apache.sling.testing.clients.ClientException
      Creates default layout container (responsivegrid) on the provided location of the provided template
      Parameters:
      templatePath - : path of the template the layout container should be created, i.e. /conf/myConfig/settings/wcm/templates/myTemplate
      location - : the location the layout container should be created, i.e. /structure/jcr:content/root/
      nameHint - : name hint for the layout container or null to create one
      Returns:
      path of the created layout container
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request fails
    • createTopLevelDefaultContainer

      public String createTopLevelDefaultContainer(String templatePath, String nameHint) throws org.apache.sling.testing.clients.ClientException
      Creates a default layout container (responsivegrid) on structure top level of the provided template
      Parameters:
      templatePath - : path of the template the layout container should be created, i.e. /conf/myConfig/settings/wcm/templates/myTemplate
      nameHint - : name hint for the layout container or null to create one
      Returns:
      path of the created layout container
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request fails
    • enable

      public void enable(String templatePath) throws org.apache.sling.testing.clients.ClientException
      Enables a existing template
      Parameters:
      templatePath - path of the template to be enabled
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request fails
    • disable

      public void disable(String templatePath) throws org.apache.sling.testing.clients.ClientException
      Disables an existing template
      Parameters:
      templatePath - path of the template to be disabled
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request fails
    • importPolicy

      public String importPolicy(String configPath, String jsonString) throws org.apache.sling.testing.clients.ClientException
      Update the policy of an existing CQConfig with the provides policy
      Parameters:
      configPath - path of the config which needs to be updated
      jsonString - policy to be updated in json format
      Returns:
      updated config path
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request fails
    • unlockStructureComponent

      public void unlockStructureComponent(String componentPath) throws org.apache.sling.testing.clients.ClientException
      Unlock a component in the structure tree of a template
      Parameters:
      componentPath - : path of the component to be unlocked
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request fails
    • setStructureComponentLock

      public void setStructureComponentLock(String componentPath, boolean isLocked) throws org.apache.sling.testing.clients.ClientException
      Lock / unlock a component in the structure tree of a template
      Parameters:
      componentPath - : path of the component to be locked / unlocked
      isLocked - : true to lock the component, false to unlock the component
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request fails
    • setComponentPolicy

      public String setComponentPolicy(String componentPath, String policyPath) throws org.apache.sling.testing.clients.ClientException
      Set the policy mapping for a component. Note: The componentPath is the path to the component in the template structure tree except for components in a unlocked layout container, here the component path is the path to the layout container component in the template structure tree plus the component resource type, i.e. for a foundation text component in unlocked main layout container: /conf/myConfig/settings/wcm/templates/myTemplate/structure/jcr:content/root/responsivegrid/wcm/foundation/components/text
      Parameters:
      componentPath - : the path of the component for which the policy should be set
      policyPath - : the path of the policy to be set for the component, i.e. wcm/foundation/components/responsivegrid/default
      Returns:
      path of the created/updated component policy
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request fails