Пример #1
0
  /**
   * Don't work with SearchResultP2P
   *
   * @param file
   * @return
   * @throws RemoteException
   */
  @Override
  public SimpleEntry<RemoteFile, Integer> downloadFile(SearchResult result) throws RemoteException {
    /*if (!PluginController.getInstance().isLocalPlugin(result.getPluginName()))
    {
        return null;
    }*/
    try {
      String path = result.getURI().toString().replace('\\', '/');

      File file = new File(path);
      InetAddress client = InetAddress.getByName(RemoteServer.getClientHost());

      FileSender sender = new FileSender(file, client);

      SimpleEntry<RemoteFile, Integer> entry =
          new SimpleEntry<RemoteFile, Integer>(new RemoteFile(file), sender.getListenerPort());

      // DebugManager.getInstance().debug("Transfering file: " + entry.getKey().getName() + ",
      // listening port: " + entry.getValue());

      Thread tSender = sender;
      tSender.start();

      return entry;

    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
Пример #2
0
  @Override
  public ArrayList<SearchResult> SearchIndexedMetaData(SearchResult searchResult)
      throws RemoteException {

    TagsStruct tags = TagsStruct.getInstance();

    ArrayList<String> extraFields = new ArrayList<>();

    for (TagValue tag : tags.getAllFields()) extraFields.add(tag.getAlias());

    String query =
        "FileName:" + searchResult.getURI() + " AND FileHash:" + searchResult.get("filehash");

    SearchDumper sdumper = new SearchDumper();
    sdumper.search(searchResult, query, extraFields);
    List<SearchResult> result = sdumper.getResults();
    // System.out.println("Result + " +result);
    if (result.size() > 0) {

      SearchResult r = (SearchResult) result.get(0);
      for (String s : r.getExtraData().keySet()) {
        if (s.contains("Sequence")) {
          String[] fields = r.getExtraData().get(s).toString().split(" ");
          for (int i = 0; i < fields.length; i++) {
            extraFields.add(fields[i]);
          }
        }
      }

      sdumper = new SearchDumper();
      sdumper.search(searchResult, query, extraFields);
      result = sdumper.getResults();
    }

    return (ArrayList<SearchResult>) result;
  }