Exemplo n.º 1
0
  protected static void generateEvidence(IndentWriter writer) {
    writer.println(file_map.size() + " FMFile Reservations");

    try {
      writer.indent();

      try {
        file_map_mon.enter();

        Iterator it = file_map.keySet().iterator();

        while (it.hasNext()) {

          String key = (String) it.next();

          List owners = (List) file_map.get(key);

          Iterator it2 = owners.iterator();

          String str = "";

          while (it2.hasNext()) {

            Object[] entry = (Object[]) it2.next();

            FMFileOwner owner = (FMFileOwner) entry[0];
            Boolean write = (Boolean) entry[1];
            String reason = (String) entry[2];

            str +=
                (str.length() == 0 ? "" : ", ")
                    + owner.getName()
                    + "["
                    + (write.booleanValue() ? "write" : "read")
                    + "/"
                    + reason
                    + "]";
          }

          writer.println(Debug.secretFileName(key) + " -> " + str);
        }
      } finally {

        file_map_mon.exit();
      }

      FMFileManagerImpl.generateEvidence(writer);

    } finally {

      writer.exdent();
    }
  }
Exemplo n.º 2
0
  public static boolean isUpdateDM(DownloadManager dm) {
    Boolean oisUpdate = (Boolean) dm.getUserData("isUpdate");
    if (oisUpdate != null) {
      return oisUpdate.booleanValue();
    }

    boolean isUpdate = true;
    TOTorrent torrent = dm.getTorrent();
    if (torrent == null) {
      isUpdate = false;
    } else {
      URL announceURL = torrent.getAnnounceURL();

      if (announceURL != null) {
        if (announceURL.getHost().indexOf(AELITIS_HOST_CORE) == -1) {
          isUpdate = false;
        }
      }

      if (isUpdate) {
        TOTorrentAnnounceURLSet[] sets = torrent.getAnnounceURLGroup().getAnnounceURLSets();

        for (int i = 0; i < sets.length; i++) {

          URL[] urls = sets[i].getAnnounceURLs();

          for (int j = 0; j < urls.length; j++) {

            if (urls[j].getHost().indexOf(AELITIS_HOST_CORE) == -1) {
              isUpdate = false;
              break;
            }
          }
        }
      }
    }

    dm.setUserData("isUpdate", new Boolean(isUpdate));
    return isUpdate;
  }