public void createOrUpdate(StackEntity stack)
      throws AmbariException {
    if (null == stack.getStackId()) {
      create(stack);
    } else {
      merge(stack);
    }
  }
Creates or updates the specified entity. This method will check
{@link StackEntity#getStackId()} in order to determine whether the entity
should be created or merged.

@param stack
         the stack to create or update (not {@code null}).
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StackDAO.java