Package org.apache.directory.shared.ldap.entry

Examples of org.apache.directory.shared.ldap.entry.Entry


     */
    private void processAddRequest( AddRequestCodec request, BatchResponseDsml batchResponseDsml,
        StudioProgressMonitor monitor )
    {
        // Executing the add request
        Entry entry = request.getEntry();
        browserConnection.getConnection().getJNDIConnectionWrapper().createEntry( entry.getDn().getUpName(),
            AttributeUtils.toAttributes( entry ), getControls( request ), monitor, null );

        // Creating the response
        if ( batchResponseDsml != null )
        {
            AddResponseDsml addResponseDsml = new AddResponseDsml();
            addResponseDsml.setLdapResult( getLdapResult( monitor, MessageTypeEnum.ADD_REQUEST ) );
            addResponseDsml.getLdapResult().setMatchedDN( entry.getDn() );
            batchResponseDsml.addResponse( addResponseDsml );
        }

        // Update cached entries
        LdapDN dn = entry.getDn();
        IEntry e = browserConnection.getEntryFromCache( dn );
        LdapDN parentDn = DnUtils.getParent( dn );
        IEntry parentEntry = parentDn != null ? browserConnection.getEntryFromCache( parentDn ) : null;
        if ( e != null )
        {
View Full Code Here


     * @throws LdapURLEncodingException
     */
    private static DsmlDecorator convertSearchResultToDsml( SearchResult searchResult, SearchParameter searchParameter )
        throws InvalidAttributeIdentifierException, InvalidNameException, LdapURLEncodingException
    {
        Entry entry = AttributeUtils.toClientEntry( searchResult.getAttributes(), new LdapDN( searchResult
            .getNameInNamespace() ) );

        if ( isReferral( entry ) )
        {
            // The search result is a referral
            SearchResultReferenceDsml srr = new SearchResultReferenceDsml();

            // Getting the 'ref' attribute
            EntryAttribute refAttribute = entry.get( ExportDsmlJob.REF_ATTRIBUTETYPE_NAME );
            if ( refAttribute == null )
            {
                // If we did not get it by its name, let's get it by its OID
                refAttribute = entry.get( ExportDsmlJob.REF_ATTRIBUTETYPE_OID );
            }

            // Adding references
            if ( refAttribute != null )
            {
View Full Code Here

     */
    private AddRequestDsml convertToAddRequestDsml( SearchResult searchResult )
        throws InvalidAttributeIdentifierException, InvalidNameException
    {
        AddRequestDsml ar = new AddRequestDsml();
        Entry entry = AttributeUtils.toClientEntry( searchResult.getAttributes(), new LdapDN( searchResult
            .getNameInNamespace() ) );
        ar.setEntry( entry );

        return ar;
    }
View Full Code Here

        if ( isDebugEnabled() )
        {
            System.out.println( "Adding entry " + dn );
        }

        Entry entry = ldifEntry.getEntry();

        addRequest.setEntryDn( new DN( dn ) );

        // Copy the attributes
        for ( EntryAttribute attribute:entry )
        {
            addRequest.addAttributeType( attribute.getId() );

            for ( Value<?> value: attribute )
            {
                addRequest.addAttributeValue( value );
            }
        }

        addRequest.setMessageId( messageId );

        // Encode and send the addRequest message
        ByteBuffer bb = addRequest.encode();
        bb.flip();

        sendMessage( bb );

        bb.clear();

        // Get the response
        LdapMessageCodec response = readResponse( bb );

        LdapResultCodec result = ((LdapResponseCodec)response).getLdapResult();

        if ( result.getResultCode() == ResultCodeEnum.SUCCESS )
        {
            if ( isDebugEnabled() )
            {
                System.out.println( "Add of Entry " + entry.getDn() + " was successful" );
            }

            return IMPORT_SUCCESS;
        }
        else
        {
            System.err.println( I18n.err( I18n.ERR_203, entry.getDn(), result.getErrorMessage() ) );

            return IMPORT_ERROR;
        }
    }
View Full Code Here

       
        service.getAdminSession().add(
            new DefaultServerEntry( service.getSchemaManager(), akarasulu.getEntry() ) );
       
        // Read the entry we just created using the akarasuluSession
        Entry readEntry = service.getAdminSession().lookup( akarasulu.getDn(), new String[]{ "userPassword"} );
       
        assertTrue( Arrays.equals( akarasulu.get( "userPassword" ).getBytes(), readEntry.get( "userPassword" ).getBytes() ) );

        EntryAttribute attribute = new DefaultClientAttribute( "userPassword", "replaced" );

        List<Modification> mods = new ArrayList<Modification>();
       
View Full Code Here

        cursor.beforeFirst();
        int nbRes = 0;
       
        while ( cursor.next() )
        {
            Entry entry = cursor.get();
            assertNotNull( entry );
            nbRes++;
           
            expectedDns.remove( entry.getDn().getNormName() );
        }

        assertEquals( 3, nbRes );
        assertEquals( 0, expectedDns.size() );
    }
View Full Code Here

     * @return An instance of ClientEntry
     */
    public Entry toClientEntry() throws NamingException
    {
        // Copy the DN
        Entry clientEntry = new DefaultClientEntry( dn );
       
        // Convert each attribute
        for ( EntryAttribute serverAttribute:this )
        {
            EntryAttribute clientAttribute = ((ServerAttribute)serverAttribute).toClientAttribute();
            clientEntry.add( clientAttribute );
        }
       
        return clientEntry;
    }
View Full Code Here

     */
    @Test
    public void testLookupStar() throws Exception
    {
        DN dn = new DN( "cn=test,ou=system" );
        Entry entry = service.getAdminSession().lookup( dn, new String[]{ "*" } );
       
        assertNotNull( entry );
       
        // Check that we don't have any operational attributes :
        // We should have only 3 attributes : objectClass, cn and sn
        assertEquals( 3, entry.size() );

        // Check that all the user attributes are present
        assertEquals( "test", entry.get( "cn" ).getString() );
        assertEquals( "sn_test", entry.get( "sn" ).getString() );
        assertTrue( entry.contains( "objectClass", "top", "person" ) );
    }
View Full Code Here

    @Test
    public void testLookupPlus() throws Exception
    {
        service.setDenormalizeOpAttrsEnabled( true );
        DN dn = new DN( "cn=test,ou=system" );
        Entry entry = service.getAdminSession().lookup( dn, new String[]{ "+" } );
       
        assertNotNull( entry );
       
        // We should have 5 attributes
        assertEquals( 7, entry.size() );

        // Check that all the user attributes are present
        assertEquals( "test", entry.get( "cn" ).getString() );
        assertEquals( "sn_test", entry.get( "sn" ).getString() );
        assertTrue( entry.contains( "objectClass", "top", "person" ) );
       
        // Check that we have all the operational attributes :
        // We should have 3 users attributes : objectClass, cn and sn
        // and 2 operational attributes : createTime and createUser
        assertNotNull( entry.get( "createTimestamp" ).getString() );
        assertEquals( "uid=admin,ou=system", entry.get( "creatorsName" ).getString() );
    }
View Full Code Here

     */
    @Test
    public void testLookupEmptyAtrid() throws Exception
    {
        DN dn = new DN( "cn=test,ou=system" );
        Entry entry = service.getAdminSession().lookup( dn, new String[]{} );
       
        assertNotNull( entry );
       
        // We should have 3 attributes
        assertEquals( 3, entry.size() );

        // Check that all the user attributes are present
        assertEquals( "test", entry.get( "cn" ).getString() );
        assertEquals( "sn_test", entry.get( "sn" ).getString() );
        assertTrue( entry.contains( "objectClass", "top", "person" ) );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.entry.Entry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.