Hi all,
  I have a scenario, where a USER has a 1-M
relationship with ROLES. I am able to create a USER
and the associated roles using CMP.

  When it comes time to update the ROLES associated
with the user, the rules are as follows: The roles are
contained within a list. Therefore, any roles that the
user does not have yet, will be created for that USER.
Whatever roles the user has and is not in the role
list, has to be removed from the DB.

 The last part, removing the associated roles, is
puzzling me in CMR for the moment. While iterating
through the collection of roles in the USER ejb, I
cannot remove the roles from the table.

 I tried the following code:

Collection userRoleList = this.getRoleList();
Iterator iterator = userRoleList.iterator();

List rolesToRemove = new ArrayList();

// First, determine which roles to remove
while (iterator.hasNext()) {
PortalRoleUserLocal userRole = (PortalRoleUserLocal)
iterator.next();
if (!roleFound(roleList, userRole.getRoleId())) {
// Role no longer needed, remove from database
rolesToRemove.add(userRole);
}
}

// Now remove the roles
iterator = rolesToRemove.iterator();
while (iterator.hasNext()) {
PortalRoleUserLocal userRole = (PortalRoleUserLocal)
iterator.next();
userRoleList.remove(userRole);
}

I also tried to remove the roles (after consructing
the list), using userRoleList.removeAll(rolesToRemove)
and it did not work.

Any help would be appreciated.

Thanks,
Richard

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to