Class AbstractDeployer

java.lang.Object
org.craftercms.studio.impl.v2.deployment.AbstractDeployer
All Implemented Interfaces:
Deployer
Direct Known Subclasses:
PreviewDeployer, ServerlessDeliveryDeployer

public abstract class AbstractDeployer extends Object implements Deployer
Base abstract class for Deployers. Provides the commons methods that call the Deployer APIs.
Author:
avasquez
  • Field Details

  • Constructor Details

    • AbstractDeployer

      public AbstractDeployer(StudioConfiguration studioConfiguration, org.craftercms.commons.rest.RestTemplate restTemplate)
  • Method Details

    • doCreateTarget

      protected void doCreateTarget(String site, String environment, String template, boolean replace, boolean disableDeployCron, String localRepoPath, String repoUrl, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> additionalParams) throws IllegalStateException, org.springframework.web.client.RestClientException
      Throws:
      IllegalStateException
      org.springframework.web.client.RestClientException
    • doDeleteTarget

      protected void doDeleteTarget(String site, String environment)
    • getCreateTargetRequestBody

      protected Map<String,Object> getCreateTargetRequestBody(String site, String environment, String template, boolean replace, boolean disableDeployCron, String localRepoPath, String repoUrl, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> additionalParams)
    • getDuplicateTargetRequestBody

      protected Map<String,Object> getDuplicateTargetRequestBody(String sourceSite, String site, String environment, String template, boolean replace, boolean disableDeployCron, String localRepoPath, String repoUrl, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> additionalParams)
      Get the body parameters for the duplicate-target request.
      Parameters:
      sourceSite - the site to duplicate from
      site - the new site
      environment - the target environment, e.g.: authoring
      template - the deployer target template
      replace - true to replace the target if it already exists
      disableDeployCron - true to disable the deploy cron (e.g. for preview target)
      localRepoPath - the local path to clone the repository. // TODO: this is used for serverless only, should this be a deployer config instead?)
      repoUrl - the repository URL
      additionalParams - additional parameters to pass to the deployer to be consumed by the target template
      Returns:
      a Map containing the parameters, preserving the hierarchical structure of the configuration parameters
    • getSourceTemplateParams

      protected Map<String,Object> getSourceTemplateParams(String sourceSite)
      Get a source site parameters Map to pass to the target template. This is useful for deployer to get context on the duplicate source site
      Parameters:
      sourceSite - the source site to duplicate from
      Returns:
      a Map containing the parameters
    • addAdditionalParams

      protected void addAdditionalParams(Map<String,Object> params, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> additionalParams)
    • addChildParams

      protected void addChildParams(Map<String,Object> childParams, org.apache.commons.configuration2.tree.ImmutableNode parentNode, org.apache.commons.configuration2.interpol.ConfigurationInterpolator interpolator)
    • getRepoUrl

      protected String getRepoUrl(String configKey, String site)
    • doDuplicateTarget

      protected void doDuplicateTarget(String sourceSiteId, String siteId, String env, String template, boolean replace, boolean disableDeployCron, String localRepoPath, String repoUrl, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> additionalParams) throws org.springframework.web.client.RestClientException
      Call Deployer API to duplicate a given target
      Parameters:
      sourceSiteId - the site to duplicate from
      siteId - the new site id
      env - the target environment, e.g.: authoring
      template - the deployer target template
      replace - true to replace the target if it already exists
      disableDeployCron - true to disable the deploy cron (e.g. for preview target)
      localRepoPath - the local path to clone the repository. // TODO: this is used for serverless only, should this be a deployer config instead?)
      repoUrl - the repository URL
      additionalParams - additional parameters to pass to the deployer to be consumed by the target template
      Throws:
      org.springframework.web.client.RestClientException - if an error occurs while calling Deployer API
    • getDuplicateTargetUrl

      protected String getDuplicateTargetUrl(String sourceSiteId, String env)
      Get the URL of the Deployer API to duplicate a given target
      Parameters:
      sourceSiteId - the site to duplicate from
      env - the target environment, e.g.: authoring
      Returns:
      the URL of the Deployer API to duplicate a given target
    • getCreateTargetUrl

      protected abstract String getCreateTargetUrl()
    • getDeleteTargetUrl

      protected abstract String getDeleteTargetUrl(String site, String environment)