Examples of IdentityUpdatedEvent


Examples of net.pterodactylus.sone.freenet.wot.event.IdentityUpdatedEvent

              Identity newIdentity = currentIdentities.get(ownIdentity).get(oldIdentity.getId());
              Set<String> oldContexts = oldIdentity.getContexts();
              Set<String> newContexts = newIdentity.getContexts();
              if (oldContexts.size() != newContexts.size()) {
                logger.finest(String.format("Contexts changed for %s: was: %s, is now: %s", ownIdentity.getId(), oldContexts, newContexts));
                eventBus.post(new IdentityUpdatedEvent(ownIdentity, newIdentity));
                continue;
              }
              for (String oldContext : oldContexts) {
                if (!newContexts.contains(oldContext)) {
                  logger.finest(String.format("Context was removed for %s: %s", ownIdentity.getId(), oldContext));
                  eventBus.post(new IdentityUpdatedEvent(ownIdentity, newIdentity));
                  break;
                }
              }
            }

            /* check for changes in the properties. */
            for (Identity oldIdentity : oldIdentities.get(ownIdentity).values()) {
              if (!currentIdentities.get(ownIdentity).containsKey(oldIdentity.getId())) {
                continue;
              }
              Identity newIdentity = currentIdentities.get(ownIdentity).get(oldIdentity.getId());
              Map<String, String> oldProperties = oldIdentity.getProperties();
              Map<String, String> newProperties = newIdentity.getProperties();
              if (oldProperties.size() != newProperties.size()) {
                logger.finest(String.format("Properties changed for %s: was: %s, is now: %s", ownIdentity.getId(), oldProperties, newProperties));
                eventBus.post(new IdentityUpdatedEvent(ownIdentity, newIdentity));
                continue;
              }
              for (Entry<String, String> oldProperty : oldProperties.entrySet()) {
                if (!newProperties.containsKey(oldProperty.getKey()) || !newProperties.get(oldProperty.getKey()).equals(oldProperty.getValue())) {
                  logger.finest(String.format("Property was removed for %s: %s", ownIdentity.getId(), oldProperty));
                  eventBus.post(new IdentityUpdatedEvent(ownIdentity, newIdentity));
                  break;
                }
              }
            }
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.