public CommandResponse doLISTJOBS(CommandRequest request) {

    CommandResponse response = StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK");
    ReplacerEnvironment env = new ReplacerEnvironment();
    TreeSet<Job> treeSet = new TreeSet<Job>(new JobIndexComparator());
    treeSet.addAll(getJobManager().getAllJobsFromQueue());

    for (Job job : treeSet) {
      env.add("job", job);
      env.add("count", job.getIndex());
      synchronized (job) {
        if (job.isTransferring()) {
          env.add("speed", Bytes.formatBytes(job.getSpeed()));
          env.add("progress", Bytes.formatBytes(job.getProgress()));
          try {
            env.add("total", Bytes.formatBytes(job.getFile().getSize()));
          } catch (FileNotFoundException e) {
            env.add("total", "0");
          }
          env.add("srcslave", job.getSourceSlave().getName());
          env.add("destslave", job.getDestinationSlave().getName());
          response.addComment(
              request.getSession().jprintf(_bundle, env, _keyPrefix + "listjobrunning"));
        } else {
          response.addComment(
              request.getSession().jprintf(_bundle, env, _keyPrefix + "listjobwaiting"));
        }
      }
    }
    env = new ReplacerEnvironment();
    env.add("total", treeSet.size());
    response.addComment(request.getSession().jprintf(_bundle, env, _keyPrefix + "sizeofjobs"));
    return response;
  }
  public CommandResponse doREMOVEJOB(CommandRequest request) throws ImproperUsageException {

    if (!request.hasArgument()) {
      throw new ImproperUsageException();
    }
    class Range {
      long _low, _high;

      Range(long low, long high) {
        if (0 >= low || low > high) {
          throw new IllegalArgumentException("0 < low <= high");
        }
        _low = low;
        _high = high;
      }

      public boolean contains(long val) {
        return _low <= val && val <= _high;
      }
    }

    ArrayList<Range> rangeList = new ArrayList<Range>();
    String rangeString = request.getArgument();
    String[] ranges = rangeString.split(" ");
    for (String range : ranges) {
      if (range.indexOf("-") == -1) {
        long val = Long.parseLong(range);
        rangeList.add(new Range(val, val));
      } else {
        String[] vals = range.split("-");
        rangeList.add(new Range(Long.parseLong(vals[0]), Long.parseLong(vals[1])));
      }
    }
    TreeSet<Job> treeSet = new TreeSet<Job>(new JobIndexComparator());
    treeSet.addAll(getJobManager().getAllJobsFromQueue());
    ReplacerEnvironment env = new ReplacerEnvironment();

    CommandResponse response = StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK");
    for (Job job : treeSet) {
      for (Range range : rangeList) {
        if (range.contains(job.getIndex())) {
          env.add("job", job);
          getJobManager().stopJob(job);
          response.addComment(
              request.getSession().jprintf(_bundle, env, _keyPrefix + "removejob.success"));
        }
      }
    }
    return response;
  }