/**
  * Executes this action.
  *
  * @param parent the parent window
  */
 public void execute(Window parent) {
   File f = new File(fileName);
   try {
     SignatureFileInfo info = signatureManager.upload(type, f, useAsDefault);
     String message =
         String.format("Signature file %s has been uploaded", info.getFile().getName());
     JOptionPane.showMessageDialog(
         parent, message, "Signature file uploaded", JOptionPane.INFORMATION_MESSAGE);
   } catch (SignatureFileException e) {
     JOptionPane.showMessageDialog(
         parent, e.getMessage(), "Error uploading signature file", JOptionPane.ERROR_MESSAGE);
   }
 }
  /** {@inheritDoc} */
  @Override
  protected Map<SignatureType, SignatureFileInfo> doInBackground()
      throws SignatureManagerException {
    Map<SignatureType, SignatureFileInfo> downloaded =
        new HashMap<SignatureType, SignatureFileInfo>();

    for (SignatureFileInfo update : updates) {
      if (!update.hasError()) {
        downloaded.put(update.getType(), signatureManager.downloadLatest(update.getType()));
      }
    }

    return downloaded;
  }
  /** @throws CommandExecutionException */
  private void updateDefaultVersion(String key) throws CommandExecutionException {
    final PropertiesConfiguration properties = globalConfig.getProperties();
    properties.setProperty(mapping.get(type).getName(), key);
    try {
      properties.save();
      SignatureFileInfo sigFileInfo = signatureManager.getDefaultSignatures().get(type);
      printWriter.println(
          I18N.getResource(
              I18N.CONFIGURE_SIGNATURE_FILE_VERSION_SUCCESS,
              sigFileInfo.getVersion(),
              sigFileInfo.getFile().getName()));

    } catch (ConfigurationException e) {
      throw new CommandExecutionException(e);
    } catch (SignatureFileException e) {
      throw new CommandExecutionException(e);
    }
  };
  /** {@inheritDoc} */
  @Override
  public void execute() throws CommandExecutionException {

    boolean validVersion = false;
    Map<SignatureType, SortedMap<String, SignatureFileInfo>> sigFileInfos =
        signatureManager.getAvailableSignatureFiles();

    Map<String, SignatureFileInfo> sigFileInfoForType = sigFileInfos.get(type);

    for (Map.Entry<String, SignatureFileInfo> entry : sigFileInfoForType.entrySet()) {
      String key = entry.getKey();
      SignatureFileInfo info = entry.getValue();
      if (info.getVersion() == signatureFileVersion) {
        validVersion = true;
        updateDefaultVersion(key);
        break;
      }
    }

    if (!validVersion) {
      throw new CommandExecutionException(
          I18N.getResource(I18N.CONFIGURE_SIGNATURE_FILE_VERSION_INVALID, signatureFileVersion));
    }
  }