public void delete( LdapDN dn ) throws NamingException { BigInteger id = getEntryId( dn.toString() ); // don't continue if id is null if ( id == null ) { throw new LdapNameNotFoundException( "Could not find entry at '" + dn + "' to delete it!" ); } if ( getChildCount( id ) > 0 ) { LdapContextNotEmptyException cnee = new LdapContextNotEmptyException( "[66] Cannot delete entry " + dn + " it has children!" ); cnee.setRemainingName( dn ); throw cnee; } delete( id ); }
/** * 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 ); }
/** * {@inheritDoc} */ public void delete( DeleteOperationContext opContext ) throws Exception { DN dn = opContext.getDn(); ID id = getEntryId( dn.getNormName() ); // don't continue if id is null if ( id == null ) { throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_699, dn ) ); } if ( getChildCount( id ) > 0 ) { LdapContextNotEmptyException cnee = new LdapContextNotEmptyException( I18n.err( I18n.ERR_700, dn ) ); //cnee.setRemainingName( dn ); throw cnee; } delete( id ); }