Package org.craftercms.deployer.api
Interface TargetService
- All Known Implementing Classes:
TargetServiceImpl
public interface TargetService
Service that manages targets.
- Author:
- avasquez
-
Method Summary
Modifier and TypeMethodDescriptioncreateTarget(String env, String siteName, boolean replace, String templateName, Map<String, Object> templateParams) Creates a new target with it's own configuration.voiddeleteTarget(String env, String siteName) Deletes a target with the given ID.voidduplicateTarget(String env, String sourceSiteName, String siteName, boolean replace, String templateName, Map<String, Object> templateParams) Duplicates a target.Returns all targets.Returns the current target with the given IDvoidrecreateIndex(String env, String siteName) Recreates the underlying OpenSearch index for a given targetScans for target configurations, loading targets with new/modified configuration and unloading targets with no configuration.booleantargetExists(String env, String siteName) Returns true if the target associated to the env and site name exists.
-
Method Details
-
targetExists
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, TargetServiceExceptionCreates 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 existsTargetServiceException- 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 existTargetServiceException- if a general error occurs
-
resolveTargets
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
Returns all targets.- Returns:
- the list of targets
- Throws:
TargetServiceException- if a general error occurs
-
getTarget
Target getTarget(String env, String siteName) throws TargetNotFoundException, TargetServiceException 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 existTargetServiceException- 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 existorg.craftercms.commons.config.ConfigurationException
-
duplicateTarget
void duplicateTarget(String env, String sourceSiteName, String siteName, boolean replace, String templateName, Map<String, Object> templateParams) throws TargetNotFoundException, TargetAlreadyExistsException, TargetServiceExceptionDuplicates a target.- Parameters:
env- the target's environment (e.g. dev)sourceSiteName- site name of the target to duplicatesiteName- site name for the new targetreplace- 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 configurationtemplateParams- the parameters that the template needs- Throws:
TargetNotFoundExceptionTargetAlreadyExistsExceptionTargetServiceException
-