Added new event publisher for new created `Role`s having "`site`" type (requested by #20896)
parent
3859f04d4e
commit
e7ce536e0e
@ -1,7 +1,9 @@
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
# Changelog for "event-publisher-portal"
|
||||
|
||||
## [v1.1.0-SNAPSHOT]
|
||||
Added new event publisher for new created `Role`s having "`site`" type (#20896)
|
||||
|
||||
## [v1.0.0]
|
||||
- First release (#19461)
|
||||
|
||||
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
@ -0,0 +1,37 @@
|
||||
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.Role;
|
||||
|
||||
public class RoleEvent extends PortalModelListenerEvent<Role> {
|
||||
|
||||
private static final long serialVersionUID = 3939268094440017646L;
|
||||
|
||||
public static final String CREATED_NAME = "role_created";
|
||||
// public static final String DELETED_NAME = "role_deleted";
|
||||
|
||||
private RoleEvent(String name, Role role) throws PortalException, SystemException {
|
||||
super(name, role);
|
||||
setRole(role);
|
||||
}
|
||||
|
||||
public static RoleEvent newCreatedEvent(Role role) {
|
||||
try {
|
||||
return new RoleEvent(CREATED_NAME, role);
|
||||
} catch (PortalException | SystemException e) {
|
||||
log.error("Cannot create event from Role model object", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// public static RoleEvent newDeletedEvent(Role role) {
|
||||
// try {
|
||||
// return new RoleEvent(DELETED_NAME, role);
|
||||
// } catch (PortalException | SystemException e) {
|
||||
// log.error("Cannot create event from Role model object", e);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package org.gcube.portal.event.publisher.lr62.model;
|
||||
|
||||
import com.liferay.portal.ModelListenerException;
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.model.Role;
|
||||
import com.liferay.portal.model.RoleConstants;
|
||||
|
||||
public class RoleEventPublisher extends AbstractEventPublisherBaseModelListener<Role> {
|
||||
|
||||
protected static final Log log = LogFactoryUtil.getLog(RoleEventPublisher.class);
|
||||
|
||||
public RoleEventPublisher() {
|
||||
super();
|
||||
log.info("New RoleEventPublisher instance created");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterCreate(Role role) throws ModelListenerException {
|
||||
if (role.getType() == RoleConstants.TYPE_SITE) {
|
||||
log.info("Created a new role having site type");
|
||||
RoleEvent event = RoleEvent.newCreatedEvent(role);
|
||||
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Event is: " + event);
|
||||
}
|
||||
publish(event);
|
||||
} else if (log.isDebugEnabled()) {
|
||||
log.debug("Created a non-site type role: " + role.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/* Uninteresting model events */
|
||||
|
||||
@Override
|
||||
public void onBeforeRemove(Role role) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterRemove(Role role) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAfterUpdate(Role role) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeCreate(Role role) throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
throws ModelListenerException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeforeUpdate(Role role) throws ModelListenerException {
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,12 @@
|
||||
value.object.listener.com.liferay.portal.model.User=org.gcube.portal.event.publisher.lr62.model.UserEventPublisher
|
||||
value.object.listener.com.liferay.portal.model.Group=org.gcube.portal.event.publisher.lr62.model.GroupEventPublisher
|
||||
#value.object.listener.com.liferay.portal.model.UserGroup=org.gcube.portal.event.publisher.lr62.model.UserGroupEventPublisher
|
||||
#value.object.listener.com.liferay.portal.model.UserGroupGroupRole=org.gcube.portal.event.publisher.lr62.model.UserGroupGroupRoleEventPublisher
|
||||
value.object.listener.com.liferay.portal.model.Role=org.gcube.portal.event.publisher.lr62.model.RoleEventPublisher
|
||||
value.object.listener.com.liferay.portal.model.User=org.gcube.portal.event.publisher.lr62.model.UserEventPublisher
|
||||
value.object.listener.com.liferay.portal.model.UserGroupRole=org.gcube.portal.event.publisher.lr62.model.UserGroupRoleEventPublisher
|
||||
login.events.post=org.gcube.portal.event.publisher.lr62.action.PostLoginAction
|
||||
logout.events.pre=org.gcube.portal.event.publisher.lr62.action.PreLogoutAction
|
||||
#servlet.session.destroy.events=
|
||||
#global.startup.events is not hook-able but they should be configured in main portal*.properties
|
||||
#global.shutdown.events is not hook-able but they should be configured in main portal*.properties
|
||||
#global.startup.events are not hook-able but they should be configured in main portal*.properties
|
||||
#global.shutdown.events are not hook-able but they should be configured in main portal*.properties
|
||||
application.startup.events=org.gcube.portal.event.publisher.lr62.action.StartupAction
|
||||
application.shutdown.events=org.gcube.portal.event.publisher.lr62.action.ShutdownAction
|
||||
# shutdown event is never called. See issue at https://issues.liferay.com/browse/LPS-11613
|
Loading…
Reference in New Issue