`UserGroupRoleEventPublisher` don't send events if the group is not enabled (#21925)
This commit is contained in:
parent
2dd141e1e9
commit
b4d568da6e
|
@ -2,6 +2,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for "event-publisher-portal"
|
||||
|
||||
## [v1.1.1-SNAPSHOT]
|
||||
`UserGroupRoleEventPublisher` don't send events if the group is not enabled (#21925)
|
||||
|
||||
## [v1.1.0]
|
||||
Added new event publisher for new created and removed `Role`s having "`site`" type (#20896)
|
||||
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -13,7 +13,7 @@
|
|||
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>event-publisher-hook</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<properties>
|
||||
|
@ -36,7 +36,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-portal-bom</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<version>3.6.3-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -73,13 +73,11 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>event-publisher-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>event-publisher-portal</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -22,7 +22,7 @@ public class UserGroupRoleEventPublisher extends AbstractEventPublisherBaseModel
|
|||
public void onAfterCreate(UserGroupRole userGroupRole) throws ModelListenerException {
|
||||
try {
|
||||
Group group = userGroupRole.getGroup();
|
||||
if (group.isSite()) {
|
||||
if (group.isSite() && group.isActive()) {
|
||||
log.info("Created a site user's group role");
|
||||
UserGroupRoleEvent event = UserGroupRoleEvent.newCreatedEvent(userGroupRole, userGroupRole.getUser(),
|
||||
group, userGroupRole.getRole());
|
||||
|
@ -31,8 +31,10 @@ public class UserGroupRoleEventPublisher extends AbstractEventPublisherBaseModel
|
|||
log.trace("Event is: " + event);
|
||||
}
|
||||
publish(event);
|
||||
} else if (log.isDebugEnabled()) {
|
||||
} 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");
|
||||
}
|
||||
} catch (PortalException | SystemException e) {
|
||||
log.error("Cannot get related model objects", e);
|
||||
|
@ -44,7 +46,7 @@ public class UserGroupRoleEventPublisher extends AbstractEventPublisherBaseModel
|
|||
public void onBeforeRemove(UserGroupRole userGroupRole) throws ModelListenerException {
|
||||
try {
|
||||
Group group = userGroupRole.getGroup();
|
||||
if (group.isSite()) {
|
||||
if (group.isSite() && group.isActive()) {
|
||||
log.info("Deleted a site user's group role");
|
||||
UserGroupRoleEvent event = UserGroupRoleEvent.newDeletedEvent(userGroupRole, userGroupRole.getUser(),
|
||||
group, userGroupRole.getRole());
|
||||
|
@ -53,8 +55,10 @@ public class UserGroupRoleEventPublisher extends AbstractEventPublisherBaseModel
|
|||
log.trace("Event is: " + event);
|
||||
}
|
||||
publish(event);
|
||||
} else if (log.isDebugEnabled()) {
|
||||
} 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");
|
||||
}
|
||||
} catch (PortalException | SystemException e) {
|
||||
log.error("Cannot get related model objects", e);
|
||||
|
|
Loading…
Reference in New Issue