public void run() { Logger.debug(this, "Main loop running..."); try { mConnectedToWoT = connectToWoT(); if (mConnectedToWoT) { try { fetchOwnIdentities(); // Fetch the own identities first to prevent own-identities from // being imported as normal identity... fetchIdentities(); garbageCollectIdentities(); } catch (Exception e) { Logger.error(this, "Fetching identities failed.", e); } } } finally { final long sleepTime = mConnectedToWoT ? (THREAD_PERIOD / 2 + mRandom.nextInt(THREAD_PERIOD)) : WOT_RECONNECT_DELAY; Logger.debug(this, "Sleeping for " + (sleepTime / (60 * 1000)) + " minutes."); mTicker.queueTimedJob( this, "Freetalk " + this.getClass().getSimpleName(), sleepTime, false, true); } Logger.debug(this, "Main loop finished."); }
public synchronized ObjectSet<WoTOwnIdentity> ownIdentityIterator() { try { fetchOwnIdentities(); garbageCollectIdentities(); } catch (Exception e) { } /* Ignore, return the ones which are in database now */ final Query q = db.query(); q.constrain(WoTOwnIdentity.class); return new Persistent.InitializingObjectSet<WoTOwnIdentity>(mFreetalk, q); }