示例#1
0
  /**
   * Execute a command. Do not forget to initialize the CVS Root on globalOptions first! Example:
   * <code>
   *   GlobalOptions options = new GlobalOptions();
   *   options.setCVSRoot(":pserver:"+userName+"@"+hostName+":"+cvsRoot);
   * </code>
   *
   * @param command the command to execute
   * @param options the global options to use for executing the command
   * @throws CommandException if an error occurs when executing the command
   * @throws CommandAbortedException if the command is aborted
   */
  public boolean executeCommand(Command command, GlobalOptions globalOptions)
      throws CommandException, CommandAbortedException, AuthenticationException {
    BugLog.getInstance().assertNotNull(command);
    BugLog.getInstance().assertNotNull(globalOptions);

    this.globalOptions = globalOptions;

    getUncompressedFileHandler().setGlobalOptions(globalOptions);
    getGzipFileHandler().setGlobalOptions(globalOptions);

    try {
      eventManager.addCVSListener(command);
      command.execute(this, eventManager);
    } finally {
      eventManager.removeCVSListener(command);
    }
    return !command.hasFailed();
  }