Skip to content

Commit 54b7880

Browse files
committed
Feature #14738
Take into account the change in the signature of the callbacks in CDIResourceEventListener. In the ResourcesManager component, remove the custom listeners for change in the 'responsable' role users list and use instead the new notification mechanism about modifications in user lists of the roles in the different component instances.
1 parent 9b16954 commit 54b7880

File tree

9 files changed

+66
-245
lines changed

9 files changed

+66
-245
lines changed

kmelia/kmelia-library/src/main/java/org/silverpeas/components/kmelia/service/KmeliaUserEventListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class KmeliaUserEventListener extends CDIResourceEventListener<UserEvent>
4141
private KmeliaService kmeliaService;
4242

4343
@Override
44-
public void onDeletion(final UserEvent event) throws Exception {
44+
public void onDeletion(final UserEvent event) {
4545
UserDetail user = event.getTransition().getBefore();
4646
kmeliaService.userHaveBeenDeleted(user.getId());
4747
}

kmelia/kmelia-library/src/main/java/org/silverpeas/components/kmelia/service/KmeliaWysiwygEventListener.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,16 @@ public class KmeliaWysiwygEventListener extends CDIResourceEventListener<Wysiwyg
4141
private KmeliaService kmeliaService;
4242

4343
@Override
44-
public void onUpdate(final WysiwygEvent event) throws Exception {
44+
public void onUpdate(final WysiwygEvent event) {
4545
WysiwygContent content = event.getTransition().getAfter();
4646
if (content != null) {
4747
anExternalPublicationElementHaveChanged(content);
4848
}
4949
}
5050

5151
@Override
52-
public void onCreation(final WysiwygEvent event) throws Exception {
53-
WysiwygContent content = event.getTransition().getAfter();
54-
if (content != null) {
55-
anExternalPublicationElementHaveChanged(content);
56-
}
52+
public void onCreation(final WysiwygEvent event) {
53+
onUpdate(event);
5754
}
5855

5956
private void anExternalPublicationElementHaveChanged(WysiwygContent content) {

kmelia/kmelia-war/src/main/java/org/silverpeas/components/kmelia/notification/VersionSupportUpdater.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class VersionSupportUpdater extends CDIResourceEventListener<ComponentIns
4747
private Administration administration;
4848

4949
@Override
50-
public void onUpdate(final ComponentInstanceEvent event) throws Exception {
50+
public void onUpdate(final ComponentInstanceEvent event) {
5151
StateTransition<ComponentInst> transition = event.getTransition();
5252
String instanceType = event.getTransition().getBefore().getName();
5353
if ("kmelia".equalsIgnoreCase(instanceType)) {

resourcesManager/resourcesManager-library/src/integration-test/java/org/silverpeas/components/resourcesmanager/ResourcesManagerInstancePreDestructionIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void preDestroyAResourcesManagerInstance() throws Exception {
9292
try (PreparedStatement stmt = connection.prepareStatement(sql)) {
9393
ResultSet rs = stmt.executeQuery();
9494
assertThat(rs.next(), is(true));
95-
assertThat(rs.getLong(1), is(0l));
95+
assertThat(rs.getLong(1), is(0L));
9696
}
9797
}
9898
}

resourcesManager/resourcesManager-library/src/main/java/org/silverpeas/components/resourcesmanager/GroupUserLinkEventListener.java

Lines changed: 0 additions & 114 deletions
This file was deleted.

resourcesManager/resourcesManager-library/src/main/java/org/silverpeas/components/resourcesmanager/ProfileInstEventListener.java

Lines changed: 0 additions & 118 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (C) 2000 - 2025 Silverpeas
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as
6+
* published by the Free Software Foundation, either version 3 of the
7+
* License, or (at your option) any later version.
8+
*
9+
* As a special exception to the terms and conditions of version 3.0 of
10+
* the GPL, you may redistribute this Program in connection with Free/Libre
11+
* Open Source Software ("FLOSS") applications as described in Silverpeas's
12+
* FLOSS exception. You should have received a copy of the text describing
13+
* the FLOSS exception, and it is also available here:
14+
* "https://www.silverpeas.org/legal/floss_exception.html"
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Affero General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
23+
*/
24+
25+
package org.silverpeas.components.resourcesmanager;
26+
27+
import org.silverpeas.core.admin.user.notification.role.UserRoleEvent;
28+
import org.silverpeas.core.annotation.Service;
29+
import org.silverpeas.core.notification.system.CDIResourceEventListener;
30+
31+
import javax.inject.Inject;
32+
import java.util.Set;
33+
34+
/**
35+
* Listeners of events about changes in the users list of the role named 'responsable'. For any
36+
* users who don't play anymore this role, they are removed from the managers in charge of the
37+
* validation for all the bookable resources handled by the Resources Manager applications.
38+
*
39+
* @author mmoquillon
40+
*/
41+
@Service
42+
public class UserRoleEventListener extends CDIResourceEventListener<UserRoleEvent> {
43+
44+
private static final String MANAGER_ROLE = "responsable";
45+
46+
@Inject
47+
private ResourcesManagersSynchronizer synchronizer;
48+
49+
@Override
50+
public void onDeletion(UserRoleEvent event) {
51+
if (event.getRole().equals(MANAGER_ROLE)) {
52+
Set<String> userIds = event.getUserIds();
53+
event.getInstanceIds().forEach(a -> synchronizer.synchronize(a, userIds));
54+
}
55+
}
56+
}
57+

webPages/webPages-library/src/main/java/org/silverpeas/components/webpages/WebPagesWysiwygEventListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public class WebPagesWysiwygEventListener extends CDIResourceEventListener<Wysiw
4545
private OrganizationController organisationController;
4646

4747
@Override
48-
public void onUpdate(final WysiwygEvent event) throws Exception {
48+
public void onUpdate(final WysiwygEvent event) {
4949
notifyUsersAboutChange(event.getTransition().getAfter());
5050
}
5151

5252
@Override
53-
public void onCreation(final WysiwygEvent event) throws Exception {
53+
public void onCreation(final WysiwygEvent event) {
5454
notifyUsersAboutChange(event.getTransition().getAfter());
5555
}
5656

yellowpages/yellowpages-library/src/main/java/org/silverpeas/components/yellowpages/GroupEventListener.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ public class GroupEventListener extends CDIResourceEventListener<GroupEvent> {
4646
* In that case, as a group can be referred by a yellowpages instance (as a group
4747
* of inner contacts), take caution to remove also this group from the yellowpages instance.
4848
* @param event the event on the deletion of a group.
49-
* @throws Exception if an error occurs while treating the event.
5049
*/
5150
@Override
52-
public void onDeletion(final GroupEvent event) throws Exception {
51+
public void onDeletion(final GroupEvent event) {
5352
yellowpagesService.removeGroup(event.getTransition().getBefore().getId());
5453
}
5554
}

0 commit comments

Comments
 (0)