[gatein-issues] [JBoss JIRA] (GTNPORTAL-3285) Logic of deleting user is not proper

Vu Viet Phuong (JIRA) issues at jboss.org
Fri May 9 06:29:57 EDT 2014


     [ https://issues.jboss.org/browse/GTNPORTAL-3285?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vu Viet Phuong updated GTNPORTAL-3285:
--------------------------------------

           Status: Resolved  (was: Pull Request Sent)
    Fix Version/s: 3.7.2.Final
       Resolution: Done


> Logic of deleting user is not proper
> ------------------------------------
>
>                 Key: GTNPORTAL-3285
>                 URL: https://issues.jboss.org/browse/GTNPORTAL-3285
>             Project: GateIn Portal
>          Issue Type: Feature Request
>      Security Level: Public(Everyone can see) 
>            Reporter: Tuyen Nguyen The
>            Assignee: Tuyen Nguyen The
>             Fix For: 3.7.2.Final
>
>
> I try to add a listener to not allow delete Platform users. for example:
> {code}
> public class IntranetUserEventListenerImpl extends UserEventListener {
>   @Override
>   public void preDelete(User user) throws Exception {
>    //don't allow delete user
>       throw new MessageException(new ApplicationMessage("IntranetUserEventListener.msg.delete-user-read-only-mode-error", null, ApplicationMessage.WARNING));
> }
> {code}
> This listener can help to not allow delete user, but all memberships of user still are deleted.
> Check logic of deleting users (in file https://github.com/exoplatform/gatein-portal/blob/3.5.x-PLF/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java): we can see it deletes all membershis of an user before broadcast event "preDelete"
> {code}
> public User removeUser(String userName, boolean broadcast) throws Exception {
> //...
>   
>        try {
>             // Remove all memberships and profile first
>             orgService.getMembershipHandler().removeMembershipByUser(userName, false);
>             orgService.getUserProfileHandler().removeUserProfile(userName, false);
>         } catch (Exception e) {
>             handleException("Cannot cleanup user relationships: " + userName + "; ", e);
>         }
>         User exoUser = getPopulatedUser(userName, session);
>         if (broadcast) {
>             preDelete(exoUser);
>         }
>         try {
>             session.getPersistenceManager().removeUser(foundUser, true);
>         } catch (IdentityException e) {
>             handleException("Cannot remove user: " + userName + "; ", e);
>         }
> //...
> }
> {code}
> Expectation:  
> 1) broadcast preDelete(exoUser) should be run before delete anything
> 2) Delete user and its membership should be run in one transaction



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)


More information about the gatein-issues mailing list