public boolean hasEntry( NextInterceptor nextInterceptor, EntryOperationContext entryContext ) throws Exception { // Ask others first. boolean hasEntry = nextInterceptor.hasEntry( entryContext ); // If the entry exists, if ( hasEntry ) { // Check DELETED attribute. try { ServerEntry entry = nextInterceptor.lookup( new LookupOperationContext( entryContext.getSession(), entryContext.getDn() ) ); hasEntry = !isDeleted( entry ); } catch ( NameNotFoundException e ) { hasEntry = false; } } return hasEntry; }
public boolean exists( DN dn ) throws Exception { EntryOperationContext opContext = new EntryOperationContext( this, dn ); OperationManager operationManager = directoryService.getOperationManager(); return operationManager.hasEntry( opContext ); }
public boolean hasEntry( EntryOperationContext opContext ) throws Exception { return null != getEntryId( opContext.getDn().getNormName() ); }
/** * Make sure the specified <tt>newEntryName</tt> already exists. It * checked {@link Constants#ENTRY_DELETED} additionally to see if the * entry actually exists in a {@link Partition} but maked as deleted. * * @param newEntryName makes sure an entry already exists. */ private void checkBeforeAdd( LdapDN newEntryName ) throws Exception { LdapDN adminDn = new LdapDN( ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED ); adminDn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() ); CoreSession adminSession = new DefaultCoreSession( new LdapPrincipal( adminDn, AuthenticationLevel.STRONG ), ds ); if ( nexus.hasEntry( new EntryOperationContext( adminSession, newEntryName ) ) ) { ServerEntry entry = nexus.lookup( new LookupOperationContext( adminSession, newEntryName ) ); EntryAttribute deleted = entry.get( Constants.ENTRY_DELETED ); Object value = deleted == null ? null : deleted.get(); /* * Check first if the entry has been marked as deleted before * throwing an exception and delete the entry if so and return * without throwing an exception. */ if ( value != null && "TRUE".equalsIgnoreCase( value.toString() ) ) { return; } throw new NameAlreadyBoundException( newEntryName.toString() + " already exists." ); } }
if ( nexus.hasEntry( new EntryOperationContext( coreSession, name ) ) )