Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<version>2.2-develop-pedago-SNAPSHOT</version>

<properties>
<entCoreVersion>6.8-SNAPSHOT</entCoreVersion>
<entCoreVersion>6.8-develop-community-SNAPSHOT</entCoreVersion>
<web-utils.version>3.1-SNAPSHOT</web-utils.version>
<vertxCronTimerVersion>3.0-SNAPSHOT</vertxCronTimerVersion>
<scramVersion>2.1</scramVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -202,12 +205,29 @@ public Future<JsonArray> 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<Integer> ids) {
if (ids == null || ids.isEmpty()) return;
final ResourceBrokerPublisher publisher = BrokerPublisherFactory.create(
ResourceBrokerPublisher.class,
communication.vertx(),
new AddressParameter("application", application)
);
final List<String> 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
Expand Down
Loading