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