/** * Checks to make sure the entry being deleted exists, and has no children, otherwise throws the appropriate * LdapException. */ public void delete( NextInterceptor nextInterceptor, LdapDN name ) throws NamingException { // check if entry to delete exists String msg = "Attempt to delete non-existant entry: "; assertHasEntry( nextInterceptor, msg, name ); // check if entry to delete has children (only leaves can be deleted) boolean hasChildren = false; NamingEnumeration list = nextInterceptor.list( name ); if ( list.hasMore() ) { hasChildren = true; } list.close(); if ( hasChildren ) { LdapContextNotEmptyException e = new LdapContextNotEmptyException(); e.setResolvedName( new LdapDN( name.getUpName() ) ); throw e; } nextInterceptor.delete( name ); }