/** 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");
    }
  }