protected JetspeedPrincipal synchronizeEntity(final Entity entity, final Map<String,Set<String>> processing, final Map<String,Map<String,String>> processed) throws SecurityException
{
JetspeedPrincipal principal = null;
if (processing != null && processing.get(entity.getType()) != null && processing.get(entity.getType()).contains(entity.getId()))
{
throw new IllegalStateException("Circular relationship detected for Entity type "+entity.getType()+" id: "+entity.getId());
}
if (processed.get(entity.getType()) != null && processed.get(entity.getType()).containsKey(entity.getId()))
{
String principalName = processed.get(entity.getType()).get(entity.getId());
return principalName != null ? getJetspeedPrincipal(entity.getType(),principalName) : null;
}
feedbackLogger.debug("Synchronizing entity {} id: {}",entity.getType(),entity.getId());
Set<JetspeedPrincipalAssociationReference> toAssociations = synchronizeEntityFromRelations(entity, processing, processed);
principal = synchronizeEntity(entity, toAssociations);
Map<String,String> entitiesMap = processed.get(entity.getType());
if (entitiesMap == null)
{
entitiesMap = new HashMap<String,String>();
processed.put(entity.getType(), entitiesMap);
}
entitiesMap.put(entity.getId(), entity.getId());
return principal;
}