From 2990cfb3622fbf6bc72d658a637597504ff41020 Mon Sep 17 00:00:00 2001 From: Nabil Mansouri Date: Tue, 23 Sep 2025 09:23:31 +0200 Subject: [PATCH 1/2] chore: upgrade entcore --- backend/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/pom.xml b/backend/pom.xml index b9a73e00..39e9185a 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -15,7 +15,7 @@ 2.2-develop-pedago-SNAPSHOT - 6.8-SNAPSHOT + 6.8-develop-community-SNAPSHOT 3.1-SNAPSHOT 3.0-SNAPSHOT 2.1 From 5b86e48223702e331f5ac3284781123f917dc91f Mon Sep 17 00:00:00 2001 From: Nabil Mansouri Date: Tue, 23 Sep 2025 10:53:22 +0200 Subject: [PATCH 2/2] feat: #PEDAGO-3213, notify through broker on trash --- .../services/impl/ResourceServiceElastic.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/opendigitaleducation/explorer/services/impl/ResourceServiceElastic.java b/backend/src/main/java/com/opendigitaleducation/explorer/services/impl/ResourceServiceElastic.java index c34f4bd0..3e380094 100644 --- a/backend/src/main/java/com/opendigitaleducation/explorer/services/impl/ResourceServiceElastic.java +++ b/backend/src/main/java/com/opendigitaleducation/explorer/services/impl/ResourceServiceElastic.java @@ -17,6 +17,10 @@ import io.vertx.core.json.JsonObject; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; +import org.entcore.broker.api.dto.resources.ResourcesTrashedDTO; +import org.entcore.broker.api.publisher.BrokerPublisherFactory; +import org.entcore.broker.api.utils.AddressParameter; +import org.entcore.broker.proxy.ResourceBrokerPublisher; import org.entcore.common.elasticsearch.ElasticClient; import org.entcore.common.elasticsearch.ElasticClientManager; import org.entcore.common.explorer.ExplorerMessage; @@ -30,7 +34,6 @@ import org.entcore.common.postgres.IPostgresClient; import org.entcore.common.share.ShareRoles; import org.entcore.common.user.UserInfos; - import java.util.*; import java.util.stream.Collectors; @@ -202,12 +205,29 @@ public Future trash(final UserInfos user, final String application, f .collect(Collectors.toList())); return communication.pushMessage(messagesToIngest); }).compose(a -> { + // Notify broker when resources are trashed + notifyResourcesTrashed(application, ids); final ResourceSearchOperation search2 = new ResourceSearchOperation().setWaitFor(true).setIds(ids.stream().map(Object::toString).collect(Collectors.toSet())); return fetch(user, application, search2); }); }); } - + /** + * Sends a broker notification for trashed resources. + * @param application the application name + * @param ids resource identifiers + */ + private void notifyResourcesTrashed(String application, Set ids) { + if (ids == null || ids.isEmpty()) return; + final ResourceBrokerPublisher publisher = BrokerPublisherFactory.create( + ResourceBrokerPublisher.class, + communication.vertx(), + new AddressParameter("application", application) + ); + final List resourceIds = ids.stream().map(String::valueOf).collect(Collectors.toList()); + final ResourcesTrashedDTO notification = new ResourcesTrashedDTO(resourceIds, application, application); + publisher.notifyResourcesTrashed(notification); + } // TODO JBER move to a more central location /** * @param resource