Map<String, OwnIdentity> currentOwnIdentities = new HashMap<String, OwnIdentity>();
Set<OwnIdentity> ownIdentities = null;
+ boolean identitiesLoaded = false;
try {
/* get all identities with the wanted context from WoT. */
ownIdentities = webOfTrustConnector.loadAllOwnIdentities();
identities.put(identity.getId(), identity);
}
}
+ identitiesLoaded = true;
} catch (WebOfTrustException wote1) {
logger.log(Level.WARNING, "WoT has disappeared!", wote1);
- ownIdentities = null;
}
- if (ownIdentities != null) {
+ if (identitiesLoaded) {
/* check for changes. */
checkOwnIdentities(currentOwnIdentities);
/* find removed own identities: */
for (OwnIdentity oldOwnIdentity : currentOwnIdentities.values()) {
- if (!newOwnIdentities.containsKey(oldOwnIdentity.getId())) {
- identityListenerManager.fireOwnIdentityRemoved(oldOwnIdentity);
+ OwnIdentity newOwnIdentity = newOwnIdentities.get(oldOwnIdentity.getId());
+ if ((newOwnIdentity == null) || ((context != null) && oldOwnIdentity.hasContext(context) && !newOwnIdentity.hasContext(context))) {
+ identityListenerManager.fireOwnIdentityRemoved(new DefaultOwnIdentity(webOfTrustConnector, oldOwnIdentity));
}
}
/* find added own identities. */
for (OwnIdentity currentOwnIdentity : newOwnIdentities.values()) {
- if (!currentOwnIdentities.containsKey(currentOwnIdentity.getId())) {
- identityListenerManager.fireOwnIdentityAdded(currentOwnIdentity);
+ OwnIdentity oldOwnIdentity = currentOwnIdentities.get(currentOwnIdentity.getId());
+ if (((oldOwnIdentity == null) && ((context == null) || currentOwnIdentity.hasContext(context))) || ((oldOwnIdentity != null) && (context != null) && (!oldOwnIdentity.hasContext(context) && currentOwnIdentity.hasContext(context)))) {
+ identityListenerManager.fireOwnIdentityAdded(new DefaultOwnIdentity(webOfTrustConnector, currentOwnIdentity));
}
}