Beispiel #1
0
  public void act(Connection c) throws Exception {

    NexusDao dao = new NexusDao(c);

    int newEvents = 0, oldEvents = 0, count = 0, pages = 0;

    int newInFeed;
    do {
      newInFeed = 0;
      NexusFeed feed = client.fetchTimeline("recentlyDeployedArtifacts", 100, count);

      pages++;
      count += feed.events.size();

      List<String> guids = new ArrayList<>();

      for (HasNexusEvent event : feed.events) {
        guids.add(event.event.guid);
      }

      Set<String> oldGuids = dao.selectGuidsByGuids(guids);

      System.out.println("oldGuids.size() = " + oldGuids.size());

      for (HasNexusEvent event : feed.events) {

        //                if (oldGuids.contains(event.event.guid)) {
        //                    oldEvents++;
        //                    continue;
        //                }

        if (dao.countEventByGuid(event.event.guid) != 0) {
          oldEvents++;
          continue;
        }

        newEvents++;
        newInFeed++;

        onEvent(dao, event);
      }

      System.out.println("newInFeed = " + newInFeed);
    } while (newInFeed > 0);

    System.out.println(
        "Timeline updated. New="
            + newEvents
            + ", old="
            + oldEvents
            + ", count="
            + count
            + ", pages="
            + pages);
  }