Package org.apache.directory.api.ldap.model.entry

Examples of org.apache.directory.api.ldap.model.entry.DefaultAttribute


    }


    private static Attribute generateSyntaxCheckers( SchemaManager schemaManager ) throws LdapException
    {
        Attribute attr = new DefaultAttribute(
            schemaManager.getAttributeType( SchemaConstants.SYNTAX_CHECKERS_AT ) );

        for ( SyntaxChecker syntaxChecker : schemaManager.getSyntaxCheckerRegistry() )
        {
            attr.add( SchemaUtils.render( syntaxChecker ) );
        }

        return attr;
    }
View Full Code Here


    }


    private static Attribute generateObjectClasses( SchemaManager schemaManager ) throws LdapException
    {
        Attribute attr = new DefaultAttribute(
            schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASSES_AT ) );

        for ( ObjectClass objectClass : schemaManager.getObjectClassRegistry() )
        {
            attr.add( SchemaObjectRenderer.SUBSCHEMA_SUBENTRY_RENDERER.render( objectClass ) );
        }

        return attr;
    }
View Full Code Here

    }


    private static Attribute generateAttributeTypes( SchemaManager schemaManager ) throws LdapException
    {
        Attribute attr = new DefaultAttribute(
            schemaManager.getAttributeType( SchemaConstants.ATTRIBUTE_TYPES_AT ) );

        for ( AttributeType attributeType : schemaManager.getAttributeTypeRegistry() )
        {
            attr.add( SchemaObjectRenderer.SUBSCHEMA_SUBENTRY_RENDERER.render( attributeType ) );
        }

        return attr;
    }
View Full Code Here

    }


    private static Attribute generateMatchingRules( SchemaManager schemaManager ) throws LdapException
    {
        Attribute attr = new DefaultAttribute(
            schemaManager.getAttributeType( SchemaConstants.MATCHING_RULES_AT ) );

        for ( MatchingRule matchingRule : schemaManager.getMatchingRuleRegistry() )
        {
            attr.add( SchemaObjectRenderer.SUBSCHEMA_SUBENTRY_RENDERER.render( matchingRule ) );
        }

        return attr;
    }
View Full Code Here

    }


    private static Attribute generateMatchingRuleUses( SchemaManager schemaManager ) throws LdapException
    {
        Attribute attr = new DefaultAttribute(
            schemaManager.getAttributeType( SchemaConstants.MATCHING_RULE_USE_AT ) );

        for ( MatchingRuleUse matchingRuleUse : schemaManager.getMatchingRuleUseRegistry() )
        {
            attr.add( SchemaObjectRenderer.SUBSCHEMA_SUBENTRY_RENDERER.render( matchingRuleUse ) );
        }

        return attr;
    }
View Full Code Here

    }


    private static Attribute generateSyntaxes( SchemaManager schemaManager ) throws LdapException
    {
        Attribute attr = new DefaultAttribute(
            schemaManager.getAttributeType( SchemaConstants.LDAP_SYNTAXES_AT ) );

        for ( LdapSyntax syntax : schemaManager.getLdapSyntaxRegistry() )
        {
            attr.add( SchemaObjectRenderer.SUBSCHEMA_SUBENTRY_RENDERER.render( syntax ) );
        }

        return attr;
    }
View Full Code Here

    }


    private static Attribute generateDitContextRules( SchemaManager schemaManager ) throws LdapException
    {
        Attribute attr = new DefaultAttribute(
            schemaManager.getAttributeType( SchemaConstants.DIT_CONTENT_RULES_AT ) );

        for ( DitContentRule ditContentRule : schemaManager.getDITContentRuleRegistry() )
        {
            attr.add( SchemaObjectRenderer.SUBSCHEMA_SUBENTRY_RENDERER.render( ditContentRule ) );
        }

        return attr;
    }
View Full Code Here

    }


    private static Attribute generateDitStructureRules( SchemaManager schemaManager ) throws LdapException
    {
        Attribute attr = new DefaultAttribute(
            schemaManager.getAttributeType( SchemaConstants.DIT_STRUCTURE_RULES_AT ) );

        for ( DitStructureRule ditStructureRule : schemaManager.getDITStructureRuleRegistry() )
        {
            attr.add( SchemaObjectRenderer.SUBSCHEMA_SUBENTRY_RENDERER.render( ditStructureRule ) );
        }

        return attr;
    }
View Full Code Here

    }


    private static Attribute generateNameForms( SchemaManager schemaManager ) throws LdapException
    {
        Attribute attr = new DefaultAttribute(
            schemaManager.getAttributeType( SchemaConstants.NAME_FORMS_AT ) );

        for ( NameForm nameForm : schemaManager.getNameFormRegistry() )
        {
            attr.add( SchemaObjectRenderer.SUBSCHEMA_SUBENTRY_RENDERER.render( nameForm ) );
        }

        return attr;
    }
View Full Code Here

        ModifyOperationContext modOpCtx = new ModifyOperationContext( mockSession );
        modOpCtx.setEntry( contextEntry );

        List<Modification> modItems = new ArrayList<Modification>();

        Attribute attribute = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( "description" ) );
        attribute.add( "this is description" );

        Modification mod = new DefaultModification();
        mod.setOperation( ModificationOperation.ADD_ATTRIBUTE );
        mod.setAttribute( attribute );

        modItems.add( mod );
        modOpCtx.setModItems( modItems );

        modOpCtx.setDn( contextEntry.getDn() );

        partition.modify( modOpCtx );
        RandomAccessFile file = new RandomAccessFile( new File( partition.getPartitionPath() ), "r" );
        assertEquals( getEntryLdifLen( modOpCtx.getAlteredEntry() ), file.length() );

        // perform the above operation, this time without causing change to the entry's size
        modOpCtx = new ModifyOperationContext( mockSession );
        modOpCtx.setEntry( new ClonedServerEntry( contextEntry ) );

        modItems = new ArrayList<Modification>();

        attribute = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( "description" ) );
        attribute.add( "siht si noitpircsed" ); // reversed "this is description"

        mod = new DefaultModification();
        mod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE );
        mod.setAttribute( attribute );

        modItems.add( mod );
        modOpCtx.setModItems( modItems );

        modOpCtx.setDn( contextEntry.getDn() );

        partition.modify( modOpCtx );
        assertEquals( getEntryLdifLen( modOpCtx.getAlteredEntry() ), file.length() );

        Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
        entry1.put( "ObjectClass", "top", "domain" );
        entry1.put( "dc", "test" );
        addCtx.setEntry( entry1 );

        partition.add( addCtx );

        Entry entry2 = createEntry( "dc=test,dc=test,ou=test,ou=system" );
        entry2.put( "ObjectClass", "top", "domain" );
        entry2.put( "dc", "test" );
        addCtx.setEntry( entry2 );

        partition.add( addCtx );

        // now perform a modification on the entry present in middle of LDIF file
        modOpCtx = new ModifyOperationContext( mockSession );
        modOpCtx.setEntry( new ClonedServerEntry( entry1 ) );
        modOpCtx.setDn( entry1.getDn() );

        modItems = new ArrayList<Modification>();

        attribute = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( "description" ) );
        attribute.add( "desc of entry1" ); // reversed "this is description"

        mod = new DefaultModification();
        mod.setOperation( ModificationOperation.ADD_ATTRIBUTE );
        mod.setAttribute( attribute );

        modItems.add( mod );
        modOpCtx.setModItems( modItems );

        partition.modify( modOpCtx );

        long ctxEntryLen = getEntryLdifLen( contextEntry );
        long entry1Len = getEntryLdifLen( entry1 );

        file.seek( ctxEntryLen );

        byte[] entry1Data = new byte[( int ) entry1Len];

        file.read( entry1Data );

        String ldif = Strings.utf8ToString( entry1Data );

        LdifEntry ldifEntry = reader.parseLdif( ldif ).get( 0 );

        // Remove the EntryDN
        entry1.removeAttributes( "entryDn" );

        assertEquals( entry1, new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );

        //"description: desc of entry1\n"

        modOpCtx = new ModifyOperationContext( mockSession );
        modOpCtx.setEntry( new ClonedServerEntry( entry1 ) );
        modOpCtx.setDn( entry1.getDn() );

        modItems = new ArrayList<Modification>();

        attribute = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( "description" ) );
        attribute.add( "desc of entry1" ); // reversed "this is description"

        mod = new DefaultModification();
        mod.setOperation( ModificationOperation.REMOVE_ATTRIBUTE );
        mod.setAttribute( attribute );
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.entry.DefaultAttribute

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.