コード例 #1
0
ファイル: DropDaemon.java プロジェクト: jmt85/qabel-desktop
  void receiveMessages() throws PersistenceException, EntityNotFoundExcepion {
    Identity identity = config.getSelectedIdentity();
    if (identity == null) {
      return;
    }
    java.util.List<DropMessage> dropMessages;
    try {
      dropMessages = httpDropConnector.receive(identity, lastDate);
    } catch (NullPointerException e) {
      return;
    }
    Contact sender = null;

    for (DropMessage d : dropMessages) {

      lastDate = config.getLastDropPoll(identity);
      if (lastDate.getTime() < d.getCreationDate().getTime()) {
        try {
          sender = contactRepository.findByKeyId(identity, d.getSenderKeyId());
        } catch (EntityNotFoundExcepion e) {
          logger.error(
              "Contact: with ID: " + d.getSenderKeyId() + " not found " + e.getMessage(), e);
          continue;
        }
        dropMessageRepository.addMessage(d, sender, identity, false);
        config.setLastDropPoll(identity, d.getCreationDate());
      }
    }
  }
コード例 #2
0
ファイル: DropDaemon.java プロジェクト: jmt85/qabel-desktop
 @Override
 public void run() {
   while (!Thread.interrupted()) {
     try {
       try {
         receiveMessages();
       } catch (PersistenceException e) {
         logger.error("Persitence fail: " + e.getMessage(), e);
         continue;
       } catch (EntityNotFoundExcepion entityNotFoundExcepion) {
         entityNotFoundExcepion.printStackTrace();
       }
       Thread.sleep(sleepTime);
     } catch (InterruptedException e) {
       logger.error("Thread stopped " + e.getMessage(), e);
       break;
     }
   }
 }