Esempio n. 1
0
 private String getSessionStat(FtpSessionContext ctx, String key) {
   String result;
   Map<String, Long> userStats = ctx.getSessionStatistics();
   if (userStats != null) {
     Object val = userStats.get(key);
     result = val == null ? "0" : formatNum(val);
   } else {
     result = "n/a";
   }
   return result;
 }
Esempio n. 2
0
  private void fillRow(StringBuffer sb, int rowCount, FtpSession session, FtpSessionContext ctx) {

    String band =
        rowCount % 2 == 0
            ? ConsoleConstants.TR_START_TAG_CLASS_A
            : ConsoleConstants.TR_START_TAG_CLASS_B;
    sb.append(band);

    fillField(sb, ctx.getClientSocket().getInetAddress().getHostName());
    fillField(sb, ctx.getUser());
    fillField(sb, session.isTerminated() ? "Terminated" : "Running");
    fillField(sb, formatDate(ctx.getCreationTime()));
    fillNumField(sb, getSessionStat(ctx, FtpConstants.STAT_BYTES_DOWNLOADED));
    fillNumField(sb, getSessionStat(ctx, FtpConstants.STAT_BYTES_UPLOADED));
    fillNumField(sb, getSessionStat(ctx, FtpConstants.STAT_FILES_DOWNLOADED));
    fillNumField(sb, getSessionStat(ctx, FtpConstants.STAT_FILES_UPLOADED));
    fillNumField(sb, getSessionStat(ctx, FtpConstants.STAT_DOWNLOAD_RATE));
    fillNumField(sb, getSessionStat(ctx, FtpConstants.STAT_UPLOAD_RATE));

    sb.append(ConsoleConstants.TR_END_TAG);
  }