Interface TargetService

All Known Implementing Classes:
TargetServiceImpl

public interface TargetService
Service that manages targets.
Author:
avasquez
  • Method Details

    • targetExists

      boolean targetExists(String env, String siteName) throws TargetServiceException
      Returns true if the target associated to the env and site name exists.
      Parameters:
      env - the target's environment (e.g. dev)
      siteName - the target's site name (e.g. mysite)
      Returns:
      true if the target exists, false otherwise
      Throws:
      TargetServiceException - if a general error occurs
    • createTarget

      Target createTarget(String env, String siteName, boolean replace, String templateName, Map<String,Object> templateParams) throws TargetAlreadyExistsException, TargetServiceException
      Creates a new target with it's own configuration. Creating a target also triggers its create lifecycle hooks.
      Parameters:
      env - the target's environment (e.g. dev)
      siteName - the target's site name (e.g. mysite)
      replace - indicates that if there's a target with the same name, the target config should be replaced.
      templateName - the name of the template used to create the target configuration (can be null).
      templateParams - the parameters that the template needs.
      Returns:
      the created target
      Throws:
      TargetAlreadyExistsException - if the target for the specified env and site name already exists
      TargetServiceException - if a general error occurs
    • deleteTarget

      void deleteTarget(String env, String siteName) throws TargetNotFoundException, TargetServiceException
      Deletes a target with the given ID. Deleting the target also triggers its delete lifecycle hooks.
      Parameters:
      env - the target's environment (e.g. dev)
      siteName - the target's site name (e.g. mysite)
      Throws:
      TargetNotFoundException - if the target for the specified env and site name doesn't exist
      TargetServiceException - if a general error occurs
    • resolveTargets

      List<Target> resolveTargets() throws TargetServiceException
      Scans for target configurations, loading targets with new/modified configuration and unloading targets with no configuration. This method triggers no lifecycle hooks.
      Returns:
      existing targets, after being loaded
      Throws:
      TargetServiceException - if a general error occurs
    • getAllTargets

      List<Target> getAllTargets() throws TargetServiceException
      Returns all targets.
      Returns:
      the list of targets
      Throws:
      TargetServiceException - if a general error occurs
    • getTarget

      Returns the current target with the given ID
      Parameters:
      env - the target's environment (e.g. dev)
      siteName - the target's site name (e.g. mysite)
      Returns:
      the target info
      Throws:
      TargetNotFoundException - if the target for the specified env and site name doesn't exist
      TargetServiceException - if a general error occurs
    • recreateIndex

      void recreateIndex(String env, String siteName) throws TargetNotFoundException, org.craftercms.commons.config.ConfigurationException
      Recreates the underlying OpenSearch index for a given target
      Parameters:
      env - the target's environment (e.g. dev)
      siteName - the target's site name (e.g. mysite)
      Throws:
      TargetNotFoundException - if the target for the specified env and site name doesn't exist
      org.craftercms.commons.config.ConfigurationException
    • duplicateTarget

      void duplicateTarget(String env, String sourceSiteName, String siteName, boolean replace, String templateName, Map<String,Object> templateParams) throws TargetNotFoundException, TargetAlreadyExistsException, TargetServiceException
      Duplicates a target.
      Parameters:
      env - the target's environment (e.g. dev)
      sourceSiteName - site name of the target to duplicate
      siteName - site name for the new target
      replace - replace the target if it already exists (if false and the target already exists, an exception will be thrown)
      templateName - the name of the template used to create the target configuration
      templateParams - the parameters that the template needs
      Throws:
      TargetNotFoundException
      TargetAlreadyExistsException
      TargetServiceException