/**
   * This method gets called when calling this action. If the stateId is 2 which equals that the
   * user tries to prepublish the page. If so we ask the user for a comment as this is to be
   * regarded as a new version.
   */
  public String doExecute() throws Exception {
    setSiteNodeVersionId(getRequest().getParameterValues("selSiteNodeVersions"));
    Iterator it = siteNodeVersionId.iterator();

    List events = new ArrayList();
    while (it.hasNext()) {
      Integer siteNodeVersionId = (Integer) it.next();
      logger.info("Publishing:" + siteNodeVersionId);
      SiteNodeVersion siteNodeVersion =
          SiteNodeStateController.getController()
              .changeState(
                  siteNodeVersionId,
                  SiteNodeVersionVO.PUBLISH_STATE,
                  getVersionComment(),
                  overrideVersionModifyer,
                  this.recipientFilter,
                  this.getInfoGluePrincipal(),
                  null,
                  events);
    }

    setContentVersionId(getRequest().getParameterValues("selContentVersions"));
    Iterator contentVersionIdsIterator = contentVersionId.iterator();

    while (contentVersionIdsIterator.hasNext()) {
      Integer contentVersionId = (Integer) contentVersionIdsIterator.next();
      logger.info("Publishing:" + contentVersionId);
      ContentVersion contentVersion =
          ContentStateController.changeState(
              contentVersionId,
              ContentVersionVO.PUBLISH_STATE,
              getVersionComment(),
              this.overrideVersionModifyer,
              this.recipientFilter,
              this.getInfoGluePrincipal(),
              null,
              events);
    }

    if (attemptDirectPublishing.equalsIgnoreCase("true")) {
      PublicationVO publicationVO = new PublicationVO();
      publicationVO.setName("Direct publication by " + this.getInfoGluePrincipal().getName());
      publicationVO.setDescription(getVersionComment());
      publicationVO.setRepositoryId(repositoryId);
      publicationVO =
          PublicationController.getController()
              .createAndPublish(
                  publicationVO, events, this.overrideVersionModifyer, this.getInfoGluePrincipal());
    }

    if (returnAddress != null && !returnAddress.equals("")) {
      this.getResponse().sendRedirect(returnAddress);

      return NONE;
    }

    return "success";
  }
 public ConstraintRule getRule(String fieldName) {
   return publicationVO.getRule(fieldName);
 }