Also `UserEventPublisher` don't send events if the group is not enabled (#21925) and revised some log messages level to debug

This commit is contained in:
Mauro Mugnaini 2021-09-29 12:13:49 +02:00
parent 57a8dab7b1
commit 9074833b89
2 changed files with 18 additions and 14 deletions

View File

@ -44,11 +44,11 @@ public class UserEventPublisher extends AbstractEventPublisherBaseModelListener<
throws ModelListenerException {
if (Group.class.getName().equals(associationClassName)) {
log.info("User has been associated to a group");
log.debug("User has been associated to a group");
User user = getUser((Long) classPK);
Group group = getGroup((Long) associationClassPK);
if (user != null && group != null) {
if (group.isSite()) {
if (group.isSite() && group.isActive()) {
if (log.isDebugEnabled()) {
log.debug("Target group is a site: " + group.getName());
}
@ -57,8 +57,10 @@ public class UserEventPublisher extends AbstractEventPublisherBaseModelListener<
log.trace("User event is: " + userEvent);
}
publish(userEvent);
} else if (log.isDebugEnabled()) {
log.debug("Target group is not a site");
} else if (log.isDebugEnabled() && !group.isSite()) {
log.debug("Target Group is a non-site group");
} else if (log.isDebugEnabled() && group.isSite() && !group.isActive()) {
log.debug("Target group is disabled");
}
}
} else {
@ -73,11 +75,11 @@ public class UserEventPublisher extends AbstractEventPublisherBaseModelListener<
throws ModelListenerException {
if (Group.class.getName().equals(associationClassName)) {
log.info("User has been associated to a group");
log.debug("User has been associated to a group");
User user = getUser((Long) classPK);
Group group = getGroup((Long) associationClassPK);
if (user != null && group != null) {
if (group.isSite()) {
if (group.isSite() && group.isActive()) {
if (log.isDebugEnabled()) {
log.debug("Target group is a site: " + group.getName());
}
@ -86,8 +88,10 @@ public class UserEventPublisher extends AbstractEventPublisherBaseModelListener<
log.trace("User event is: " + userEvent);
}
publish(userEvent);
} else if (log.isDebugEnabled()) {
log.debug("Target group is not a site");
} else if (log.isDebugEnabled() && !group.isSite()) {
log.debug("Target group is a non-site group");
} else if (log.isDebugEnabled() && group.isSite() && !group.isActive()) {
log.debug("Target group is disabled");
}
}
} else {

View File

@ -23,7 +23,7 @@ public class UserGroupRoleEventPublisher extends AbstractEventPublisherBaseModel
try {
Group group = userGroupRole.getGroup();
if (group.isSite() && group.isActive()) {
log.info("Created a site user's group role");
log.debug("Created a site user's group role");
UserGroupRoleEvent event = UserGroupRoleEvent.newCreatedEvent(userGroupRole, userGroupRole.getUser(),
group, userGroupRole.getRole());
@ -33,8 +33,8 @@ public class UserGroupRoleEventPublisher extends AbstractEventPublisherBaseModel
publish(event);
} else if (log.isDebugEnabled() && !group.isSite()) {
log.debug("Created a non-site user's group role");
} else if (log.isWarnEnabled() && group.isSite() && !group.isActive()) {
log.warn("Created a user's group role for a disabled group");
} else if (log.isDebugEnabled() && group.isSite() && !group.isActive()) {
log.debug("Created a user's group role for a disabled group");
}
} catch (PortalException | SystemException e) {
log.error("Cannot get related model objects", e);
@ -47,7 +47,7 @@ public class UserGroupRoleEventPublisher extends AbstractEventPublisherBaseModel
try {
Group group = userGroupRole.getGroup();
if (group.isSite() && group.isActive()) {
log.info("Deleted a site user's group role");
log.debug("Deleted a site user's group role");
UserGroupRoleEvent event = UserGroupRoleEvent.newDeletedEvent(userGroupRole, userGroupRole.getUser(),
group, userGroupRole.getRole());
@ -57,8 +57,8 @@ public class UserGroupRoleEventPublisher extends AbstractEventPublisherBaseModel
publish(event);
} else if (log.isDebugEnabled() && !group.isSite()) {
log.debug("Deleted a non-site user's group role");
} else if (log.isWarnEnabled() && group.isSite() && !group.isActive()) {
log.warn("Deleted a user's group role for a disabled group");
} else if (log.isDebugEnabled() && group.isSite() && !group.isActive()) {
log.debug("Deleted a user's group role for a disabled group");
}
} catch (PortalException | SystemException e) {
log.error("Cannot get related model objects", e);