class LogbookOperationsImpl implements LogbookOperations {

    @Override
    public IndexationResult reindex(IndexParameters indexParameters) {
        LogbookCollections collection;
        try {
            collection = LogbookCollections.valueOf(indexParameters.getCollectionName().toUpperCase());
        } catch (IllegalArgumentException exc) {
            String message = String.format("Try to reindex a non operation logbook collection '%s' with operation " +
                    "logbook module",
                indexParameters
                    .getCollectionName());
            LOGGER.error(message);
            return indexationHelper.getFullKOResult(indexParameters, message);
        }
        if (!LogbookCollections.OPERATION.equals(collection)) {
            String message = String.format("Try to reindex a non operation logbook collection '%s' with operation " +
                    "logbook module",
                indexParameters
                    .getCollectionName());
            LOGGER.error(message);
            return indexationHelper.getFullKOResult(indexParameters, message);
        } else {
            MongoCollection<Document> mongoCollection = collection.getCollection();
            try (InputStream mappingStream = ElasticsearchCollections
                .valueOf(indexParameters.getCollectionName().toUpperCase())
                .getMappingAsInputStream()) {
                return indexationHelper.reindex(mongoCollection, collection.getName(), collection.getEsClient(),
                    indexParameters.getTenants(), mappingStream);
            } catch (IOException exc) {
                LOGGER.error("Cannot get '{}' elastic search mapping for tenants {}", collection.name(),
                    indexParameters.getTenants().stream().map(Object::toString).collect(Collectors.joining(", ")));
                return indexationHelper.getFullKOResult(indexParameters, exc.getMessage());
            }
        }

    }

    public  LogbookOperationsImpl(LogbookDbAccess mongoDbAccess);
    @VisibleForTesting public  LogbookOperationsImpl(LogbookDbAccess mongoDbAccess, WorkspaceClientFactory workspaceClientFactory,
        StorageClientFactory storageClientFactory, IndexationHelper indexationHelper);

}