/**
  * This method determines if the managed server has the capability to set multiple release/stage
  * attributes. This method is used only in the Criteria Details Page.
  *
  * @return if the server can support multiple attributes
  */
 protected boolean isServerPatched() {
   // Boolean to determine if multiple flags are allowed.
   // Multiple Release Attribute flag is allowed in:
   // Version 5.0
   // Version 4.6 with patch 04 (API Version 1.5.9.1 or later)
   try {
     String apiVersion = SamUtil.getAPIVersion(serverName);
     TraceUtil.trace3("isServerPatched: apiVersion: " + apiVersion);
     if (apiVersion.startsWith("1.5")) {
       return SamUtil.isVersionCurrentOrLaterThan(apiVersion, "1.5.9.1");
     } else {
       // This is a 5.0 GUI managing a 5.0 server
       return true;
     }
   } catch (SamFSException samEx) {
     TraceUtil.trace1("Failed to determine if the server can support multi-attr!");
     TraceUtil.trace1("Reason: " + samEx.getMessage());
     return false;
   }
 }
  public void handleSubmitRequest(RequestInvocationEvent event)
      throws ServletException, IOException, ModelControlException {
    TraceUtil.trace3("Entering");
    TraceUtil.trace3("Entering handleSubmitRequest()");
    int pageMode =
        Integer.parseInt(
            (String) getParentViewBean().getDisplayFieldValue(FileDetailsPopupViewBean.PAGE_MODE));
    TraceUtil.trace3("pageMode is " + pageMode);

    String successMsg = null, errorMsg = null;
    String[] existingAttArray = getFileAttributes().split("###");
    boolean recursive = false;
    TraceUtil.trace3("fileAttributes: " + getFileAttributes());
    SamQFSSystemFSManager fsManager = null;
    String radioValue = (String) ((CCRadioButton) getChild(RADIO)).getValue();
    TraceUtil.trace3("radioValue: " + radioValue);
    // If entry is a directory, check if RECURSIVE is checked
    if (directory) {
      CCCheckBox checkBox = (CCCheckBox) getChild(RECURSIVE);
      recursive = "true".equals((String) checkBox.getValue());
    }

    int newOption = -1, existingOption = -1, partialSize = -1;

    try {
      // Check Permission (IE7)
      if (!SecurityManagerFactory.getSecurityManager()
          .hasAuthorization(Authorization.FILE_OPERATOR)) {
        throw new SamFSException("common.nopermission");
      }

      try {
        existingOption = Integer.parseInt(existingAttArray[pageMode]);
      } catch (NumberFormatException numEx) {
        throw new SamFSException("Developer's bug found, incorrect existingOption!");
      }
      fsManager = SamUtil.getModel(serverName).getSamQFSSystemFSManager();

      switch (pageMode) {
        case MODE_ARCHIVE:
          successMsg = "fs.filedetails.archiving.success";
          errorMsg = "fs.filedetails.archiving.failed";

          try {
            newOption = Integer.parseInt(radioValue);
          } catch (NumberFormatException numEx) {
            // Developer's bug
            throw new SamFSException("Invalid radioValue detected!");
          }
          break;

        case MODE_RELEASE:
          successMsg = "fs.filedetails.releasing.success";
          errorMsg = "fs.filedetails.releasing.failed";

          if ("release".equals(radioValue)) {
            String subRadioValue = (String) ((CCRadioButton) getChild(SUB_RADIO)).getValue();
            try {
              newOption = Integer.parseInt(subRadioValue);
            } catch (NumberFormatException numEx) {
              // Developer's bug
              throw new SamFSException("Invalid subRadioValue detected!", numEx);
            }
          } else {
            newOption = Releaser.NEVER;
          }

          CCCheckBox check = (CCCheckBox) getChild(PARTIAL_RELEASE);
          if ("true".equals(check.getValue())) {
            String sizeText = (String) ((CCTextField) getChild(PARTIAL_RELEASE_SIZE)).getValue();
            try {
              partialSize = Integer.parseInt(sizeText);
            } catch (NumberFormatException numEx) {
              // let partialSize be -1 and generate error
              // in isValidPartialSize
            }
            if (!isValidPartialSize(partialSize)) {
              ((CCLabel) getChild(LABEL)).setShowError(true);
              throw new SamFSException(
                  SamUtil.getResourceString("fs.filedetails.releasing.invalidReleaseSize"));
            } else {
              newOption = newOption | Releaser.PARTIAL;
            }
          }
          break;

        case MODE_STAGE:
          successMsg = "fs.filedetails.staging.success";
          errorMsg = "fs.filedetails.staging.failed";

          if ("stage".equals(radioValue)) {
            String subRadioValue = (String) ((CCRadioButton) getChild(SUB_RADIO)).getValue();
            try {
              newOption = Integer.parseInt(subRadioValue);
            } catch (NumberFormatException numEx) {
              // Developer's bug
              throw new SamFSException("Invalid subRadioValue detected!", numEx);
            }
          } else {
            newOption = Stager.NEVER;
          }

          break;
      }

      fsManager.changeFileAttributes(
          pageMode, getFileName(), newOption, existingOption, recursive, partialSize);

      SamUtil.setInfoAlert(this, ALERT, "success.summary", successMsg, serverName);
    } catch (SamFSException samEx) {
      TraceUtil.trace1("Failed to set file attributes! Reason: " + samEx.getMessage());
      SamUtil.processException(
          samEx,
          this.getClass(),
          "handleSubmitRequest()",
          "Failed to set file attributes!",
          serverName);

      // Suppress the following two error codes because the detailed
      // error message makes no sense in this case
      // SE_RELEASE_FILES_FAILED = 30180,
      // SE_ARCHIVE_FILES_FAILED = 30629,
      SamUtil.setErrorAlert(
          this,
          ALERT,
          errorMsg,
          samEx.getSAMerrno(),
          samEx.getSAMerrno() == 30180 || samEx.getSAMerrno() == 30629 ? "" : samEx.getMessage(),
          serverName);
    }

    getParentViewBean().forwardTo(getRequestContext());
    TraceUtil.trace3("Exiting");
  }
  public void populateVersionTable() throws SamFSException {
    CCActionTableModel model = getTableModel(VERSION_TABLE);
    model.clear();

    HttpSession session = RequestManager.getRequestContext().getRequest().getSession();
    HashMap myHashMap =
        (HashMap) session.getAttribute(Constants.SessionAttributes.VERSION_HIGHLIGHT);

    if (myHashMap == null) {
      // Start parsing the XML file

      try {
        SAXHandler.parseIt();
      } catch (SamFSException ex) {
        // Failed to parse version highlight XML file
        SamUtil.setErrorAlert(
            getParentViewBean(),
            ServerCommonViewBeanBase.CHILD_COMMON_ALERT,
            "VersionHighlight.error",
            ex.getSAMerrno(),
            ex.getMessage(),
            "");
        return;
      }

      // Retrieve the HashMap after parsing the XML file
      myHashMap = SAXHandler.getHashMap();

      // Save hashMap into Session
      session.setAttribute(Constants.SessionAttributes.VERSION_HIGHLIGHT, myHashMap);
    }

    for (int i = 0; i < myHashMap.size(); i++) {
      if (i > 0) {
        model.appendRow();
      }

      HighlightInfo highlightInfo = (HighlightInfo) myHashMap.get(new Integer(i));

      String featureType = highlightInfo.getFeatureType();
      featureType = featureType == null ? "" : featureType;

      // pre-populate blank images into the model,
      // overwrite them later if necessary
      model.setValue("FirstImage", Constants.Image.ICON_BLANK);
      model.setValue("SecondImage", Constants.Image.ICON_BLANK);
      model.setValue("ThirdImage", Constants.Image.ICON_BLANK);
      model.setValue("SupportText", "");

      // populate the feature name
      if (featureType.equals("summary")) {
        model.setValue(
            "NameText",
            new NonSyncStringBuffer("<b>")
                .append(SamUtil.getResourceString(highlightInfo.getFeatureName()))
                .append("</b>")
                .toString());
      } else {
        String heading = "---- ";
        if (featureType.equals("detail")) {
          heading = "-- ";
        }
        model.setValue(
            "NameText",
            new NonSyncStringBuffer(heading)
                .append(SamUtil.getResourceString(highlightInfo.getFeatureName()))
                .toString());
        model.setValue("SupportText", highlightInfo.getServerVersion());

        String[] versionInfoArray = highlightInfo.getVersionInfo().split("###");

        for (int j = 0; j < versionInfoArray.length; j++) {
          String[] versionInfo = versionInfoArray[j].split(",");

          if (versionInfo[0].equals("version.highlight.versionnumber.50")) {
            model.setValue("FirstImage", getImage(versionInfo[1]));
          } else if (versionInfo[0].equals("version.highlight.versionnumber.46")) {
            model.setValue("SecondImage", getImage(versionInfo[1]));
            model.setValue("FirstImage", Constants.Image.ICON_AVAILABLE);
          } else if (versionInfo[0].equals("version.highlight.versionnumber.45")) {
            model.setValue("ThirdImage", getImage(versionInfo[1]));
            model.setValue("FirstImage", Constants.Image.ICON_AVAILABLE);
            model.setValue("SecondImage", Constants.Image.ICON_AVAILABLE);
          } else {
            model.setValue("ThirdImage", Constants.Image.ICON_AVAILABLE);
            model.setValue("FirstImage", Constants.Image.ICON_AVAILABLE);
            model.setValue("SecondImage", Constants.Image.ICON_AVAILABLE);
          }
        }
      }
    }
  }