package org.gcube.portal.event.publisher.lr62.model; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.model.Group; import com.liferay.portal.model.Role; import com.liferay.portal.model.User; import com.liferay.portal.model.UserGroupRole; public class UserGroupRoleEvent extends PortalModelListenerEvent { private static final long serialVersionUID = 3939268094440017646L; public static final String CREATED_NAME = "user-group-role_created"; public static final String DELETED_NAME = "user-group-role_deleted"; private UserGroupRoleEvent(String name, UserGroupRole userGroupRole, User user, Group group, Role role) throws PortalException, SystemException { super(name, user.getScreenName(), userGroupRole); setGroup(group); setRole(role); } public static UserGroupRoleEvent newCreatedEvent(UserGroupRole userGroupRole, User user, Group group, Role role) { try { return new UserGroupRoleEvent(CREATED_NAME, userGroupRole, user, group, role); } catch (PortalException | SystemException e) { log.error("Cannot create event from model object", e); return null; } } public static UserGroupRoleEvent newDeletedEvent(UserGroupRole userGroupRole, User user, Group group, Role role) { try { return new UserGroupRoleEvent(DELETED_NAME, userGroupRole, user, group, role); } catch (PortalException | SystemException e) { log.error("Cannot create event from model object", e); return null; } } }