user-registration-hook/src/main/java/org/gcube/portal/usersaccount/MyCreateUserAccountListener...

32 lines
1.4 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package org.gcube.portal.usersaccount;
import org.gcube.portal.notifications.thread.NewUserAccountNotificationThread;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.liferay.portal.ModelListenerException;
import com.liferay.portal.model.BaseModelListener;
import com.liferay.portal.model.User;
/**
*
* @author Massimiliano Assante, CNR-ISTI
*
* Model Listeners are used to listen for events on models and do something in response.
* Theyre similar in concept to custom action hooks, which perform actions in response to portal events (user login, for example).
* Model listeners implement the ModelListener interface.
*
* @see https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/creating-model-listeners
*/
public class MyCreateUserAccountListener extends BaseModelListener<User> {
private static final Logger _log = LoggerFactory.getLogger(MyCreateUserAccountListener.class);
final String SUBJECT = "New user account notification";
@Override
public void onAfterCreate(User user) throws ModelListenerException {
_log.info("onAfterCreate NewUserAccount listener for: " + user.getScreenName() + " / " + user.getFullName());
Thread emailManagersThread = new Thread(new NewUserAccountNotificationThread(user.getScreenName(), user.getFullName(), user.getEmailAddress()));
emailManagersThread.start();
}
}