[ 
https://jira.nuxeo.org/browse/NXP-4705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Enrique Perez updated NXP-4705:
-------------------------------

    Attachment: UserManagerImpl.java

I've added the following constants:

    public static final String USERCREATED_EVENT_ID = "user_created";
    public static final String USEREDITED_EVENT_ID = "user_edited";
    public static final String USERDELETED_EVENT_ID = "user_deleted";

And I've modified the notifyUserChanged method adding a new parameter (the type 
of modification):

    protected void notifyUserChanged(String userName, String eventId) throws 
ClientException {
        try {
            EventService eventService = 
Framework.getService(EventService.class);
            eventService.sendEvent(new Event(USERMANAGER_TOPIC,
                    eventId, this, userName));
            eventService.sendEvent(new Event(USERMANAGER_TOPIC,
                    USERCHANGED_EVENT_ID, this, userName));
        } catch (Exception e) {
            throw new ClientException(e);
        }
    }

I've also kept the old event because I don't know if this event is used in 
another class.

Finally, this method will be called in the create, update and edit methods:

    public DocumentModel createUser(DocumentModel userModel)
            throws ClientException {
        Session userDir = null;
        try {

...

            notifyUserChanged(userId, USERCREATED_EVENT_ID);
            return userModel;

        } finally {
            if (userDir != null) {
                userDir.close();
            }
        }
    }

    public void deleteUser(String userId) throws ClientException {
        Session userDir = null;
        try {

...

            notifyUserChanged(userId, USERDELETED_EVENT_ID);

        } finally {
            if (userDir != null) {
                userDir.close();
            }
        }
    }

    public void updateUser(DocumentModel userModel) throws ClientException {
        Session userDir = null;
        try {

...

            notifyUserChanged(userId, USEREDITED_EVENT_ID);
        } finally {
            if (userDir != null) {
                userDir.close();
            }
        }
    }


> Create, edit and delete users must throw different events
> ---------------------------------------------------------
>
>                 Key: NXP-4705
>                 URL: https://jira.nuxeo.org/browse/NXP-4705
>             Project: Nuxeo Enterprise Platform
>          Issue Type: Improvement
>            Reporter: Enrique Perez
>         Attachments: UserManagerImpl.java
>
>
> When an user is created, edited or deleted is thrown the "user_changed" 
> event. There should be a different event for each action.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://jira.nuxeo.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
ECM-tickets mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm-tickets

Reply via email to