directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1065362 - in /directory/studio/trunk/plugins: connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/ ldapbrowser.core/ ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/
Date Sun, 30 Jan 2011 19:54:29 GMT
Author: akarasulu
Date: Sun Jan 30 19:54:29 2011
New Revision: 1065362

URL: http://svn.apache.org/viewvc?rev=1065362&view=rev
Log:
finally getting studio to compile after all the changes to shared: starting to make tests
work

Modified:
    directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/CursorStudioNamingEnumeration.java
    directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
    directory/studio/trunk/plugins/ldapbrowser.core/pom.xml
    directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlRunnable.java
    directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlRunnable.java

Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/CursorStudioNamingEnumeration.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/CursorStudioNamingEnumeration.java?rev=1065362&r1=1065361&r2=1065362&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/CursorStudioNamingEnumeration.java
(original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/CursorStudioNamingEnumeration.java
Sun Jan 30 19:54:29 2011
@@ -34,14 +34,13 @@ import javax.naming.ldap.BasicControl;
 import javax.naming.ldap.Control;
 import javax.naming.ldap.PagedResultsResponseControl;
 
+import org.apache.directory.shared.ldap.codec.DefaultLdapCodecService;
+import org.apache.directory.shared.ldap.codec.ICodecControl;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.cursor.SearchCursor;
 import org.apache.directory.shared.ldap.model.entry.AttributeUtils;
 import org.apache.directory.shared.ldap.model.filter.LdapURL;
-import org.apache.directory.shared.ldap.model.message.Referral;
 import org.apache.directory.shared.ldap.model.message.*;
-import org.apache.directory.shared.ldap.model.message.Response;
-import org.apache.directory.shared.ldap.model.message.SearchResultDone;
-import org.apache.directory.shared.ldap.model.message.SearchResultReference;
 import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
@@ -69,6 +68,9 @@ public class CursorStudioNamingEnumerati
     private StudioNamingEnumeration cursorNamingEnumeration;
     private SearchResultDone searchResultDone;
 
+    // @TODO: By Alex: temporary fix until things are in order (needs to be fixed)
+    private ILdapCodecService codec = new DefaultLdapCodecService();
+    
 
     /**
      * Creates a new instance of ReferralNamingEnumeration.
@@ -366,26 +368,36 @@ public class CursorStudioNamingEnumerati
             for ( org.apache.directory.shared.ldap.model.message.Control control : controls
)
             {
                 Control convertedControl = null;
+                ICodecControl<? extends org.apache.directory.shared.ldap.model.message.Control>
wrapped = null;
+
+                if ( control instanceof ICodecControl )
+                {
+                    wrapped = ( ICodecControl<?> ) control;
+                }
+                else
+                {
+                    wrapped = codec.decorate( control );
+                }
 
                 if ( PagedResultsResponseControl.OID.equals( control.getOid() ) )
                 {
                     // Special case for the PagedResultsResponseControl
                     try
                     {
-                        convertedControl = new PagedResultsResponseControl( control.getOid(),
control.isCritical(),
-                            control.getValue() );
+                        convertedControl = new PagedResultsResponseControl( wrapped.getOid(),
wrapped.isCritical(),
+                            wrapped.getValue() );
                     }
                     catch ( IOException e )
                     {
-                        convertedControl = new BasicControl( control.getOid(), control.isCritical(),
-                            control.getValue() );
+                        convertedControl = new BasicControl( wrapped.getOid(), wrapped.isCritical(),
+                            wrapped.getValue() );
                     }
                 }
                 else
                 {
                     // Default case
-                    convertedControl = new BasicControl( control.getOid(), control.isCritical(),
-                        control.getValue() );
+                    convertedControl = new BasicControl( wrapped.getOid(), wrapped.isCritical(),
+                        wrapped.getValue() );
                 }
 
                 convertedControls.add( convertedControl );

Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java?rev=1065362&r1=1065361&r2=1065362&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
(original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
Sun Jan 30 19:54:29 2011
@@ -39,30 +39,13 @@ import javax.net.ssl.X509TrustManager;
 import org.apache.directory.ldap.client.api.LdapConnectionConfig;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.exception.InvalidConnectionException;
-import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
 import org.apache.directory.shared.ldap.model.cursor.SearchCursor;
 import org.apache.directory.shared.ldap.model.entry.DefaultModification;
 import org.apache.directory.shared.ldap.model.filter.SearchScope;
 import org.apache.directory.shared.ldap.model.entry.AttributeUtils;
 import org.apache.directory.shared.ldap.model.entry.Modification;
 import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
-import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
-import org.apache.directory.shared.ldap.model.message.AddResponse;
 import org.apache.directory.shared.ldap.model.message.*;
-import org.apache.directory.shared.ldap.model.message.DeleteRequest;
-import org.apache.directory.shared.ldap.model.message.DeleteRequestImpl;
-import org.apache.directory.shared.ldap.model.message.LdapResult;
-import org.apache.directory.shared.ldap.model.message.ModifyDnRequest;
-import org.apache.directory.shared.ldap.model.message.ModifyDnRequestImpl;
-import org.apache.directory.shared.ldap.model.message.ModifyDnResponse;
-import org.apache.directory.shared.ldap.model.message.ModifyRequest;
-import org.apache.directory.shared.ldap.model.message.ModifyRequestImpl;
-import org.apache.directory.shared.ldap.model.message.ModifyResponse;
-import org.apache.directory.shared.ldap.model.message.DeleteResponse;
-import org.apache.directory.shared.ldap.model.message.ResultResponse;
-import org.apache.directory.shared.ldap.model.message.SearchRequest;
-import org.apache.directory.shared.ldap.model.message.SearchRequestImpl;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.connection.core.Connection;
@@ -526,19 +509,20 @@ public class DirectoryApiConnectionWrapp
      *      an array of converted controls
      */
     private org.apache.directory.shared.ldap.model.message.Control[] convertControls( Control[]
controls )
+        throws Exception
     {
         if ( controls != null )
         {
-            org.apache.directory.shared.ldap.model.message.Control[] returningControls =
new org.apache.directory.shared.ldap.model.message.Control[controls.length];
+            org.apache.directory.shared.ldap.model.message.Control[] returningControls =

+                new org.apache.directory.shared.ldap.model.message.Control[controls.length];
 
             for ( int i = 0; i < controls.length; i++ )
             {
                 Control control = controls[i];
-                org.apache.directory.shared.ldap.model.message.Control returningControl =
new ControlImpl(
-                    control.getID() );
-                returningControl.setValue( control.getEncodedValue() );
-                returningControl.setCritical( control.isCritical() );
-
+                
+                org.apache.directory.shared.ldap.model.message.Control returningControl;
+                    returningControl = ldapConnection.getCodecService().fromJndiControl(
control );
+                
                 returningControls[i] = returningControl;
             }
 

Modified: directory/studio/trunk/plugins/ldapbrowser.core/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.core/pom.xml?rev=1065362&r1=1065361&r2=1065362&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.core/pom.xml (original)
+++ directory/studio/trunk/plugins/ldapbrowser.core/pom.xml Sun Jan 30 19:54:29 2011
@@ -110,6 +110,7 @@
  org.apache.commons.collections;bundle-version="${org.apache.commons.collections.version}",
  org.apache.commons.io;bundle-version="${org.apache.commons.io.version}",
  org.apache.commons.lang;bundle-version="${org.apache.commons.lang.version}",
+ org.apache.directory.shared.asn1.api;bundle-version="${org.apache.directory.shared.validversion}",
  org.apache.directory.shared.ldap;bundle-version="${org.apache.directory.shared.validversion}",
  org.apache.directory.shared.dsmlv2.parser;bundle-version="${org.apache.directory.shared.validversion}",
  org.apache.directory.shared.util;bundle-version="${org.apache.directory.shared.validversion}",

Modified: directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlRunnable.java?rev=1065362&r1=1065361&r2=1065362&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlRunnable.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportDsmlRunnable.java
Sun Jan 30 19:54:29 2011
@@ -42,6 +42,8 @@ import org.apache.directory.shared.dsmlv
 import org.apache.directory.shared.dsmlv2.reponse.SearchResultReferenceDsml;
 import org.apache.directory.shared.dsmlv2.request.AddRequestDsml;
 import org.apache.directory.shared.dsmlv2.request.BatchRequestDsml;
+import org.apache.directory.shared.ldap.codec.DefaultLdapCodecService;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.entry.AttributeUtils;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.exception.LdapURLEncodingException;
@@ -89,6 +91,14 @@ public class ExportDsmlRunnable implemen
 
     /** The type of the export */
     private ExportDsmlJobType type = ExportDsmlJobType.RESPONSE;
+    
+    /** 
+     * The LDAP Codec - for now need by the DSML Parser 
+     * @TODO - this should be removed - no reason why the DSML parser needs it
+     * @TODO - hate to make it static like this but methods are static
+     */
+    private static ILdapCodecService codec = new DefaultLdapCodecService();
+    
 
     /**
      * This enum contains the two possible export types.
@@ -264,7 +274,7 @@ public class ExportDsmlRunnable implemen
         StudioProgressMonitor monitor, SearchParameter searchParameter ) throws LdapURLEncodingException,
LdapException
     {
         // Creating and adding the search response
-        SearchResponseDsml sr = new SearchResponseDsml();
+        SearchResponseDsml sr = new SearchResponseDsml( codec );
         batchResponse.addResponse( sr );
 
         try
@@ -320,7 +330,7 @@ public class ExportDsmlRunnable implemen
                 ldapResult.setErrorMessage( t.getMessage() );
             }
         }
-        sr.addResponse( new SearchResultDoneDsml( srd ) );
+        sr.addResponse( new SearchResultDoneDsml( codec, srd ) );
     }
 
 
@@ -342,7 +352,7 @@ public class ExportDsmlRunnable implemen
         if ( isReferral( entry ) )
         {
             // The search result is a referral
-            SearchResultReferenceDsml srr = new SearchResultReferenceDsml();
+            SearchResultReferenceDsml srr = new SearchResultReferenceDsml( codec );
 
             // Getting the 'ref' attribute
             EntryAttribute refAttribute = entry.get( ExportDsmlRunnable.REF_ATTRIBUTETYPE_NAME
);
@@ -368,7 +378,7 @@ public class ExportDsmlRunnable implemen
         else
         {
             // The search result is NOT a referral
-            SearchResultEntryDsml sre = new SearchResultEntryDsml();
+            SearchResultEntryDsml sre = new SearchResultEntryDsml( codec );
             sre.setEntry( entry );
 
             return sre;
@@ -476,7 +486,7 @@ public class ExportDsmlRunnable implemen
     private AddRequestDsml convertToAddRequestDsml( SearchResult searchResult )
         throws LdapException
     {
-        AddRequestDsml ar = new AddRequestDsml();
+        AddRequestDsml ar = new AddRequestDsml( codec );
         Entry entry = AttributeUtils.toClientEntry( searchResult.getAttributes(),
             new Dn( searchResult.getNameInNamespace() ) );
         ar.setEntry( entry );

Modified: directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlRunnable.java?rev=1065362&r1=1065361&r2=1065362&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlRunnable.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlRunnable.java
Sun Jan 30 19:54:29 2011
@@ -37,6 +37,8 @@ import javax.naming.directory.SearchCont
 import javax.naming.ldap.Control;
 
 import org.apache.commons.codec.digest.DigestUtils;
+
+import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.dsmlv2.Dsmlv2Parser;
 import org.apache.directory.shared.dsmlv2.reponse.AddResponseDsml;
 import org.apache.directory.shared.dsmlv2.reponse.AuthResponseDsml;
@@ -47,6 +49,8 @@ import org.apache.directory.shared.dsmlv
 import org.apache.directory.shared.dsmlv2.reponse.ModDNResponseDsml;
 import org.apache.directory.shared.dsmlv2.reponse.ModifyResponseDsml;
 import org.apache.directory.shared.dsmlv2.request.BatchRequest;
+import org.apache.directory.shared.ldap.codec.DefaultLdapCodecService;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
 import org.apache.directory.shared.ldap.model.entry.*;
 import org.apache.directory.shared.ldap.model.message.*;
 import org.apache.directory.shared.ldap.model.entry.AttributeUtils;
@@ -77,8 +81,6 @@ import org.apache.directory.studio.ldapb
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
 
-import com.sun.jndi.ldap.BasicControl;
-
 
 /**
  * Runnable to import a DSML File into a LDAP server
@@ -95,6 +97,12 @@ public class ImportDsmlRunnable implemen
 
     /** The Save file to use */
     private File responseFile;
+    
+    /** 
+     * LDAP Codec used by DSML parser
+     * @TODO by Alex - this should be removed completely
+     */
+    private ILdapCodecService codec = new DefaultLdapCodecService();
 
 
     /**
@@ -323,7 +331,7 @@ public class ImportDsmlRunnable implemen
         // Creating the response
         if ( batchResponseDsml != null )
         {
-            AuthResponseDsml authResponseDsml = new AuthResponseDsml();
+            AuthResponseDsml authResponseDsml = new AuthResponseDsml( codec );
             LdapResult ldapResult = authResponseDsml.getLdapResult();
             ldapResult.setResultCode( ResultCodeEnum.UNWILLING_TO_PERFORM );
             ldapResult.setErrorMessage( "This kind of request is not yet supported." );
@@ -354,7 +362,7 @@ public class ImportDsmlRunnable implemen
         // Creating the response
         if ( batchResponseDsml != null )
         {
-            AddResponseDsml addResponseDsml = new AddResponseDsml();
+            AddResponseDsml addResponseDsml = new AddResponseDsml( codec );
             LdapResult ldapResult = addResponseDsml.getLdapResult();
             setLdapResultValuesFromMonitor( ldapResult, monitor, MessageTypeEnum.ADD_REQUEST
);
             ldapResult.setMatchedDn( entry.getDn() );
@@ -394,7 +402,7 @@ public class ImportDsmlRunnable implemen
         // Creating the response
         if ( batchResponseDsml != null )
         {
-            CompareResponseDsml compareResponseDsml = new CompareResponseDsml();
+            CompareResponseDsml compareResponseDsml = new CompareResponseDsml( codec );
             LdapResult ldapResult = compareResponseDsml.getLdapResult();
             ldapResult.setResultCode( ResultCodeEnum.UNWILLING_TO_PERFORM );
             ldapResult.setErrorMessage( "This kind of request is not yet supported." );
@@ -421,7 +429,7 @@ public class ImportDsmlRunnable implemen
         // Creating the response
         if ( batchResponseDsml != null )
         {
-            DelResponseDsml delResponseDsml = new DelResponseDsml();
+            DelResponseDsml delResponseDsml = new DelResponseDsml( codec );
             LdapResult ldapResult = delResponseDsml.getLdapResult();
             setLdapResultValuesFromMonitor( ldapResult, monitor, MessageTypeEnum.ADD_REQUEST
);
             delResponseDsml.getLdapResult().setMatchedDn( request.getName() );
@@ -462,7 +470,7 @@ public class ImportDsmlRunnable implemen
         // Creating the response
         if ( batchResponseDsml != null )
         {
-            ExtendedResponseDsml extendedResponseDsml = new ExtendedResponseDsml();
+            ExtendedResponseDsml extendedResponseDsml = new ExtendedResponseDsml( codec );
             LdapResult ldapResult = extendedResponseDsml.getLdapResult();
             ldapResult.setResultCode( ResultCodeEnum.UNWILLING_TO_PERFORM );
             ldapResult.setErrorMessage( "This kind of request is not yet supported." );
@@ -500,7 +508,7 @@ public class ImportDsmlRunnable implemen
         // Creating the response
         if ( batchResponseDsml != null )
         {
-            ModifyResponseDsml modifyResponseDsml = new ModifyResponseDsml();
+            ModifyResponseDsml modifyResponseDsml = new ModifyResponseDsml( codec );
             LdapResult ldapResult = modifyResponseDsml.getLdapResult();
             setLdapResultValuesFromMonitor( ldapResult, monitor, MessageTypeEnum.ADD_REQUEST
);
             modifyResponseDsml.getLdapResult().setMatchedDn( request.getName() );
@@ -561,7 +569,7 @@ public class ImportDsmlRunnable implemen
         // Creating the response
         if ( batchResponseDsml != null )
         {
-            ModDNResponseDsml modDNResponseDsml = new ModDNResponseDsml();
+            ModDNResponseDsml modDNResponseDsml = new ModDNResponseDsml( codec );
             LdapResult ldapResult = modDNResponseDsml.getLdapResult();
             setLdapResultValuesFromMonitor( ldapResult, monitor, MessageTypeEnum.ADD_REQUEST
);
             modDNResponseDsml.getLdapResult().setMatchedDn( request.getName() );
@@ -715,9 +723,14 @@ public class ImportDsmlRunnable implemen
             List<Control> jndiControls = new ArrayList<Control>();
             for ( org.apache.directory.shared.ldap.model.message.Control control : controls
)
             {
-                Control jndiControl = new BasicControl( control.getOid(), control.isCritical(),
-                    control.getValue() );
-                jndiControls.add( jndiControl );
+                try
+                {
+                    jndiControls.add( codec.toJndiControl( control ) );
+                }
+                catch ( EncoderException e )
+                {
+                    throw new RuntimeException( e );
+                }
             }
             return jndiControls.toArray( new Control[jndiControls.size()] );
         }



Mime
View raw message