public void install(
      TierInstance tierInstance,
      ClaudiaData claudiaData,
      String envName,
      String vdc,
      ProductRelease productRelease,
      Set<Attribute> attributes,
      Task task,
      String callback)
      throws EntityNotFoundException {

    EnvironmentInstance environmentInstance = environmentInstanceManager.load(vdc, envName);

    try {
      ProductInstance productInstance =
          productInstanceManager.install(
              tierInstance, claudiaData, environmentInstance, productRelease);
      log.info(
          "Product "
              + productRelease.getProduct()
              + '-'
              + productRelease.getVersion()
              + " installed successfully");
    } catch (InvalidProductInstanceRequestException e) {
      String errorMsg = e.getMessage();
      ProductInstance instance = getInstalledProduct(productRelease, tierInstance.getVM());
      if (instance != null) {
        updateErrorTask(instance, task, errorMsg, e);
      } else {
        updateErrorTask(task, errorMsg, e);
      }
    } catch (Exception e) {
      String errorMsg =
          "The product "
              + productRelease.getProduct()
              + "-"
              + productRelease.getVersion()
              + " can not be installed in"
              + tierInstance.getVM();
      ProductInstance instance = getInstalledProduct(productRelease, tierInstance.getVM());
      if (instance != null) {
        updateErrorTask(instance, task, errorMsg, e);
      } else {
        updateErrorTask(task, errorMsg, e);
      }
    } finally {
      notifyTask(callback, task);
    }
  }
  /** It checks the relation with environments. */
  private void validateTierInEnvInstance(String environmentName, String vdc)
      throws InvalidEntityException {
    Environment environment;
    try {
      environment = environmentManager.load(environmentName, vdc);
    } catch (EntityNotFoundException e) {
      log.error("The enviornment " + environmentName + " does not exist");
      throw new InvalidEntityException("The enviornment " + environmentName + " does not exist");
    }
    EnvironmentInstanceSearchCriteria criteria = new EnvironmentInstanceSearchCriteria();

    criteria.setVdc(vdc);
    criteria.setEnvironment(environment);

    List<EnvironmentInstance> envInstances = environmentInstanceManager.findByCriteria(criteria);

    if (envInstances != null && envInstances.size() != 0) {
      throw new InvalidEntityException("The environment is being used by an env instance");
    }
  }