private void onResetParameter() {
    ConfirmationModel model = (ConfirmationModel) getWindow();

    if (model.getProgress() != null) {
      return;
    }

    if (getSelectedItem() == null) {
      return;
    }
    GlusterVolumeOptionEntity selectedOption = getSelectedItem();

    ResetGlusterVolumeOptionsParameters parameters =
        new ResetGlusterVolumeOptionsParameters(
            selectedOption.getVolumeId(), selectedOption, false);

    model.startProgress();

    Frontend.getInstance()
        .runAction(
            VdcActionType.ResetGlusterVolumeOptions,
            parameters,
            new IFrontendActionAsyncCallback() {

              @Override
              public void executed(FrontendActionAsyncResult result) {
                ConfirmationModel localModel = (ConfirmationModel) result.getState();
                localModel.stopProgress();
                cancel();
              }
            },
            model);
  }
  private void resetParameter() {
    if (getWindow() != null) {
      return;
    }

    if (getSelectedItem() == null) {
      return;
    }
    GlusterVolumeOptionEntity selectedOption = getSelectedItem();

    ConfirmationModel model = new ConfirmationModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().resetOptionVolumeTitle());
    model.setHelpTag(HelpTag.reset_option);
    model.setHashName("reset_option"); // $NON-NLS-1$
    model.setMessage(ConstantsManager.getInstance().getConstants().resetOptionVolumeMsg());

    ArrayList<String> list = new ArrayList<String>();
    list.add(selectedOption.getKey());
    model.setItems(list);

    UICommand okCommand =
        UICommand.createDefaultOkUiCommand("OnResetParameter", this); // $NON-NLS-1$
    model.getCommands().add(okCommand);
    UICommand cancelCommand = UICommand.createCancelUiCommand("OnCancel", this); // $NON-NLS-1$
    model.getCommands().add(cancelCommand);
  }
  private void onSetParameter() {
    if (getEntity() == null) {
      return;
    }

    GlusterVolumeEntity volume = getEntity();

    VolumeParameterModel model = (VolumeParameterModel) getWindow();

    if (!model.validate()) {
      return;
    }

    GlusterVolumeOptionEntity option = new GlusterVolumeOptionEntity();
    option.setVolumeId(volume.getId());
    option.setKey(model.getSelectedKey().getEntity());
    option.setValue(model.getValue().getEntity());

    model.startProgress();

    Frontend.getInstance()
        .runAction(
            VdcActionType.SetGlusterVolumeOption,
            new GlusterVolumeOptionParameters(option),
            new IFrontendActionAsyncCallback() {

              @Override
              public void executed(FrontendActionAsyncResult result) {
                VolumeParameterListModel localModel = (VolumeParameterListModel) result.getState();
                localModel.postOnSetParameter(result.getReturnValue());
              }
            },
            this);
  }
  @Override
  public boolean equals(Object obj) {
    if (!(obj instanceof GlusterVolumeOptionEntity)) {
      return false;
    }

    GlusterVolumeOptionEntity option = (GlusterVolumeOptionEntity) obj;
    return (getId().equals(option.getId())
        && (volumeId != null && volumeId.equals(option.getVolumeId()))
        && key.equals(option.getKey())
        && value.equals(option.getValue()));
  }
  /**
   * Sets all options of a volume by invoking the action {@link
   * VdcActionType#SetGlusterVolumeOption} in a loop. <br>
   * Errors if any are collected and added to "executeFailedMessages"
   *
   * @param volume
   */
  private void setVolumeOptions(GlusterVolumeEntity volume) {
    List<String> errors = new ArrayList<String>();
    for (GlusterVolumeOptionEntity option : volume.getOptions()) {
      // make sure that volume id is set
      option.setVolumeId(volume.getId());
      VdcReturnValueBase setOptionReturnValue =
          runBllAction(
              VdcActionType.SetGlusterVolumeOption, new GlusterVolumeOptionParameters(option));
      if (!getSucceeded()) {
        errors.addAll(setOptionReturnValue.getCanDoActionMessages());
        errors.addAll(setOptionReturnValue.getExecuteFailedMessages());
      }
    }

    if (!errors.isEmpty()) {
      handleVdsErrors(AuditLogType.GLUSTER_VOLUME_OPTION_SET_FAILED, errors);
    }
  }
  @Override
  protected void executeCommand() {
    VDSReturnValue returnValue =
        runVdsCommand(
            VDSCommandType.ResetGlusterVolumeOptions,
            new ResetGlusterVolumeOptionsVDSParameters(
                upServer.getId(),
                getGlusterVolumeName(),
                getParameters().getVolumeOption(),
                getParameters().isForceAction()));
    setSucceeded(returnValue.getSucceeded());

    if (getSucceeded()) {

      if (getParameters().getVolumeOption() != null
          && !(getParameters().getVolumeOption().getKey().isEmpty())) {
        GlusterVolumeOptionEntity entity =
            getGlusterVolume().getOption(getParameters().getVolumeOption().getKey());
        isResetAllOptions = false;
        if (entity != null) {
          removeOptionInDb(entity);
          String optionValue = entity.getValue();
          getParameters().getVolumeOption().setValue(optionValue != null ? optionValue : "");
          addCustomValue(GlusterConstants.OPTION_KEY, getParameters().getVolumeOption().getKey());
          addCustomValue(
              GlusterConstants.OPTION_VALUE, getParameters().getVolumeOption().getValue());
        }
      } else {
        for (GlusterVolumeOptionEntity option : getGlusterVolume().getOptions()) {
          removeOptionInDb(option);
        }
        isResetAllOptions = true;
      }
    } else {
      handleVdsError(
          AuditLogType.GLUSTER_VOLUME_OPTIONS_RESET_FAILED, returnValue.getVdsError().getMessage());
      return;
    }
  }
 /**
  * Remove the volume option in DB. If the option with given key already exists for the volume,
  * <br>
  * it will be deleted.
  *
  * @param option
  */
 private void removeOptionInDb(GlusterVolumeOptionEntity option) {
   getGlusterOptionDao().removeVolumeOption(option.getId());
 }