From a7dd511b31ea3dfa12dc63fae605b319eecee385 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Wed, 11 Nov 2020 08:37:02 +0100 Subject: [PATCH] DATALDAP-181 - Implement CrudRepository.deleteAllById(Iterable ids). Original pull request: #20. --- .../support/SimpleLdapRepository.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/springframework/data/ldap/repository/support/SimpleLdapRepository.java b/src/main/java/org/springframework/data/ldap/repository/support/SimpleLdapRepository.java index 2a98839..fe3497c 100644 --- a/src/main/java/org/springframework/data/ldap/repository/support/SimpleLdapRepository.java +++ b/src/main/java/org/springframework/data/ldap/repository/support/SimpleLdapRepository.java @@ -15,15 +15,6 @@ */ package org.springframework.data.ldap.repository.support; -import static org.springframework.ldap.query.LdapQueryBuilder.*; - -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; - -import javax.naming.Name; - import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.data.domain.Persistable; import org.springframework.data.ldap.repository.LdapRepository; @@ -37,6 +28,14 @@ import org.springframework.ldap.odm.core.ObjectDirectoryMapper; import org.springframework.ldap.query.LdapQuery; import org.springframework.util.Assert; +import javax.naming.Name; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +import static org.springframework.ldap.query.LdapQueryBuilder.*; + /** * Base repository implementation for LDAP. * @@ -56,8 +55,8 @@ public class SimpleLdapRepository implements LdapRepository { * Creates a new {@link SimpleLdapRepository}. * * @param ldapOperations must not be {@literal null}. - * @param odm must not be {@literal null}. - * @param entityType must not be {@literal null}. + * @param odm must not be {@literal null}. + * @param entityType must not be {@literal null}. */ public SimpleLdapRepository(LdapOperations ldapOperations, ObjectDirectoryMapper odm, Class entityType) { @@ -222,9 +221,20 @@ public class SimpleLdapRepository implements LdapRepository { */ @Override public void deleteAll(Iterable entities) { + + Assert.notNull(entities, "Entities must not be null."); + entities.forEach(this::delete); } + @Override + public void deleteAllById(Iterable names) { + + Assert.notNull(names, "Names must not be null."); + + names.forEach(this::deleteById); + } + /* (non-Javadoc) * @see org.springframework.data.repository.CrudRepository#deleteAll() */