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
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