final String communityName =
communityName =
  public void newAlert(ThreatAlert ta) {    if (ta instanceof ReaffiliationNotification) {      ReaffiliationNotification rn = (ReaffiliationNotification) ta;      if (logger.isDebugEnabled()) {        logger.debug("Received new ReaffiliationNotification: " + ta);      }      // Leave current robustness community      Collection communities =          commSvc.searchCommunity(null,                                  "(CommunityType=Robustness)",                                  false,                                  Community.COMMUNITIES_ONLY,                                  null);      if (communities != null && !communities.isEmpty()) {        final String communityName =            ((Community) communities.iterator().next()).getName();        Community comm = commSvc.getCommunity(communityName, null);        if (comm != null && comm.hasEntity(agentId.toString())) {          final Attributes attrs =              comm.getEntity(agentId.toString()).getAttributes();          commSvc.leaveCommunity(communityName, agentId.toString(),                                 new CommunityResponseListener() {            public void getResponse(CommunityResponse resp) {              if (logger.isDebugEnabled()) {                logger.debug("Leaving community: community=" +                             communityName + " resp=" + resp);              }            }          });          if (logger.isDebugEnabled()) {            logger.debug("Requesting to leave community: " + communityName);          }          // Join new robustness community          final String newCommunity = (String) rn.getContent();          if (newCommunity != null && newCommunity.length() > 0) {            commSvc.joinCommunity(newCommunity,                                  agentId.toString(),                                  commSvc.AGENT,                                  attrs,                                  true,                                  null,                                  new CommunityResponseListener() {              public void getResponse(CommunityResponse resp) {                if (logger.isDebugEnabled()) {                  logger.debug("Joining community: community=" +                              newCommunity + " resp=" + resp);                }              }            });            if (logger.isDebugEnabled()) {              logger.debug("Requesting to join community: " + newCommunity);            }          }          // Send Notification to members          Attribute entityType = attrs.get("EntityType");          if (entityType != null && entityType.contains("Node")) {            Set members = findLocalAgentsInCommunity(communityName);            sendToMembers(rn, members);          }        }      }    }  }