示例#1
0
 public static void checkAuthor(Author author) {
   AuthorUpdateEvent event = null;
   switch (author.getTypeSite()) {
     case LITERA:
       event = litera.checkUpdateAuthor(author);
       break;
     case SAMLIB:
       for (Date d : SamLibUpdater.getDaysFrom(author.getLastCheck(), new Date())) {
         event = getSamlib(d).checkUpdateAuthor(author);
         if (event != null) break;
       }
       if (event == null) event = getSamlib(new Date()).checkUpdateAuthor(author);
   }
   author.setLastCheck(new Date());
   if (event != null) {
     author.setLastUpdate(event.getUpdateTime());
     Logger.getLogger()
         .print(
             "Обнаруженно обновление автора " + author.getName() + " от " + event.getUpdateTime());
     subscribe.sendUpdateEvent(event);
   }
 }
示例#2
0
  public static void checkBook(IBook book) {
    BookUpdateEvent event = null;
    // Logger.getLogger().print("Проверка на обновление книги " + book.getNameBook());

    switch (book.getType()) {
      case LITERA:
        event = litera.checkUpdateBook(book);
        break;
      case SAMLIB:
        for (Date d : SamLibUpdater.getDaysFrom(book.getLastCheck(), new Date())) {
          event = getSamlib(d).checkUpdateBook(book);
          if (event != null) break;
        }
        if (event == null) event = getSamlib(new Date()).checkUpdateBook(book);
    }
    book.setLastCheck(new Date());
    if (event != null) {
      book.setLastUpdate(event.updateTime);
      Logger.getLogger()
          .print("Обнаруженно обновление книги " + book.getNameBook() + " от " + event.updateTime);
      subscribe.sendUpdateEvent(event);
    }
  }