List accessRightsUsers = getAccessRightsUsers(interceptionPointCategory, parameters, userName, db);
Iterator accessRightsUsersIterator = accessRightsUsers.iterator();
while(accessRightsUsersIterator.hasNext())
{
AccessRightUser accessRightUser = (AccessRightUser)accessRightsUsersIterator.next();
AccessRight ar = getAccessRightWithId(accessRightUser.getAccessRight().getAccessRightId(), db);
ar.getUsers().remove(accessRightUser);
accessRightsUsersIterator.remove();
db.remove(accessRightUser);
}
int interceptionPointIndex = 0;
String interceptionPointIdString = request.getParameter((index != null ? index + "_" : "") + interceptionPointIndex + "_InterceptionPointId");
logger.info("interceptionPointIdString:" + interceptionPointIdString);
while(interceptionPointIdString != null)
{
String hasAccess = request.getParameter((index != null ? index + "_" : "") + interceptionPointIdString + "_hasAccess");
logger.info("interceptionPointIdString:" + interceptionPointIdString);
AccessRight accessRight = null;
List<AccessRight> accessRights = getAccessRightListForEntity(new Integer(interceptionPointIdString), parameters, db);
if(hasAccess != null)
{
if(accessRights == null || accessRights.size() == 0)
{
AccessRightVO accessRightVO = new AccessRightVO();
accessRightVO.setParameters(parameters);
InterceptionPoint interceptionPoint = InterceptionPointController.getController().getInterceptionPointWithId(new Integer(interceptionPointIdString), db);
accessRight = create(accessRightVO, interceptionPoint, db);
}
else
{
accessRight = (AccessRight)accessRights.get(0);
}
if(userName != null && accessRight != null)
{
AccessRightUserVO accessRightUserVO = new AccessRightUserVO();
accessRightUserVO.setUserName(userName);
AccessRightUser accessRightUser = createAccessRightUser(db, accessRightUserVO, accessRight);
accessRight.getUsers().add(accessRightUser);
}
}
// If we do not have an access right reference here we try to get one so that we can do some cleaning