Java Code Examples for org.apache.directory.api.ldap.model.name.Dn#isRootDse()

The following examples show how to use org.apache.directory.api.ldap.model.name.Dn#isRootDse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultPartitionNexus.java    From MyVirtualDirectory with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean hasEntry( HasEntryOperationContext hasEntryContext ) throws LdapException
{
    Dn dn = hasEntryContext.getDn();

    if ( IS_DEBUG )
    {
        LOG.debug( "Check if Dn '" + dn + "' exists." );
    }

    if ( dn.isRootDse() )
    {
        return true;
    }

    Partition partition = getPartition( dn );

    return partition.hasEntry( hasEntryContext );
}
 
Example 2
Source File: DefaultPartitionNexus.java    From MyVirtualDirectory with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean hasEntry( HasEntryOperationContext hasEntryContext ) throws LdapException
{
    Dn dn = hasEntryContext.getDn();

    if ( IS_DEBUG )
    {
        LOG.debug( "Check if Dn '" + dn + "' exists." );
    }

    if ( dn.isRootDse() )
    {
        return true;
    }

    Partition partition = getPartition( dn );

    return partition.hasEntry( hasEntryContext );
}
 
Example 3
Source File: DefaultPartitionNexus.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Entry lookup( LookupOperationContext lookupContext ) throws LdapException
{
    Dn dn = lookupContext.getDn();

    if ( dn.equals( subschemSubentryDn ) )
    {
        return new ClonedServerEntry( rootDse.clone() );
    }

    // This is for the case we do a lookup on the rootDSE
    if ( dn.isRootDse() )
    {
        Entry retval = new ClonedServerEntry( rootDse );

        return retval;
    }

    Partition partition = getPartition( dn );
    Entry entry = partition.lookup( lookupContext );

    if ( entry == null )
    {
        LdapNoSuchObjectException e = new LdapNoSuchObjectException( "Attempt to lookup non-existant entry: "
            + dn.getName() );

        throw e;
    }

    return entry;
}
 
Example 4
Source File: DefaultPartitionNexus.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Entry lookup( LookupOperationContext lookupContext ) throws LdapException
{
    Dn dn = lookupContext.getDn();

    if ( dn.equals( subschemSubentryDn ) )
    {
        return new ClonedServerEntry( rootDse.clone() );
    }

    // This is for the case we do a lookup on the rootDSE
    if ( dn.isRootDse() )
    {
        Entry retval = new ClonedServerEntry( rootDse );

        return retval;
    }

    Partition partition = getPartition( dn );
    Entry entry = partition.lookup( lookupContext );

    if ( entry == null )
    {
        LdapNoSuchObjectException e = new LdapNoSuchObjectException( "Attempt to lookup non-existant entry: "
            + dn.getName() );

        throw e;
    }

    return entry;
}
 
Example 5
Source File: LdapNetworkConnection.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
{
    // Check the parameters first
    if ( entryDn == null )
    {
        throw new IllegalArgumentException( I18n.err( I18n.ERR_04142_NULL_ENTRY_DN ) );
    }

    if ( entryDn.isRootDse() )
    {
        throw new IllegalArgumentException( I18n.err( I18n.ERR_04143_CANNOT_MOVE_ROOT_DSE ) );
    }

    if ( newDn == null )
    {
        throw new IllegalArgumentException( I18n.err( I18n.ERR_04144_NULL_NEW_DN ) );
    }

    if ( newDn.isRootDse() )
    {
        throw new IllegalArgumentException( I18n.err( I18n.ERR_04145_ROOT_DSE_CANNOT_BE_TARGET ) );
    }

    // Create the request
    ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
    modDnRequest.setName( entryDn );
    modDnRequest.setNewRdn( newDn.getRdn() );
    
    // Check if we really need to specify newSuperior.
    // newSuperior is optional [RFC4511, section 4.9]
    // Some servers (e.g. OpenDJ 2.6) require a special privilege if
    // newSuperior is specified even if it is the same as the old one. Therefore let's not
    // specify it if we do not need it. This is better interoperability. 
    Dn newDnParent = newDn.getParent();
    if ( newDnParent != null && !newDnParent.equals( entryDn.getParent() ) )
    {
        modDnRequest.setNewSuperior( newDnParent );
    }
    
    modDnRequest.setDeleteOldRdn( deleteOldRdn );

    ModifyDnResponse modifyDnResponse = modifyDn( modDnRequest );

    processResponse( modifyDnResponse );
}