directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r615363 - in /directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core: jobs/InitializeAttributesJob.java jobs/SearchJob.java model/IRootDSE.java model/impl/RootDSE.java
Date Fri, 25 Jan 2008 21:56:13 GMT
Author: seelmann
Date: Fri Jan 25 13:56:12 2008
New Revision: 615363

URL: http://svn.apache.org/viewvc?rev=615363&view=rev
Log:
Fix for DIRSTUDIO-269

Modified:
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IRootDSE.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/RootDSE.java

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesJob.java?rev=615363&r1=615362&r2=615363&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesJob.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeAttributesJob.java
Fri Jan 25 13:56:12 2008
@@ -73,8 +73,7 @@
             IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDLDAPVERSION, IRootDSE.ROOTDSE_ATTRIBUTE_SUBSCHEMASUBENTRY,
             IRootDSE.ROOTDSE_ATTRIBUTE_ALTSERVER, IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDEXTENSION,
             IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDCONTROL, IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDFEATURES,
-            IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDSASLMECHANISM, ISearch.ALL_OPERATIONAL_ATTRIBUTES,
-            ISearch.ALL_USER_ATTRIBUTES };
+            IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDSASLMECHANISM, ISearch.ALL_OPERATIONAL_ATTRIBUTES
};
 
 
     /**
@@ -182,7 +181,11 @@
                 .getBrowserConnection().getSchema() );
             String[] attributeTypeDescriptionNames = SchemaUtils.getAttributeTypeDescriptionNames(
opAtds );
             raSet.addAll( Arrays.asList( attributeTypeDescriptionNames ) );
-            raSet.add( ISearch.ALL_OPERATIONAL_ATTRIBUTES );
+            if ( entry.getBrowserConnection().getRootDSE().isFeatureSupported(
+                IRootDSE.FEATURE_ALL_OPERATIONAL_ATTRIBUTES_OID ) )
+            {
+                raSet.add( ISearch.ALL_OPERATIONAL_ATTRIBUTES );
+            }
         }
         if ( entry.isReferral() )
         {
@@ -213,25 +216,25 @@
         {
             // special handling for Root DSE
             loadRootDSE( entry.getBrowserConnection(), monitor );
-            
-        	entry.setAttributesInitialized( true );
-        	entry.setChildrenInitialized( true );
+
+            entry.setAttributesInitialized( true );
+            entry.setChildrenInitialized( true );
         }
         else
         {
-	        // search
+            // search
             ISearch search = new Search( null, entry.getBrowserConnection(), entry.getDn(),
                 entry.isSubentry() ? ISearch.FILTER_SUBENTRY : ISearch.FILTER_TRUE, attributes,
SearchScope.OBJECT, 0,
                 0, entry.getBrowserConnection().getAliasesDereferencingMethod(), entry.getBrowserConnection()
                     .getReferralsHandlingMethod(), false, null );
             SearchJob.searchAndUpdateModel( entry.getBrowserConnection(), search, monitor
);
-	
-	        // set initialized state
-	        entry.setAttributesInitialized( true );
+
+            // set initialized state
+            entry.setAttributesInitialized( true );
         }
     }
 
-    
+
     /**
      * Loads the Root DSE.
      * 
@@ -244,7 +247,7 @@
     {
         // delete old children
         IEntry[] oldChildren = browserConnection.getRootDSE().getChildren();
-        if(oldChildren != null)
+        if ( oldChildren != null )
         {
             for ( IEntry entry : oldChildren )
             {
@@ -256,24 +259,31 @@
         }
         browserConnection.getRootDSE().setChildrenInitialized( false );
 
-        // load well-known Root DSE attributes, includes + and *
-        ISearch search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE,
-            InitializeAttributesJob.ROOT_DSE_ATTRIBUTES, SearchScope.OBJECT, 0, 0, Connection.AliasDereferencingMethod.NEVER,
+        // load all user attributes
+        ISearch search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE,
new String[]
+            { ISearch.ALL_USER_ATTRIBUTES }, SearchScope.OBJECT, 0, 0, Connection.AliasDereferencingMethod.NEVER,
+            Connection.ReferralHandlingMethod.IGNORE, false, null );
+        SearchJob.searchAndUpdateModel( browserConnection, search, monitor );
+
+        // load well-known Root DSE attributes and operational attributes
+        search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE,
ROOT_DSE_ATTRIBUTES,
+            SearchScope.OBJECT, 0, 0, Connection.AliasDereferencingMethod.NEVER,
             Connection.ReferralHandlingMethod.IGNORE, false, null );
         SearchJob.searchAndUpdateModel( browserConnection, search, monitor );
 
         // the list of entries under the Root DSE
         Map<LdapDN, IEntry> rootDseEntries = new HashMap<LdapDN, IEntry>();
-        
+
         // 1st: add base DNs, either the specified or from the namingContexts attribute
-        if( !browserConnection.isFetchBaseDNs() && browserConnection.getBaseDN()
!= null && !"".equals( browserConnection.getBaseDN().toString() ))
+        if ( !browserConnection.isFetchBaseDNs() && browserConnection.getBaseDN()
!= null
+            && !"".equals( browserConnection.getBaseDN().toString() ) )
         {
             // only add the specified base DN
             try
             {
                 LdapDN dn = browserConnection.getBaseDN();
                 IEntry entry = browserConnection.getEntryFromCache( dn );
-                if(entry == null)
+                if ( entry == null )
                 {
                     entry = new BaseDNEntry( new LdapDN( dn ), browserConnection );
                     browserConnection.cacheEntry( entry );
@@ -289,7 +299,8 @@
         {
             // get base DNs from namingContexts attribute
             Set<String> namingContextSet = new HashSet<String>();
-            IAttribute attribute = browserConnection.getRootDSE().getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_NAMINGCONTEXTS
);
+            IAttribute attribute = browserConnection.getRootDSE().getAttribute(
+                IRootDSE.ROOTDSE_ATTRIBUTE_NAMINGCONTEXTS );
             if ( attribute != null )
             {
                 String[] values = attribute.getStringValues();
@@ -305,7 +316,7 @@
                     {
                         LdapDN dn = new LdapDN( namingContext );
                         IEntry entry = browserConnection.getEntryFromCache( dn );
-                        if(entry == null)
+                        if ( entry == null )
                         {
                             entry = new BaseDNEntry( new LdapDN( dn ), browserConnection
);
                             browserConnection.cacheEntry( entry );
@@ -346,7 +357,7 @@
             }
             rootDseEntries.put( entry.getDn(), entry );
         }
-        
+
         // get other meta data entries
         IAttribute[] rootDseAttributes = browserConnection.getRootDSE().getAttributes();
         if ( rootDseAttributes != null )
@@ -360,7 +371,7 @@
                 }
             }
         }
-        
+
         // try to init entries
         StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
         for ( IEntry entry : rootDseEntries.values() )
@@ -368,7 +379,7 @@
             initBaseEntry( entry.getBrowserConnection(), entry.getDn(), dummyMonitor );
             // TODO: log if a base entry doesn't exist
         }
-        
+
         // set flags
         browserConnection.getRootDSE().setHasMoreChildren( false );
         browserConnection.getRootDSE().setAttributesInitialized( true );
@@ -388,10 +399,10 @@
         search = new Search( null, browserConnection, dn, ISearch.FILTER_TRUE, ISearch.NO_ATTRIBUTES,
             SearchScope.OBJECT, 1, 0, derefAliasMethod, handleReferralsMethod, true, null
);
         SearchJob.searchAndUpdateModel( browserConnection, search, monitor );
-        
+
         // add entry to Root DSE
         ISearchResult[] results = search.getSearchResults();
-        if(results != null && results.length == 1)
+        if ( results != null && results.length == 1 )
         {
             ISearchResult result = results[0];
             entry = result.getEntry();
@@ -400,7 +411,8 @@
     }
 
 
-    private static IEntry[] getDirectoryMetadataEntries( IBrowserConnection browserConnection,
String metadataAttributeName )
+    private static IEntry[] getDirectoryMetadataEntries( IBrowserConnection browserConnection,
+        String metadataAttributeName )
     {
         List<LdapDN> metadataEntryDnList = new ArrayList<LdapDN>();
         IAttribute attribute = browserConnection.getRootDSE().getAttribute( metadataAttributeName
);
@@ -409,7 +421,7 @@
             String[] values = attribute.getStringValues();
             for ( String dn : values )
             {
-                if( dn != null && !"".equals( dn ))
+                if ( dn != null && !"".equals( dn ) )
                 {
                     try
                     {
@@ -427,7 +439,7 @@
         {
             LdapDN dn = metadataEntryDnList.get( i );
             metadataEntries[i] = browserConnection.getEntryFromCache( dn );
-            if(metadataEntries[i] == null)
+            if ( metadataEntries[i] == null )
             {
                 metadataEntries[i] = new DirectoryMetadataEntry( dn, browserConnection );
                 metadataEntries[i].setDirectoryEntry( true );

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java?rev=615363&r1=615362&r2=615363&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchJob.java
Fri Jan 25 13:56:12 2008
@@ -181,7 +181,7 @@
             }
             return;
         }
-        
+
         try
         {
             if ( !monitor.isCanceled() )
@@ -205,13 +205,13 @@
                         if ( sr instanceof StudioSearchResult )
                         {
                             StudioSearchResult ssr = ( StudioSearchResult ) sr;
-                            
+
                             isReferral = ssr.isReferral();
-                            
+
                             Connection connection = ssr.getConnection();
                             IBrowserConnection bc = BrowserCorePlugin.getDefault().getConnectionManager()
                                 .getBrowserConnection( connection );
-                            if( bc != null )
+                            if ( bc != null )
                             {
                                 resultBrowserConnection = bc;
                             }
@@ -223,18 +223,18 @@
                         {
                             entry = createAndCacheEntry( resultBrowserConnection, dn );
                         }
-                        
+
                         // initialize special flags
                         initFlags( entry, sr, searchParameter );
 
                         // fill the attributes
                         fillAttributes( entry, sr, search.getSearchParameter() );
-                        
-                        if ( isReferral  )
+
+                        if ( isReferral )
                         {
                             entry = new ReferralBaseEntry( resultBrowserConnection, dn );
                         }
-                        
+
                         searchResultList.add( new org.apache.directory.studio.ldapbrowser.core.model.impl.SearchResult(
                             entry, search ) );
 
@@ -317,7 +317,8 @@
         }
 
         NamingEnumeration<SearchResult> result = browserConnection.getConnection().getJNDIConnectionWrapper().search(
-            searchBase, filter, controls, aliasesDereferencingMethod, referralsHandlingMethod,
ldapControls, monitor, null );
+            searchBase, filter, controls, aliasesDereferencingMethod, referralsHandlingMethod,
ldapControls, monitor,
+            null );
         return result;
     }
 
@@ -363,41 +364,15 @@
                 searchParameter.setReturningAttributes( returningAttributes );
             }
         }
-//
-//        // to init the alias/referral flag we need the objectClass
-//        if ( search.isInitAliasAndReferralFlag() )
-//        {
-//            if ( !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes()
),
-//                IAttribute.OBJECTCLASS_ATTRIBUTE ) )
-//            {
-//                String[] returningAttributes = new String[searchParameter.getReturningAttributes().length
+ 1];
-//                System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes,
0, searchParameter
-//                    .getReturningAttributes().length );
-//                returningAttributes[returningAttributes.length - 1] = IAttribute.OBJECTCLASS_ATTRIBUTE;
-//                searchParameter.setReturningAttributes( returningAttributes );
-//            }
-//        }
-//
-//        // if returning attributes are requested but objectClass isn't included then add
it
-//        if ( search.getReturningAttributes() == null || search.getReturningAttributes().length
> 0 )
-//        {
-//            if ( !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes()
),
-//                IAttribute.OBJECTCLASS_ATTRIBUTE ) )
-//            {
-//                String[] returningAttributes = new String[searchParameter.getReturningAttributes().length
+ 1];
-//                System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes,
0, searchParameter
-//                    .getReturningAttributes().length );
-//                returningAttributes[returningAttributes.length - 1] = IAttribute.OBJECTCLASS_ATTRIBUTE;
-//                searchParameter.setReturningAttributes( returningAttributes );
-//            }
-//        }
-        
+
         // always add the objectClass attribute, we need it  
         // - to detect alias and referral entries
         // - to determine the entry's icon
         // - to determine must and may attributes
         if ( !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes()
),
-            IAttribute.OBJECTCLASS_ATTRIBUTE ) )
+            IAttribute.OBJECTCLASS_ATTRIBUTE )
+            && !Utils.containsIgnoreCase( Arrays.asList( searchParameter.getReturningAttributes()
),
+                ISearch.ALL_USER_ATTRIBUTES ) )
         {
             String[] returningAttributes = new String[searchParameter.getReturningAttributes().length
+ 1];
             System.arraycopy( searchParameter.getReturningAttributes(), 0, returningAttributes,
0, searchParameter

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IRootDSE.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IRootDSE.java?rev=615363&r1=615362&r2=615363&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IRootDSE.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IRootDSE.java
Fri Jan 25 13:56:12 2008
@@ -63,6 +63,9 @@
     /** The supportedSASLMechanisms attribute */
     public static final String ROOTDSE_ATTRIBUTE_SUPPORTEDSASLMECHANISM = "supportedSASLMechanisms";
//$NON-NLS-1$
 
+    /** The OID of feature 'All Operational Attributes' */
+    public static final String FEATURE_ALL_OPERATIONAL_ATTRIBUTES_OID = "1.3.6.1.4.1.4203.1.5.1";
//$NON-NLS-1$
+
 
     /**
      * Gets the supported extensions.
@@ -88,7 +91,6 @@
     public String[] getSupportedFeatures();
 
 
-    
     /**
      * Checks if control is supported.
      * 
@@ -97,5 +99,15 @@
      * @return true, if control is supported
      */
     public boolean isControlSupported( String oid );
+
+
+    /**
+     * Checks if feature is supported.
+     * 
+     * @param oid the OID
+     * 
+     * @return true, if feature is supported
+     */
+    public boolean isFeatureSupported( String oid );
 
 }

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/RootDSE.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/RootDSE.java?rev=615363&r1=615362&r2=615363&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/RootDSE.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/RootDSE.java
Fri Jan 25 13:56:12 2008
@@ -124,7 +124,8 @@
     {
         return false;
     }
-    
+
+
     /**
      * @see org.apache.directory.studio.ldapbrowser.core.model.IRootDSE#isControlSupported(java.lang.String)
      */
@@ -132,6 +133,16 @@
     {
         String[] supportedControls = getSupportedControls();
         return Arrays.asList( supportedControls ).contains( oid );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.model.IRootDSE#isFeatureSupported(java.lang.String)
+     */
+    public boolean isFeatureSupported( String oid )
+    {
+        String[] supportedFeatures = getSupportedFeatures();
+        return Arrays.asList( supportedFeatures ).contains( oid );
     }
 
 }



Mime
View raw message