use of alien4cloud.paas.exception.OrchestratorDeploymentIdConflictException in project alien4cloud by alien4cloud.
the class DeployService method generateOrchestratorDeploymentId.
/**
* Generate the human readable deployment id for the orchestrator.
*
* @param envId Id of the deployed environment.
* @param orchestratorId Id of the orchestrator on which the deployment is performed.
* @return The orchestrator deployment id.
* @throws alien4cloud.paas.exception.OrchestratorDeploymentIdConflictException
*/
private String generateOrchestratorDeploymentId(String envId, String orchestratorId) throws OrchestratorDeploymentIdConflictException {
log.debug("Generating deployment paaS Id...");
log.debug("All spaces will be replaced by an \"_\" charactr. You might consider it while naming your applications.");
ApplicationEnvironment env = applicationEnvironmentService.getOrFail(envId);
Orchestrator orchestrator = orchestratorService.getOrFail(orchestratorId);
String namePattern = orchestrator.getDeploymentNamePattern();
ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression(namePattern);
String orchestratorDeploymentId = (String) exp.getValue(new OrchestratorIdContext(env, applicationService.getOrFail(env.getApplicationId()), namePattern.contains("metaProperties[")));
// ensure that the id is not used by another deployment.
if (deploymentService.isActiveDeployment(orchestratorId, orchestratorDeploymentId)) {
throw new OrchestratorDeploymentIdConflictException("Conflict detected with the generated paasId <" + orchestratorDeploymentId + ">.");
}
return orchestratorDeploymentId;
}
Aggregations