Java Code Examples for org.apache.directory.api.ldap.model.message.SearchScope#ONELEVEL

The following examples show how to use org.apache.directory.api.ldap.model.message.SearchScope#ONELEVEL . 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: DefaultCoreSession.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
public EntryFilteringCursor list( Dn dn, AliasDerefMode aliasDerefMode,
    String... returningAttributes ) throws LdapException
{
    OperationManager operationManager = directoryService.getOperationManager();

    PresenceNode filter = new PresenceNode( OBJECT_CLASS_AT );
    SearchOperationContext searchContext = new SearchOperationContext( this, dn, SearchScope.ONELEVEL, filter,
        returningAttributes );
    searchContext.setAliasDerefMode( aliasDerefMode );

    return operationManager.search( searchContext );
}
 
Example 2
Source File: DefaultCoreSession.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
public Cursor<Entry> list( Dn dn, AliasDerefMode aliasDerefMode,
    String... returningAttributes ) throws LdapException
{
    OperationManager operationManager = directoryService.getOperationManager();

    PresenceNode filter = new PresenceNode( OBJECT_CLASS_AT );
    SearchOperationContext searchContext = new SearchOperationContext( this, dn, SearchScope.ONELEVEL, filter,
        returningAttributes );
    searchContext.setAliasDerefMode( aliasDerefMode );

    return operationManager.search( searchContext );
}
 
Example 3
Source File: SearchRequestDsml.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Element toDsml( Element root )
{
    Element element = super.toDsml( root );

    SearchRequest request = getDecorated();

    // Dn
    if ( request.getBase() != null )
    {
        element.addAttribute( "dn", request.getBase().getName() );
    }

    // Scope
    SearchScope scope = request.getScope();
    if ( scope != null )
    {
        if ( scope == SearchScope.OBJECT )
        {
            element.addAttribute( "scope", "baseObject" );
        }
        else if ( scope == SearchScope.ONELEVEL )
        {
            element.addAttribute( "scope", "singleLevel" );
        }
        else if ( scope == SearchScope.SUBTREE )
        {
            element.addAttribute( "scope", "wholeSubtree" );
        }
    }

    // DerefAliases
    AliasDerefMode derefAliases = request.getDerefAliases();

    switch ( derefAliases )
    {
        case NEVER_DEREF_ALIASES:
            element.addAttribute( DEREF_ALIASES, "neverDerefAliases" );
            break;

        case DEREF_ALWAYS:
            element.addAttribute( DEREF_ALIASES, "derefAlways" );
            break;

        case DEREF_FINDING_BASE_OBJ:
            element.addAttribute( DEREF_ALIASES, "derefFindingBaseObj" );
            break;

        case DEREF_IN_SEARCHING:
            element.addAttribute( DEREF_ALIASES, "derefInSearching" );
            break;

        default:
            throw new IllegalStateException( I18n.err( I18n.ERR_03043_UNEXPECTED_DEREF_ALIAS, derefAliases ) );
    }

    // SizeLimit
    if ( request.getSizeLimit() != 0L )
    {
        element.addAttribute( "sizeLimit", Long.toString( request.getSizeLimit() ) );
    }

    // TimeLimit
    if ( request.getTimeLimit() != 0 )
    {
        element.addAttribute( "timeLimit", Integer.toString( request.getTimeLimit() ) );
    }

    // TypesOnly
    if ( request.getTypesOnly() )
    {
        element.addAttribute( "typesOnly", "true" );
    }

    // Filter
    Element filterElement = element.addElement( "filter" );
    toDsml( filterElement, request.getFilter() );

    // Attributes
    List<String> attributes = request.getAttributes();

    if ( !attributes.isEmpty() )
    {
        Element attributesElement = element.addElement( "attributes" );

        for ( String entryAttribute : attributes )
        {
            attributesElement.addElement( "attribute" ).addAttribute( NAME, entryAttribute );
        }
    }

    return element;
}
 
Example 4
Source File: LdapUrl.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * Parse the scope part.
 *
 * @param chars The char array to be checked
 * @param pos the starting position
 * @return -1 if the char array does not contains a scope
 */
private int parseScope( char[] chars, int pos )
{

    if ( Chars.isCharASCII( chars, pos, 'b' ) || Chars.isCharASCII( chars, pos, 'B' ) )
    {
        pos++;

        if ( Chars.isCharASCII( chars, pos, 'a' ) || Chars.isCharASCII( chars, pos, 'A' ) )
        {
            pos++;

            if ( Chars.isCharASCII( chars, pos, 's' ) || Chars.isCharASCII( chars, pos, 'S' ) )
            {
                pos++;

                if ( Chars.isCharASCII( chars, pos, 'e' ) || Chars.isCharASCII( chars, pos, 'E' ) )
                {
                    pos++;
                    scope = SearchScope.OBJECT;
                    return pos;
                }
            }
        }
    }
    else if ( Chars.isCharASCII( chars, pos, 'o' ) || Chars.isCharASCII( chars, pos, 'O' ) )
    {
        pos++;

        if ( Chars.isCharASCII( chars, pos, 'n' ) || Chars.isCharASCII( chars, pos, 'N' ) )
        {
            pos++;

            if ( Chars.isCharASCII( chars, pos, 'e' ) || Chars.isCharASCII( chars, pos, 'E' ) )
            {
                pos++;

                scope = SearchScope.ONELEVEL;
                return pos;
            }
        }
    }
    else if ( Chars.isCharASCII( chars, pos, 's' ) || Chars.isCharASCII( chars, pos, 'S' ) )
    {
        pos++;

        if ( Chars.isCharASCII( chars, pos, 'u' ) || Chars.isCharASCII( chars, pos, 'U' ) )
        {
            pos++;

            if ( Chars.isCharASCII( chars, pos, 'b' ) || Chars.isCharASCII( chars, pos, 'B' ) )
            {
                pos++;

                scope = SearchScope.SUBTREE;
                return pos;
            }
        }
    }
    else if ( Chars.isCharASCII( chars, pos, '?' ) )
    {
        // An empty scope. This is valid
        return pos;
    }
    else if ( pos == chars.length )
    {
        // An empty scope at the end of the URL. This is valid
        return pos;
    }

    // The scope is not one of "one", "sub" or "base". It's an error
    return -1;
}