Examples of MutableAttributeType


Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     * @param schema
     *      the schema
     */
    private static void readAttributeType( Element element, Schema schema ) throws XMLSchemaFileImportException
    {
        MutableAttributeType at = null;

        // OID
        Attribute oidAttribute = element.attribute( OID_TAG );
        if ( ( oidAttribute != null ) && ( !oidAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
        {
            at = new MutableAttributeType( oidAttribute.getValue() );
        }
        else
        {
            throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.NoOIDInAttribute" ) ); //$NON-NLS-1$
        }

        // Schema
        at.setSchemaName( schema.getSchemaName() );

        // Aliases
        Element aliasesElement = element.element( ALIASES_TAG );
        if ( aliasesElement != null )
        {
            List<String> aliases = new ArrayList<String>();
            for ( Iterator<?> i = aliasesElement.elementIterator( ALIAS_TAG ); i.hasNext(); )
            {
                Element aliasElement = ( Element ) i.next();
                aliases.add( aliasElement.getText() );
            }
            if ( aliases.size() >= 1 )
            {
                at.setNames( aliases.toArray( new String[0] ) );
            }
        }

        // Description
        Element descriptionElement = element.element( DESCRIPTION_TAG );
        if ( ( descriptionElement != null ) && ( !descriptionElement.getText().equals( "" ) ) ) //$NON-NLS-1$
        {
            at.setDescription( descriptionElement.getText() );
        }

        // Superior
        Element superiorElement = element.element( SUPERIOR_TAG );
        if ( ( superiorElement != null ) && ( !superiorElement.getText().equals( "" ) ) ) //$NON-NLS-1$
        {
            at.setSuperiorOid( superiorElement.getText() );
        }

        // Usage
        Element usageElement = element.element( USAGE_TAG );
        if ( ( usageElement != null ) && ( !usageElement.getText().equals( "" ) ) ) //$NON-NLS-1$
        {
            try
            {
                at.setUsage( UsageEnum.valueOf( usageElement.getText() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new XMLSchemaFileImportException( Messages
                    .getString( "XMLSchemaFileImporter.UnceonvertableAttribute" ), e ); //$NON-NLS-1$
            }
        }

        // Syntax
        Element syntaxElement = element.element( SYNTAX_TAG );
        if ( ( syntaxElement != null ) && ( !syntaxElement.getText().equals( "" ) ) ) //$NON-NLS-1$
        {
            at.setSyntaxOid( syntaxElement.getText() );
        }

        // Syntax Length
        Element syntaxLengthElement = element.element( SYNTAX_LENGTH_TAG );
        if ( ( syntaxLengthElement != null ) && ( !syntaxLengthElement.getText().equals( "" ) ) ) //$NON-NLS-1$
        {
            try
            {
                at.setSyntaxLength( Long.parseLong( syntaxLengthElement.getText() ) );
            }
            catch ( NumberFormatException e )
            {
                throw new XMLSchemaFileImportException( Messages
                    .getString( "XMLSchemaFileImporter.UnconvertableInteger" ), e ); //$NON-NLS-1$
            }
        }

        // Obsolete
        Attribute obsoleteAttribute = element.attribute( OBSOLETE_TAG );
        if ( ( obsoleteAttribute != null ) && ( !obsoleteAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
        {
            at.setObsolete( readBoolean( obsoleteAttribute.getValue() ) );
        }

        // Single Value
        Attribute singleValueAttribute = element.attribute( SINGLE_VALUE_TAG );
        if ( ( singleValueAttribute != null ) && ( !singleValueAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
        {
            at.setSingleValued( readBoolean( singleValueAttribute.getValue() ) );
        }

        // Collective
        Attribute collectiveAttribute = element.attribute( COLLECTIVE_TAG );
        if ( ( collectiveAttribute != null ) && ( !collectiveAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
        {
            at.setCollective( readBoolean( collectiveAttribute.getValue() ) );
        }

        // No User Modification
        Attribute noUserModificationAttribute = element.attribute( NO_USER_MODIFICATION_TAG );
        if ( ( noUserModificationAttribute != null ) && ( !noUserModificationAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
        {
            at.setUserModifiable( !readBoolean( noUserModificationAttribute.getValue() ) );
        }

        // Equality
        Element equalityElement = element.element( EQUALITY_TAG );
        if ( ( equalityElement != null ) && ( !equalityElement.getText().equals( "" ) ) ) //$NON-NLS-1$
        {
            at.setEqualityOid( equalityElement.getText() );
        }

        // Ordering
        Element orderingElement = element.element( ORDERING_TAG );
        if ( ( orderingElement != null ) && ( !orderingElement.getText().equals( "" ) ) ) //$NON-NLS-1$
        {
            at.setOrderingOid( orderingElement.getText() );
        }

        // Substring
        Element substringElement = element.element( SUBSTRING_TAG );
        if ( ( substringElement != null ) && ( !substringElement.getText().equals( "" ) ) ) //$NON-NLS-1$
        {
            at.setSubstringOid( substringElement.getText() );
        }

        // Adding the attribute type to the schema
        schema.addAttributeType( at );
    }
View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     * @return
     *      a clone of the given attribute type
     */
    public static MutableAttributeType getClone( AttributeType at )
    {
        MutableAttributeType clone = new MutableAttributeType( at.getOid() );
        clone.setNames( at.getNames() );
        clone.setSchemaName( at.getSchemaName() );
        clone.setDescription( at.getDescription() );
        clone.setSuperiorOid( at.getSuperiorOid() );
        clone.setUsage( at.getUsage() );
        clone.setSyntaxOid( at.getSyntaxOid() );
        clone.setSyntaxLength( at.getSyntaxLength() );
        clone.setObsolete( at.isObsolete() );
        clone.setSingleValued( at.isSingleValued() );
        clone.setCollective( at.isCollective() );
        clone.setUserModifiable( at.isUserModifiable() );
        clone.setEqualityOid( at.getEqualityOid() );
        clone.setOrderingOid( at.getOrderingOid() );
        clone.setSubstringOid( at.getSubstringOid() );

        return clone;
    }
View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     * @throws Exception
     */
    public void testAddEqualityDifference() throws Exception
    {
        AttributeType o1 = new AttributeType( "1.2.3.4" ); //$NON-NLS-1$
        MutableAttributeType o2 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o2.setEqualityOid( "Equality" ); //$NON-NLS-1$

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );

View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     * @throws Exception
     */
    public void testAddOrderingDifference() throws Exception
    {
        AttributeType o1 = new AttributeType( "1.2.3.4" ); //$NON-NLS-1$
        MutableAttributeType o2 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o2.setOrderingOid( "Ordering" ); //$NON-NLS-1$

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );

View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     * @throws Exception
     */
    public void testAddSubstringDifference() throws Exception
    {
        AttributeType o1 = new AttributeType( "1.2.3.4" ); //$NON-NLS-1$
        MutableAttributeType o2 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o2.setSubstringOid( "Substring" ); //$NON-NLS-1$

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );

View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     * @throws Exception
     */
    public void testAddSuperiorATDifference() throws Exception
    {
        AttributeType o1 = new AttributeType( "1.2.3.4" ); //$NON-NLS-1$
        MutableAttributeType o2 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o2.setSuperiorOid( "superiorAT" ); //$NON-NLS-1$

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );

View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     * @throws Exception
     */
    public void testAddSyntaxDifference() throws Exception
    {
        AttributeType o1 = new AttributeType( "1.2.3.4" ); //$NON-NLS-1$
        MutableAttributeType o2 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o2.setSyntaxOid( "1.2.3.4.5" ); //$NON-NLS-1$

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );

View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     * @throws Exception
     */
    public void testAddSyntaxLengthDifference() throws Exception
    {
        AttributeType o1 = new AttributeType( "1.2.3.4" ); //$NON-NLS-1$
        MutableAttributeType o2 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o2.setSyntaxLength( 1234 );

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );

View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     *
     * @throws Exception
     */
    public void testModifyCollectiveDifference() throws Exception
    {
        MutableAttributeType o1 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o1.setCollective( true );
        MutableAttributeType o2 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o2.setCollective( false );

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );

View Full Code Here

Examples of org.apache.directory.api.ldap.model.schema.MutableAttributeType

     *
     * @throws Exception
     */
    public void testModifyEqualityDifference() throws Exception
    {
        MutableAttributeType o1 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o1.setEqualityOid( "equalityName" ); //$NON-NLS-1$
        MutableAttributeType o2 = new MutableAttributeType( "1.2.3.4" ); //$NON-NLS-1$
        o2.setEqualityOid( "newEqualityName" ); //$NON-NLS-1$

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.