Package org.apache.directory.shared.ldap.schema

Examples of org.apache.directory.shared.ldap.schema.AttributeType


    {
        for ( Modification mod:mods )
        {
            // TODO: handle http://issues.apache.org/jira/browse/DIRSERVER-1198
            ServerAttribute attr = (ServerAttribute)mod.getAttribute();
            AttributeType attrType = attr.getAttributeType();

            if ( attrType == null )
            {
                if ( !schemaManager.getAttributeTypeRegistry().contains( attr.getUpId() ) )
                {
                    throw new LdapInvalidAttributeIdentifierException();
                }
                else
                {
                    attrType = schemaManager.lookupAttributeTypeRegistry( attr.getUpId() );
                }
            }
           
           
            ModificationOperation modOp = mod.getOperation();
           
            if ( ( ( modOp == ModificationOperation.ADD_ATTRIBUTE ) || ( modOp == ModificationOperation.REPLACE_ATTRIBUTE ) ) &&
                attrType.isCollective() )
            {
                return true;
            }
        }
       
View Full Code Here


    public boolean evaluate( ExprNode node, String dn, ServerEntry entry ) throws NamingException
    {
        Pattern regex = null;
        SubstringNode snode = (SubstringNode)node;
        String oid = schemaManager.getAttributeTypeRegistry().getOidByName( snode.getAttribute() );
        AttributeType type = schemaManager.lookupAttributeTypeRegistry( oid );
        MatchingRule matchingRule = type.getSubstring();
       
        if ( matchingRule == null )
        {
            matchingRule = type.getEquality();
        }
       
        Normalizer normalizer = matchingRule.getNormalizer();
       
View Full Code Here

            exclusions = new HashSet<String>();
           
            for ( Value<?> value:collectiveExclusions )
            {
                AttributeType attrType = schemaManager.lookupAttributeTypeRegistry( value.getString() );
                exclusions.add( attrType.getOid() );
            }
        }
       
        /*
         * If no attributes are requested specifically
         * then it means all user attributes are requested.
         * So populate the array with all user attributes indicator: "*".
         */
        if ( retAttrs == null )
        {
            retAttrs = SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY;
        }
       
        /*
         * Construct a set of requested attributes for easier tracking.
         */
        Set<String> retIdsSet = new HashSet<String>( retAttrs.length );
       
        for ( String retAttr:retAttrs )
        {
            if ( retAttr.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) ||
                retAttr.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
            {
                retIdsSet.add( retAttr );
            }
            else
            {
                retIdsSet.add( schemaManager.lookupAttributeTypeRegistry( retAttr ).getOid() );
            }
        }

        /*
         * For each collective subentry referenced by the entry we lookup the
         * attributes of the subentry and copy collective attributes from the
         * subentry into the entry.
         */
        for ( Value<?> value:collectiveAttributeSubentries )
        {
            String subentryDnStr = value.getString();
            DN subentryDn = new DN( subentryDnStr );
           
            /*
             * TODO - Instead of hitting disk here can't we leverage the
             * SubentryService to get us cached sub-entries so we're not
             * wasting time with a lookup here? It is ridiculous to waste
             * time looking up this sub-entry.
             */
           
            ServerEntry subentry = opContext.lookup( subentryDn, ByPassConstants.LOOKUP_COLLECTIVE_BYPASS );
           
            for ( AttributeType attributeType:subentry.getAttributeTypes() )
            {
                String attrId = attributeType.getName();
               
                if ( !attributeType.isCollective() )
                {
                    continue;
                }
               
                /*
                 * Skip the addition of this collective attribute if it is excluded
                 * in the 'collectiveAttributes' attribute.
                 */
                if ( exclusions.contains( attributeType.getOid() ) )
                {
                    continue;
                }
               
                Set<AttributeType> allSuperTypes = getAllSuperTypes( attributeType );

                for ( String retId : retIdsSet )
                {
                    if ( retId.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) || retId.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
                    {
                        continue;
                    }

                    AttributeType retType = schemaManager.lookupAttributeTypeRegistry( retId );

                    if ( allSuperTypes.contains( retType ) )
                    {
                        retIdsSet.add( schemaManager.lookupAttributeTypeRegistry( attrId ).getOid() );
                        break;
View Full Code Here

   
   
    private Set<AttributeType> getAllSuperTypes( AttributeType id ) throws Exception
    {
        Set<AttributeType> allSuperTypes = new HashSet<AttributeType>();
        AttributeType superType = id;
       
        while ( superType != null )
        {
            superType = superType.getSuperior();
           
            if ( superType != null )
            {
                allSuperTypes.add( superType );
            }
View Full Code Here

                ProtectedItem.AttributeValue av = ( ProtectedItem.AttributeValue ) item;
                for ( Iterator<Attribute> j = av.iterator(); j.hasNext(); )
                {
                    Attribute attr = j.next();
                    String attrOid = schemaManager.getAttributeTypeRegistry().getOidByName( attr.getID() );
                    AttributeType attrType = schemaManager.lookupAttributeTypeRegistry( attrOid );
                   
                    if ( oid.equals( attrOid ) && AttributeUtils.containsValue( attr, attrValue, attrType ) )
                    {
                        return true;
                    }
View Full Code Here

        Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" );

        MatchingRule equality = new MatchingRule( "1.1.1" );
        equality.setNormalizer( normalizer );
       
        AttributeType attributeType = new AttributeType( id );
        attributeType.setEquality( equality );
        attributeType.setSingleValued( false );
        attributeType.setCollective( false );
        attributeType.setDescription( id );

        if ( returnOperational )
        {
            attributeType.setUserModifiable( false );
        }
        else
        {
            LdapSyntax syntax = new LdapSyntax( "1.1.1" );
            syntax.setHumanReadable( true );

            attributeType.setSyntax( syntax );
            attributeType.setUserModifiable( true );
        }
       
        return attributeType;
    }
View Full Code Here

        {
            EntryAttribute opAttr = candidate.get( opAttrId );

            if ( ( opAttr != null ) && opAttr.contains( dn ) )
            {
                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( opAttrId );
                ServerAttribute attr = new DefaultServerAttribute( opAttrId, attributeType, dn );
                modList.add( new ServerModification( ModificationOperation.REMOVE_ATTRIBUTE, attr ) );
            }
        }
View Full Code Here

            else if ( isNewEntrySelected && !isOldEntrySelected )
            {
                for ( String attribute : SUBENTRY_OPATTRS )
                {
                    ModificationOperation op = ModificationOperation.ADD_ATTRIBUTE;
                    AttributeType type = schemaManager.lookupAttributeTypeRegistry( attribute );
                    ServerAttribute opAttr = new DefaultServerAttribute( attribute, type );
                    opAttr.add( subentryDn );
                    modList.add( new ServerModification( op, opAttr ) );
                }
            }
View Full Code Here

    @Test public void testAddAtBytesElipsis() throws Exception
    {
        DN dn = new DN( "cn=test" );
        DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
       
        AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
       
        byte[] test1 = StringTools.getBytesUtf8( "test1" );
        byte[] test2 = StringTools.getBytesUtf8( "test2" );
        byte[] test3 = StringTools.getBytesUtf8( "test3" );
       
View Full Code Here

    @Test public void testAddAtServerValueElipsis() throws Exception
    {
        DN dn = new DN( "cn=test" );
        DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
       
        AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
       
        byte[] b1 = StringTools.getBytesUtf8( "test1" );
        byte[] b2 = StringTools.getBytesUtf8( "test2" );
        byte[] b3 = StringTools.getBytesUtf8( "test3" );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.schema.AttributeType

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.