- sleep(1000);
-
- /* don’t insert locked Sones. */
- Sone sone = this.sone;
- if (core.isLocked(sone)) {
- /* trigger redetection when the Sone is unlocked. */
- synchronized (sone) {
- modified = !sone.getFingerprint().equals(lastInsertedFingerprint);
- }
- lastFingerprint = "";
- lastModificationTime = absent();
- continue;
- }
-
- boolean insertSoneNow = false;
- synchronized (sone) {
- String fingerprint = sone.getFingerprint();
- if (!fingerprint.equals(lastFingerprint)) {
- if (fingerprint.equals(lastInsertedFingerprint)) {
- modified = false;
- lastModificationTime = absent();
- logger.log(Level.FINE, String.format("Sone %s has been reverted to last insert state.", sone));
- } else {
- lastModificationTime = of(currentTimeMillis());
- modified = true;
- logger.log(Level.FINE, String.format("Sone %s has been modified, waiting %d seconds before inserting.", sone.getName(), insertionDelay));
- }
- lastFingerprint = fingerprint;
- }
- if (modified && lastModificationTime.isPresent() && ((currentTimeMillis() - lastModificationTime.get()) > (insertionDelay * 1000))) {
- lastInsertedFingerprint = fingerprint;
- insertSoneNow = true;
- }
- }