*/
public void removeUserPrincipalInGroup(String username, String groupFullPathName) throws SecurityException
{
boolean isMappingOnly = false;
// Check is the record is used for mapping only.
InternalUserPrincipal internalUser = commonQueries.getInternalUserPrincipal(username, false);
if (null == internalUser)
{
internalUser = commonQueries.getInternalUserPrincipal(username, true);
isMappingOnly = true;
}
if (null != internalUser)
{
Collection internalGroups = internalUser.getGroupPrincipals();
// This should not be null. Check for null should be made by the caller.
InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(GroupPrincipalImpl
.getFullPathFromPrincipalName(groupFullPathName));
// Check anyway.
if (null == internalGroup)
{
throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupFullPathName));
}
internalGroups.remove(internalGroup);
// Remove dead mapping records. I.e. No mapping is associated with the specific record.
if (isMappingOnly && internalGroups.isEmpty() && internalUser.getRolePrincipals().isEmpty()
&& internalUser.getPermissions().isEmpty())
{
commonQueries.removeInternalUserPrincipal(internalUser);
}
else
{
internalUser.setGroupPrincipals(internalGroups);
commonQueries.setInternalUserPrincipal(internalUser, isMappingOnly);
}
}
else
{