Package org.apache.directory.studio.ldapbrowser.core.model

Examples of org.apache.directory.studio.ldapbrowser.core.model.IAttribute


                    AttributeHierarchy ah = entry.getAttributeWithSubtypes( ras[r] );
                    if ( ah != null )
                    {
                        for ( Iterator<IAttribute> it = ah.iterator(); it.hasNext(); )
                        {
                            IAttribute attribute = it.next();
                            entry.deleteAttribute( attribute );
                        }
                    }
                }
            }
            else
            {
                // clear all
                IAttribute[] oldAttributes = entry.getAttributes();
                for ( int i = 0; oldAttributes != null && i < oldAttributes.length; i++ )
                {
                    entry.deleteAttribute( oldAttributes[i] );
                }
            }

            // additional clear old attributes if the record contains the attribute
            NamingEnumeration<? extends Attribute> attributeEnumeration = sr.getAttributes().getAll();
            while ( attributeEnumeration.hasMore() )
            {
                Attribute attribute = attributeEnumeration.next();
                String attributeDescription = attribute.getID();
                IAttribute oldAttribute = entry.getAttribute( attributeDescription );
                if ( oldAttribute != null )
                {
                    entry.deleteAttribute( oldAttribute );
                }
            }

            // set new attributes and values
            attributeEnumeration = sr.getAttributes().getAll();
            while ( attributeEnumeration.hasMore() )
            {
                Attribute attribute = attributeEnumeration.next();
                String attributeDescription = attribute.getID();

                if ( attribute.getAll().hasMore() )
                {
                    IAttribute studioAttribute = null;
                    if ( entry.getAttribute( attributeDescription ) == null )
                    {
                        studioAttribute = new org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute( entry,
                            attributeDescription );
                        entry.addAttribute( studioAttribute );
                    }
                    else
                    {
                        studioAttribute = entry.getAttribute( attributeDescription );
                    }

                    NamingEnumeration<?> valueEnumeration = attribute.getAll();
                    while ( valueEnumeration.hasMore() )
                    {
                        Object value = valueEnumeration.next();
                        studioAttribute.addValue( new Value( studioAttribute, value ) );
                    }
                }
            }
        }
    }
View Full Code Here


     *
     * @return the attribute values
     */
    private String[] getAttributeValues( String attributeDescription )
    {
        IAttribute supportedFeaturesAttr = getAttribute( attributeDescription );
        if ( supportedFeaturesAttr != null )
        {
            String[] stringValues = supportedFeaturesAttr.getStringValues();
            Arrays.sort( stringValues );
            return stringValues;
        }
        else
        {
View Full Code Here

        }
        else
        {
            // get base DNs from namingContexts attribute
            Set<String> namingContextSet = new HashSet<String>();
            IAttribute attribute = browserConnection.getRootDSE().getAttribute( SchemaConstants.NAMING_CONTEXTS_AT );
            if ( attribute != null )
            {
                String[] values = attribute.getStringValues();
                for ( int i = 0; i < values.length; i++ )
                {
                    namingContextSet.add( values[i] );
                }
            }

            if ( !namingContextSet.isEmpty() )
            {
                for ( String namingContext : namingContextSet )
                {
                    if ( namingContext.length() > 0 && namingContext.charAt( namingContext.length() - 1 ) == '\u0000' )
                    {
                        namingContext = namingContext.substring( 0, namingContext.length() - 1 );
                    }

                    if ( !"".equals( namingContext ) ) //$NON-NLS-1$
                    {
                        try
                        {
                            LdapDN dn = new LdapDN( namingContext );
                            IEntry entry = browserConnection.getEntryFromCache( dn );
                            if ( entry == null )
                            {
                                entry = new BaseDNEntry( dn, browserConnection );
                                browserConnection.cacheEntry( entry );
                            }
                            rootDseEntries.put( dn, entry );
                        }
                        catch ( InvalidNameException e )
                        {
                            monitor.reportError( BrowserCoreMessages.model__error_setting_base_dn, e );
                        }
                    }
                    else
                    {
                        // special handling of empty namingContext (Novell eDirectory):
                        // perform a one-level search and add all result DNs to the set
                        searchRootDseEntries( browserConnection, rootDseEntries, monitor );
                    }
                }
            }
            else
            {
                // special handling of non-existing namingContexts attribute (Oracle Internet Directory)
                // perform a one-level search and add all result DNs to the set
                searchRootDseEntries( browserConnection, rootDseEntries, monitor );
            }
        }

        // 2nd: add schema sub-entry
        IEntry[] schemaEntries = getDirectoryMetadataEntries( browserConnection, SchemaConstants.SUBSCHEMA_SUBENTRY_AT );
        for ( IEntry entry : schemaEntries )
        {
            if ( entry instanceof DirectoryMetadataEntry )
            {
                ( ( DirectoryMetadataEntry ) entry ).setSchemaEntry( true );
            }
            rootDseEntries.put( entry.getDn(), entry );
        }

        // get other meta data entries
        IAttribute[] rootDseAttributes = browserConnection.getRootDSE().getAttributes();
        if ( rootDseAttributes != null )
        {
            for ( IAttribute attribute : rootDseAttributes )
            {
                IEntry[] metadataEntries = getDirectoryMetadataEntries( browserConnection, attribute.getDescription() );
                for ( IEntry entry : metadataEntries )
                {
                    rootDseEntries.put( entry.getDn(), entry );
                }
            }
View Full Code Here

    private static IEntry[] getDirectoryMetadataEntries( IBrowserConnection browserConnection,
        String metadataAttributeName )
    {
        List<LdapDN> metadataEntryDnList = new ArrayList<LdapDN>();
        IAttribute attribute = browserConnection.getRootDSE().getAttribute( metadataAttributeName );
        if ( attribute != null )
        {
            String[] values = attribute.getStringValues();
            for ( String dn : values )
            {
                if ( dn != null && !"".equals( dn ) )
                {
                    try
View Full Code Here

        orderingMatchingRuleText = BaseWidgetUtils.createLabeledText( matchingComposite, "", 1 ); //$NON-NLS-1$
        GridData orderingMatchingRuleTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false );
        orderingMatchingRuleTextGridData.widthHint = 300;
        orderingMatchingRuleText.setLayoutData( orderingMatchingRuleTextGridData );

        IAttribute attribute = getAttribute( getElement() );
        if ( attribute != null )
        {
            Schema schema = attribute.getEntry().getBrowserConnection().getSchema();

            int bytes = 0;
            int valCount = 0;
            IValue[] allValues = attribute.getValues();
            for ( int valIndex = 0; valIndex < allValues.length; valIndex++ )
            {
                if ( !allValues[valIndex].isEmpty() )
                {
                    valCount++;
                    bytes += allValues[valIndex].getBinaryValue().length;
                }
            }

            this.setMessage( NLS.bind(
                Messages.getString( "AttributePropertyPage.Attribute" ), new String[] { attribute.getDescription() } ) ); //$NON-NLS-1$
            attributeNameText.setText( attribute.getDescription() );
            attributeTypeText.setText( attribute.isString() ? "String" : "Binary" ); //$NON-NLS-1$ //$NON-NLS-2$
            attributeValuesText.setText( "" + valCount ); //$NON-NLS-1$
            attributeSizeText.setText( Utils.formatBytes( bytes ) );

            if ( schema.hasAttributeTypeDescription( attribute.getDescription() ) )
            {
                AttributeTypeDescription atd = schema.getAttributeTypeDescription( attribute.getDescription() );

                atdOidText.setText( atd.getNumericOid() );
                String atdNames = atd.getNames().toString();
                atdNamesText.setText( atdNames.substring( 1, atdNames.length() - 1 ) );
                atdDescText.setText( Utils.getNonNullString( atd.getDescription() ) );
View Full Code Here

     *
     * @return the attribute
     */
    private static IAttribute getAttribute( Object element )
    {
        IAttribute attribute = null;
        if ( element instanceof IAdaptable )
        {
            attribute = ( IAttribute ) ( ( IAdaptable ) element ).getAdapter( IAttribute.class );
        }
        return attribute;
View Full Code Here

     */
    private String detectByVendorName( IRootDSE rootDSE )
    {
        String result = null;

        IAttribute vnAttribute = rootDSE.getAttribute( "vendorName" ); //$NON-NLS-1$
        IAttribute vvAttribute = rootDSE.getAttribute( "vendorVersion" ); //$NON-NLS-1$

        if ( vnAttribute != null && vnAttribute.getStringValues().length > 0 && vvAttribute != null
            && vvAttribute.getStringValues().length > 0 )
        {

            String vendorName = vnAttribute.getStringValues()[0];
            String vendorVersion = vvAttribute.getStringValues()[0];

            if ( vendorName.indexOf( "Apache Software Foundation" ) > -1 ) //$NON-NLS-1$
            {
                result = Messages.getString( "RootDSEPropertyPage.ApacheDirectoryServer" ); //$NON-NLS-1$
            }
View Full Code Here

    private String detectActiveDirectory( IRootDSE rootDSE )
    {
        String result = null;

        // check active directory
        IAttribute rdncAttribute = rootDSE.getAttribute( "rootDomainNamingContext" ); //$NON-NLS-1$
        if ( rdncAttribute != null )
        {
            IAttribute ffAttribute = rootDSE.getAttribute( "forestFunctionality" ); //$NON-NLS-1$
            if ( ffAttribute != null )
            {
                result = Messages.getString( "RootDSEPropertyPage.MSAD2003" ); //$NON-NLS-1$
            }
            else
View Full Code Here

     */
    private String detectSiemensDirX( IRootDSE rootDSE )
    {
        String result = null;

        IAttribute ssseAttribute = rootDSE.getAttribute( "subSchemaSubentry" ); //$NON-NLS-1$
        if ( ssseAttribute != null )
        {
            for ( int i = 0; i < ssseAttribute.getStringValues().length; i++ )
            {
                if ( "cn=LDAPGlobalSchemaSubentry".equals( ssseAttribute.getStringValues()[i] ) ) //$NON-NLS-1$
                {
                    result = Messages.getString( "RootDSEPropertyPage.SiemesDirX" ); //$NON-NLS-1$
                }
            }
        }
View Full Code Here

    {
        String result = null;
        boolean typeDetected = false;

        // check OpenLDAP
        IAttribute ocAttribute = rootDSE.getAttribute( "objectClass" ); //$NON-NLS-1$
        if ( ocAttribute != null )
        {
            for ( int i = 0; i < ocAttribute.getStringValues().length; i++ )
            {
                if ( "OpenLDAProotDSE".equals( ocAttribute.getStringValues()[i] ) ) //$NON-NLS-1$
                {
                    IAttribute ccAttribute = rootDSE.getAttribute( "configContext" ); //$NON-NLS-1$
                    if ( ccAttribute != null )
                    {
                        result = Messages.getString( "RootDSEPropertyPage.openLDAP23" ); //$NON-NLS-1$
                        typeDetected = true;
                    }
                    if ( !typeDetected )
                    {
                        IAttribute scAttribute = rootDSE.getAttribute( "supportedControl" ); //$NON-NLS-1$
                        if ( scAttribute != null )
                        {
                            for ( int sci = 0; sci < scAttribute.getStringValues().length; sci++ )
                            {
                                // if("1.2.840.113556.1.4.319".equals(scAttribute.getStringValues()[sci]))
                                // {
                                if ( "2.16.840.1.113730.3.4.18".equals( scAttribute.getStringValues()[sci] ) ) //$NON-NLS-1$
                                {
                                    result = Messages.getString( "RootDSEPropertyPage.OpenLDAP22" ); //$NON-NLS-1$
                                    typeDetected = true;
                                }
                            }
                        }

                    }
                    if ( !typeDetected )
                    {
                        IAttribute seAttribute = rootDSE.getAttribute( "supportedExtension" ); //$NON-NLS-1$
                        if ( seAttribute != null )
                        {
                            for ( int sei = 0; sei < seAttribute.getStringValues().length; sei++ )
                            {
                                if ( "1.3.6.1.4.1.4203.1.11.3".equals( seAttribute.getStringValues()[sei] ) ) //$NON-NLS-1$
                                {
                                    result = Messages.getString( "RootDSEPropertyPage.OpenLDAP21" ); //$NON-NLS-1$
                                    typeDetected = true;
                                }
                            }
                        }
                    }
                    if ( !typeDetected )
                    {
                        IAttribute sfAttribute = rootDSE.getAttribute( "supportedFeatures" ); //$NON-NLS-1$
                        if ( sfAttribute != null )
                        {
                            for ( int sfi = 0; sfi < sfAttribute.getStringValues().length; sfi++ )
                            {
                                if ( "1.3.6.1.4.1.4203.1.5.4".equals( sfAttribute.getStringValues()[sfi] ) ) //$NON-NLS-1$
                                {
                                    result = Messages.getString( "RootDSEPropertyPage.OpenLDAP20" ); //$NON-NLS-1$
                                    typeDetected = true;
                                }
                            }
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.ldapbrowser.core.model.IAttribute

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.