Added also support to publish event on site's Role removal
This commit is contained in:
parent
e7ce536e0e
commit
80e43886ec
|
@ -9,7 +9,7 @@ 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";
|
||||
public static final String DELETED_NAME = "role_deleted";
|
||||
|
||||
private RoleEvent(String name, Role role) throws PortalException, SystemException {
|
||||
super(name, role);
|
||||
|
@ -25,13 +25,13 @@ public class RoleEvent extends PortalModelListenerEvent<Role> {
|
|||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
// }
|
||||
// }
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -30,11 +30,22 @@ public class RoleEventPublisher extends AbstractEventPublisherBaseModelListener<
|
|||
}
|
||||
}
|
||||
|
||||
/* Uninteresting model events */
|
||||
|
||||
@Override
|
||||
public void onBeforeRemove(Role role) throws ModelListenerException {
|
||||
if (role.getType() == RoleConstants.TYPE_SITE) {
|
||||
log.info("Removed a role having site type");
|
||||
RoleEvent event = RoleEvent.newDeletedEvent(role);
|
||||
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Event is: " + event);
|
||||
}
|
||||
publish(event);
|
||||
} else if (log.isDebugEnabled()) {
|
||||
log.debug("Removed a non-site type role: " + role.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/* Uninteresting model events */
|
||||
|
||||
@Override
|
||||
public void onAfterAddAssociation(Object classPK, String associationClassName, Object associationClassPK)
|
||||
|
|
Loading…
Reference in New Issue