for(Entity entity : GlobalModel.getEntities().values()) {
Map<Community,EntityIdentifier> usuario = entity.getIdentificatorInCommunities();
//In this form of iteration, we dont search accounts in the new accounts found or
// accounts updated that have already been iterated
for(Object object : usuario.keySet().toArray()) {
Community community = (Community) object;
Set<String> accounts = new HashSet<String>();
String userName = usuario.get(community).getName();
//System.out.println(userName+":"+community);
String url = usuario.get(community).getUrl();
try {
if(url != null) {
accounts.add(url);
Set<String> userAccounts = Scrapper.MoreUserAccountsByURL(url);
if(userAccounts != null) {
accounts.addAll(userAccounts);
}
} else {
List<String> userAccounts = Scrapper.UserAccounts(userName,
community.getDomainName(), true);
if(userAccounts != null) {
accounts.addAll(userAccounts);
}
}
} catch (Exception e) {
e.printStackTrace();
ModelException.throwException(ModelException.GET_MORE_ACCOUNTS,
"Error to get more accounts for entity:"+
entity.getUniqueIdentificator()+" with community: "+
community.getName()+" and user:"+userName+" from"+url);
}
if(accounts != null) {
SetAccountsInEntity(entity, userName, accounts);
}
}