directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r597838 [2/2] - in /directory/studio/trunk: studio-aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/ studio-connection-core/ studio-connection-core/META-INF/ studio-connection-core/src/main/java/org/apache/...
Date Sat, 24 Nov 2007 11:20:49 GMT
Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/Utils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/Utils.java?rev=597838&r1=597837&r2=597838&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/Utils.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/Utils.java
Sat Nov 24 03:20:34 2007
@@ -30,8 +30,12 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
 import org.apache.directory.studio.ldifparser.LdifFormatParameters;
 import org.apache.directory.studio.ldifparser.LdifUtils;
 import org.eclipse.core.runtime.Preferences;
@@ -39,6 +43,69 @@
 
 public class Utils
 {
+
+
+    /**
+     * Transforms the given DN into a normalized String, usable by the schema cache.
+     * The following transformations are permformed:
+     * <ul>
+     *   <li>The attribute type is replaced by the OID
+     *   <li>The attribute value is trimmed and lowercased
+     * </ul> 
+     * Example: the surname=Bar will be transformed to
+     * 2.5.4.4=bar
+     * 
+     * 
+     * @param dn the DN
+     * @param schema the schema
+     * 
+     * @return the oid string
+     */
+    public static String getNormalizedOidString( LdapDN dn, Schema schema )
+    {
+        StringBuffer sb = new StringBuffer();
+
+        Iterator<Rdn> it = dn.getRdns().iterator();
+        while ( it.hasNext() )
+        {
+            Rdn rdn = it.next();
+            sb.append( getOidString( rdn, schema ) );
+            if ( it.hasNext() )
+            {
+                sb.append( ',' );
+            }
+        }
+
+        return sb.toString();
+    }
+
+
+    private static String getOidString( Rdn rdn, Schema schema )
+    {
+        StringBuffer sb = new StringBuffer();
+
+        Iterator<AttributeTypeAndValue> it = rdn.iterator();
+        while ( it.hasNext() )
+        {
+            AttributeTypeAndValue atav = it.next();
+            sb.append( getOidString( atav, schema ) );
+            if ( it.hasNext() )
+            {
+                sb.append( '+' );
+            }
+        }
+
+        return sb.toString();
+    }
+
+
+    private static String getOidString( AttributeTypeAndValue atav, Schema schema )
+    {
+        String oid = schema != null ? schema.getAttributeTypeDescription( atav.getNormType()
).getNumericOID() : atav
+            .getNormType();
+        return oid.trim().toLowerCase() + "=" + ( ( String ) atav.getUpValue() ).trim().toLowerCase();
//$NON-NLS-1$
+    }
+
 
     public static String[] stringToArray( String s )
     {

Modified: directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java?rev=597838&r1=597837&r2=597838&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java
Sat Nov 24 03:20:34 2007
@@ -26,6 +26,8 @@
 import java.io.FileWriter;
 
 import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.apache.directory.studio.connection.core.io.jndi.LdifModificationLogger;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
@@ -145,7 +147,8 @@
 
             // load file %u %g
             StringBuffer sb = new StringBuffer();
-            File[] files = input.getConnection().getModificationLogger().getFiles();
+            LdifModificationLogger modificationLogger = ConnectionCorePlugin.getDefault().getLdifModificationLogger();
+            File[] files = modificationLogger.getFiles( input.getConnection().getConnection()
);
             int i = input.getIndex();
             if ( 0 <= i && i < files.length && files[i] != null &&
files[i].exists() && files[i].canRead() )
             {
@@ -229,8 +232,9 @@
     {
         StringBuffer sb = new StringBuffer( "" );
         FileWriter fw = null;
-        File[] files = input.getConnection().getModificationLogger().getFiles();
-        input.getConnection().getModificationLogger().dispose();
+        LdifModificationLogger modificationLogger = ConnectionCorePlugin.getDefault().getLdifModificationLogger();
+        File[] files = modificationLogger.getFiles( input.getConnection().getConnection()
);
+        modificationLogger.dispose( input.getConnection().getConnection() );
         for ( int i = 0; i < files.length; i++ )
         {
             try

Modified: directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OlderAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OlderAction.java?rev=597838&r1=597837&r2=597838&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OlderAction.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OlderAction.java
Sat Nov 24 03:20:34 2007
@@ -23,6 +23,8 @@
 
 import java.io.File;
 
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.apache.directory.studio.connection.core.io.jndi.LdifModificationLogger;
 import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
 import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
 import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
@@ -110,7 +112,8 @@
         if ( getInput() != null && ( getInput() instanceof ModificationLogsViewInput
) )
         {
             ModificationLogsViewInput input = ( ModificationLogsViewInput ) getInput();
-            File[] files = input.getConnection().getModificationLogger().getFiles();
+            LdifModificationLogger modificationLogger = ConnectionCorePlugin.getDefault().getLdifModificationLogger();
+            File[] files = modificationLogger.getFiles( input.getConnection().getConnection()
);
             int i = input.getIndex() + 1;
             if ( 0 <= i && i < files.length && files[i] != null &&
files[i].exists() && files[i].canRead() )
             {

Modified: directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryDnWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryDnWizardPage.java?rev=597838&r1=597837&r2=597838&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryDnWizardPage.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewEntryDnWizardPage.java
Sat Nov 24 03:20:34 2007
@@ -27,6 +27,7 @@
 import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.studio.connection.core.DnUtils;
 import org.apache.directory.studio.ldapbrowser.common.jobs.RunnableContextJobAdapter;
 import org.apache.directory.studio.ldapbrowser.common.widgets.DnBuilderWidget;
 import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
@@ -40,7 +41,6 @@
 import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.Value;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.Subschema;
-import org.apache.directory.studio.ldapbrowser.core.utils.DnUtils;
 import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
 import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
 import org.eclipse.jface.dialogs.MessageDialog;



Mime
View raw message