class RequestStageContainer {

  public void persist() throws AmbariException {
    if (!stages.isEmpty()) {
      Request request = (null == actionRequest)
          ? requestFactory.createNewFromStages(stages, clusterHostInfo)
          : requestFactory.createNewFromStages(stages, clusterHostInfo, actionRequest);

      if (null != requestContext) {
        request.setRequestContext(requestContext);
      }

      if (request != null) { //request can be null at least in JUnit
        request.setUserName(AuthorizationHelper.getAuthenticatedName());
      }

      if (request != null && request.getStages()!= null && !request.getStages().isEmpty()) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Triggering Action Manager, request={}", request);
        }
        actionManager.sendActions(request, actionRequest);
      }
    }
  }

  public  RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager);
  public  RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager,
                               ExecuteActionRequest actionRequest);

}