directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1025611 - in /directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core: ./ io/ io/api/ io/jndi/
Date Wed, 20 Oct 2010 15:08:38 GMT
Author: pamarcelot
Date: Wed Oct 20 15:08:38 2010
New Revision: 1025611

URL: http://svn.apache.org/viewvc?rev=1025611&view=rev
Log:
o Moved the getReferralConnection(...) method in a helper since it's now shared between the
JNDI and Directory API connection wrappers.
o Added support for "read-only" connections in the Directory API connection wrapper.

Added:
    directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionWrapperUtils.java
Modified:
    directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
    directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/CursorStudioNamingEnumeration.java
    directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
    directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
    directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JndiStudioNamingEnumeration.java

Modified: directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java?rev=1025611&r1=1025610&r2=1025611&view=diff
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
(original)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/Connection.java
Wed Oct 20 15:08:38 2010
@@ -39,7 +39,6 @@ import org.eclipse.core.runtime.IAdaptab
  */
 public class Connection implements ConnectionPropertyPageProvider, IAdaptable
 {
-
     /**
      * Enum for alias dereferencing method.
      * 
@@ -47,7 +46,6 @@ public class Connection implements Conne
      */
     public static enum AliasDereferencingMethod
     {
-
         /** Never. */
         NEVER(0),
 
@@ -112,7 +110,6 @@ public class Connection implements Conne
      */
     public static enum ReferralHandlingMethod
     {
-
         /** Ignore. */
         IGNORE(0),
 

Added: directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionWrapperUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionWrapperUtils.java?rev=1025611&view=auto
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionWrapperUtils.java
(added)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionWrapperUtils.java
Wed Oct 20 15:08:38 2010
@@ -0,0 +1,73 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.connection.core.io;
+
+
+import java.util.ArrayList;
+
+import org.apache.directory.shared.ldap.message.Referral;
+import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.apache.directory.studio.connection.core.IConnectionListener;
+import org.apache.directory.studio.connection.core.IReferralHandler;
+import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
+
+
+/**
+ * Connection wrapper helper class. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ConnectionWrapperUtils
+{
+    /**
+     * Gets the referral connection from the given URL.
+     * 
+     * @param url the URL
+     * @param monitor the progress monitor
+     * @param source the source
+     * 
+     * @return the referral connection
+     */
+    public static Connection getReferralConnection( Referral referral, StudioProgressMonitor
monitor, Object source )
+    {
+        Connection referralConnection = null;
+        IReferralHandler referralHandler = ConnectionCorePlugin.getDefault().getReferralHandler();
+        if ( referralHandler != null )
+        {
+            referralConnection = referralHandler
+                .getReferralConnection( new ArrayList<String>( referral.getLdapUrls()
) );
+
+            // open connection if not yet open
+            if ( referralConnection != null && !referralConnection.getConnectionWrapper().isConnected()
)
+            {
+                referralConnection.getConnectionWrapper().connect( monitor );
+                referralConnection.getConnectionWrapper().bind( monitor );
+                for ( IConnectionListener listener : ConnectionCorePlugin.getDefault().getConnectionListeners()
)
+                {
+                    listener.connectionOpened( referralConnection, monitor );
+                }
+                ConnectionEventRegistry.fireConnectionOpened( referralConnection, source
);
+            }
+        }
+        return referralConnection;
+    }
+}

Modified: directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/CursorStudioNamingEnumeration.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/CursorStudioNamingEnumeration.java?rev=1025611&r1=1025610&r2=1025611&view=diff
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/CursorStudioNamingEnumeration.java
(original)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/CursorStudioNamingEnumeration.java
Wed Oct 20 15:08:38 2010
@@ -41,8 +41,8 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
 import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
 import org.apache.directory.studio.connection.core.io.AbstractStudioNamingEnumeration;
+import org.apache.directory.studio.connection.core.io.ConnectionWrapperUtils;
 import org.apache.directory.studio.connection.core.io.StudioNamingEnumeration;
-import org.apache.directory.studio.connection.core.io.jndi.JNDIConnectionWrapper;
 import org.apache.directory.studio.connection.core.io.jndi.ReferralsInfo;
 import org.apache.directory.studio.connection.core.io.jndi.StudioSearchResult;
 
@@ -182,7 +182,7 @@ public class CursorStudioNamingEnumerati
                     List<String> referralUrls = new ArrayList<String>( referral.getLdapUrls()
);
                     LdapURL url = new LdapURL( referralUrls.get( 0 ) );
 
-                    Connection referralConnection = JNDIConnectionWrapper.getReferralConnection(
referral, monitor,
+                    Connection referralConnection = ConnectionWrapperUtils.getReferralConnection(
referral, monitor,
                         this );
                     if ( referralConnection != null )
                     {

Modified: directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java?rev=1025611&r1=1025610&r2=1025611&view=diff
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
(original)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
Wed Oct 20 15:08:38 2010
@@ -55,12 +55,14 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.Messages;
 import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
 import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
 import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
 import org.apache.directory.studio.connection.core.io.ConnectionWrapper;
 import org.apache.directory.studio.connection.core.io.StudioNamingEnumeration;
 import org.apache.directory.studio.connection.core.io.jndi.ReferralsInfo;
+import org.eclipse.osgi.util.NLS;
 
 
 /**
@@ -336,6 +338,12 @@ public class DirectoryApiConnectionWrapp
     public void modifyEntry( final String dn, final ModificationItem[] modificationItems,
final Control[] controls,
         final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
+        if ( connection.isReadOnly() )
+        {
+            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            return;
+        }
+
         try
         {
             // Preparing the modify request
@@ -425,6 +433,12 @@ public class DirectoryApiConnectionWrapp
     public void renameEntry( final String oldDn, final String newDn, final boolean deleteOldRdn,
         final Control[] controls, final StudioProgressMonitor monitor, final ReferralsInfo
referralsInfo )
     {
+        if ( connection.isReadOnly() )
+        {
+            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            return;
+        }
+
         try
         {
             // Preparing the rename request
@@ -452,6 +466,12 @@ public class DirectoryApiConnectionWrapp
     public void createEntry( final String dn, final Attributes attributes, final Control[]
controls,
         final StudioProgressMonitor monitor, final ReferralsInfo referralsInfo )
     {
+        if ( connection.isReadOnly() )
+        {
+            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            return;
+        }
+
         try
         {
             // Preparing the add request
@@ -476,6 +496,12 @@ public class DirectoryApiConnectionWrapp
     public void deleteEntry( final String dn, final Control[] controls, final StudioProgressMonitor
monitor,
         final ReferralsInfo referralsInfo )
     {
+        if ( connection.isReadOnly() )
+        {
+            monitor.reportError( NLS.bind( Messages.error__connection_is_readonly, connection.getName()
) );
+            return;
+        }
+
         try
         {
             // Preparing the delete request

Modified: directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java?rev=1025611&r1=1025610&r2=1025611&view=diff
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
(original)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
Wed Oct 20 15:08:38 2010
@@ -87,6 +87,7 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.Utils;
 import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
 import org.apache.directory.studio.connection.core.io.ConnectionWrapper;
+import org.apache.directory.studio.connection.core.io.ConnectionWrapperUtils;
 import org.eclipse.core.runtime.Preferences;
 import org.eclipse.osgi.util.NLS;
 
@@ -355,7 +356,8 @@ public class JNDIConnectionWrapper imple
                     // perform the search
                     NamingEnumeration<SearchResult> result = searchCtx.search( JNDIConnectionWrapper
                         .getSaveJndiName( searchBase ), filter, searchControls );
-                    namingEnumeration = new JndiStudioNamingEnumeration( connection, searchCtx,
result, null, searchBase,
+                    namingEnumeration = new JndiStudioNamingEnumeration( connection, searchCtx,
result, null,
+                        searchBase,
                         filter, searchControls, aliasesDereferencingMethod, referralsHandlingMethod,
controls,
                         requestNum, monitor, referralsInfo );
                 }
@@ -462,7 +464,8 @@ public class JNDIConnectionWrapper imple
                         Referral referral = newReferralsInfo.getNextReferral();
                         if ( referral != null )
                         {
-                            Connection referralConnection = getReferralConnection( referral,
monitor, this );
+                            Connection referralConnection = ConnectionWrapperUtils.getReferralConnection(
referral,
+                                monitor, this );
                             if ( referralConnection != null )
                             {
                                 List<String> urls = new ArrayList<String>( referral.getLdapUrls()
);
@@ -577,7 +580,8 @@ public class JNDIConnectionWrapper imple
                         Referral referral = newReferralsInfo.getNextReferral();
                         if ( referral != null )
                         {
-                            Connection referralConnection = getReferralConnection( referral,
monitor, this );
+                            Connection referralConnection = ConnectionWrapperUtils.getReferralConnection(
referral,
+                                monitor, this );
                             if ( referralConnection != null )
                             {
                                 referralConnection.getConnectionWrapper().renameEntry( oldDn,
newDn, deleteOldRdn,
@@ -672,7 +676,8 @@ public class JNDIConnectionWrapper imple
                         Referral referral = newReferralsInfo.getNextReferral();
                         if ( referral != null )
                         {
-                            Connection referralConnection = getReferralConnection( referral,
monitor, this );
+                            Connection referralConnection = ConnectionWrapperUtils.getReferralConnection(
referral,
+                                monitor, this );
                             if ( referralConnection != null )
                             {
                                 List<String> urls = new ArrayList<String>( referral.getLdapUrls()
);
@@ -773,7 +778,8 @@ public class JNDIConnectionWrapper imple
                         Referral referral = newReferralsInfo.getNextReferral();
                         if ( referral != null )
                         {
-                            Connection referralConnection = getReferralConnection( referral,
monitor, this );
+                            Connection referralConnection = ConnectionWrapperUtils.getReferralConnection(
referral,
+                                monitor, this );
                             if ( referralConnection != null )
                             {
                                 List<String> urls = new ArrayList<String>( referral.getLdapUrls()
);
@@ -1510,40 +1516,6 @@ public class JNDIConnectionWrapper imple
 
 
     /**
-     * Gets the referral connection from the given URL.
-     * 
-     * @param url the URL
-     * @param monitor the progress monitor
-     * @param source the source
-     * 
-     * @return the referral connection
-     */
-    public static Connection getReferralConnection( Referral referral, StudioProgressMonitor
monitor, Object source )
-    {
-        Connection referralConnection = null;
-        IReferralHandler referralHandler = ConnectionCorePlugin.getDefault().getReferralHandler();
-        if ( referralHandler != null )
-        {
-            referralConnection = referralHandler
-                .getReferralConnection( new ArrayList<String>( referral.getLdapUrls()
) );
-
-            // open connection if not yet open
-            if ( referralConnection != null && !referralConnection.getConnectionWrapper().isConnected()
)
-            {
-                referralConnection.getConnectionWrapper().connect( monitor );
-                referralConnection.getConnectionWrapper().bind( monitor );
-                for ( IConnectionListener listener : ConnectionCorePlugin.getDefault().getConnectionListeners()
)
-                {
-                    listener.connectionOpened( referralConnection, monitor );
-                }
-                ConnectionEventRegistry.fireConnectionOpened( referralConnection, source
);
-            }
-        }
-        return referralConnection;
-    }
-
-
-    /**
      * Retrieves all referrals from the ReferralException and
      * creates or updates the ReferralsInfo.
      * 

Modified: directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JndiStudioNamingEnumeration.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JndiStudioNamingEnumeration.java?rev=1025611&r1=1025610&r2=1025611&view=diff
==============================================================================
--- directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JndiStudioNamingEnumeration.java
(original)
+++ directory/studio/branches/studio-connection-refactoring/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JndiStudioNamingEnumeration.java
Wed Oct 20 15:08:38 2010
@@ -41,6 +41,7 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
 import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
 import org.apache.directory.studio.connection.core.io.AbstractStudioNamingEnumeration;
+import org.apache.directory.studio.connection.core.io.ConnectionWrapperUtils;
 import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
 import org.apache.directory.studio.connection.core.IJndiLogger;
 
@@ -352,7 +353,7 @@ public class JndiStudioNamingEnumeration
                 }
                 List<String> urls = new ArrayList<String>( referral.getLdapUrls()
);
                 LdapURL url = new LdapURL( urls.get( 0 ) );
-                Connection referralConnection = JNDIConnectionWrapper.getReferralConnection(
referral, monitor, this );
+                Connection referralConnection = ConnectionWrapperUtils.getReferralConnection(
referral, monitor, this );
                 if ( referralConnection != null )
                 {
                     done = false;



Mime
View raw message