directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r641062 - in /directory/studio/trunk: connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/
Date Tue, 25 Mar 2008 22:49:21 GMT
Author: seelmann
Date: Tue Mar 25 15:49:16 2008
New Revision: 641062

URL: http://svn.apache.org/viewvc?rev=641062&view=rev
Log:
Fix for DIRSTUDIO-310: Adding all binary attributes to java.naming.ldap.attributes.binary
JNDI environment property

Modified:
    directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionListener.java

Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java?rev=641062&r1=641061&r2=641062&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
(original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
Tue Mar 25 15:49:16 2008
@@ -20,6 +20,7 @@
 package org.apache.directory.studio.connection.core.io.jndi;
 
 
+import java.util.Collection;
 import java.util.Hashtable;
 import java.util.List;
 
@@ -105,6 +106,8 @@
 
     private Thread jobThread;
 
+    private Collection<String> binaryAttributes;
+
     /** JNDI constant for "throw" referrals handling */
     public static final String REFERRAL_THROW = "throw";
 
@@ -223,6 +226,40 @@
 
 
     /**
+     * Sets the binary attributes.
+     * 
+     * @param binaryAttributes the binary attributes
+     */
+    public void setBinaryAttributes( Collection<String> binaryAttributes )
+    {
+        this.binaryAttributes = binaryAttributes;
+        String binaryAttributesString = "";
+        for ( String string : binaryAttributes )
+        {
+            binaryAttributesString += string + " ";
+        }
+
+        if ( environment != null )
+        {
+            environment.put( "java.naming.ldap.attributes.binary", binaryAttributesString
);
+        }
+
+        if ( context != null )
+        {
+            try
+            {
+                context.addToEnvironment( "java.naming.ldap.attributes.binary", binaryAttributesString
);
+            }
+            catch ( NamingException e )
+            {
+                // TODO: logging
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+    /**
      * Search.
      * 
      * @param searchBase the search base
@@ -376,7 +413,7 @@
         final ReferralHandlingMethod referralsHandlingMethod, final Control[] controls,
         final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
-        if( connection.isReadOnly() )
+        if ( connection.isReadOnly() )
         {
             monitor.reportError( "Connection '" + connection.getName() + "' is read only."
);
             return;
@@ -467,7 +504,7 @@
         final ReferralHandlingMethod referralsHandlingMethod, final Control[] controls,
         final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
-        if( connection.isReadOnly() )
+        if ( connection.isReadOnly() )
         {
             monitor.reportError( "Connection '" + connection.getName() + "' is read only."
);
             return;
@@ -567,7 +604,7 @@
         final ReferralHandlingMethod referralsHandlingMethod, final Control[] controls,
         final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
-        if( connection.isReadOnly() )
+        if ( connection.isReadOnly() )
         {
             monitor.reportError( "Connection '" + connection.getName() + "' is read only."
);
             return;
@@ -655,7 +692,7 @@
     public void deleteEntry( final String dn, final ReferralHandlingMethod referralsHandlingMethod,
         final Control[] controls, final StudioProgressMonitor monitor, final ReferralsInfo
referralsInfo )
     {
-        if( connection.isReadOnly() )
+        if ( connection.isReadOnly() )
         {
             monitor.reportError( "Connection '" + connection.getName() + "' is read only."
);
             return;
@@ -765,6 +802,11 @@
         else
         {
             environment.put( Context.PROVIDER_URL, "ldap://" + host + ":" + port ); //$NON-NLS-1$
//$NON-NLS-2$
+        }
+
+        if ( binaryAttributes != null )
+        {
+            setBinaryAttributes( binaryAttributes );
         }
 
         InnerRunnable runnable = new InnerRunnable()

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionListener.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionListener.java?rev=641062&r1=641061&r2=641062&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionListener.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionListener.java
Tue Mar 25 15:49:16 2008
@@ -21,7 +21,12 @@
 package org.apache.directory.studio.ldapbrowser.core;
 
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.syntax.AttributeTypeDescription;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.IConnectionListener;
 import org.apache.directory.studio.connection.core.StudioProgressMonitor;
@@ -39,6 +44,7 @@
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.Search;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
 
 
 /**
@@ -65,6 +71,7 @@
             {
                 EventRegistry.suspendEventFireingInCurrentThread();
                 openBrowserConnection( browserConnection, monitor );
+                setBinaryAttributes( browserConnection, monitor );
             }
             finally
             {
@@ -180,9 +187,34 @@
                 browserConnection.setSchema( Schema.DEFAULT_SCHEMA );
                 monitor.reportError( BrowserCoreMessages.model__error_loading_schema, e );
                 e.printStackTrace();
-                return;
             }
         }
+    }
+
+
+    /**
+     * Extracts the binary attributes from the schema and 
+     * sets the binary attributes to the underlying connection.
+     * 
+     * @param browserConnection the browser connection
+     * @param monitor the progress monitor
+     */
+    private static void setBinaryAttributes( IBrowserConnection browserConnection, StudioProgressMonitor
monitor )
+    {
+        List<String> binaryAttributeNames = new ArrayList<String>();
+
+        Schema schema = browserConnection.getSchema();
+        Collection<AttributeTypeDescription> attributeTypeDescriptions = schema.getAttributeTypeDescriptions();
+        for ( AttributeTypeDescription atd : attributeTypeDescriptions )
+        {
+            if ( SchemaUtils.isBinary( atd, schema ) )
+            {
+                String name = atd.getNames().isEmpty() ? atd.getNumericOid() : atd.getNames().get(
0 );
+                binaryAttributeNames.add( name );
+            }
+        }
+
+        browserConnection.getConnection().getJNDIConnectionWrapper().setBinaryAttributes(
binaryAttributeNames );
     }
 
 }



Mime
View raw message