Tools.logMethodIn(log, LogLevel.TRACE, "removeMembership", new Object[] { "id", id, "broadcast", broadcast });
}
orgService.flush();
Membership m = new MembershipImpl(id);
String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
String groupId = getIdentitySession().getPersistenceManager().createGroupKey(plGroupName,
getGroupTypeFromId(m.getGroupId()));
boolean hasRole = false;
try {
hasRole = getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType());
} catch (Exception e) {
// TODO:
handleException("Identity operation error: ", e);
}
boolean associated = false;
try {
associated = getIdentitySession().getRelationshipManager().isAssociatedByKeys(groupId, m.getUserName());
} catch (Exception e) {
// TODO:
handleException("Identity operation error: ", e);
}
if (!hasRole && !(isAssociationMapped() && getAssociationMapping().equals(m.getMembershipType()) && associated)) {
return m;
}
if (broadcast) {
preDelete(m);
}
if (isCreateMembership(m.getMembershipType(), m.getGroupId())) {
try {
getIdentitySession().getRoleManager().removeRole(m.getMembershipType(), m.getUserName(), groupId);
} catch (Exception e) {
// TODO:
handleException("Identity operation error: ", e);
}
}
if (isAssociationMapped() && getAssociationMapping().equals(m.getMembershipType()) && associated) {
Set<String> keys = new HashSet<String>();
keys.add(m.getUserName());
try {
getIdentitySession().getRelationshipManager().disassociateUsersByKeys(groupId, keys);
} catch (Exception e) {
// TODO:
handleException("Identity operation error: ", e);