directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r803976 - in /directory/studio/trunk: ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/ valueeditors/ valueeditors/src/main/java/org/apache/directory/studio/valueeditors/uuid/
Date Thu, 13 Aug 2009 18:13:57 GMT
Author: seelmann
Date: Thu Aug 13 18:13:57 2009
New Revision: 803976

URL: http://svn.apache.org/viewvc?rev=803976&view=rev
Log:
Fixed UUID value editor to handle string or binary values:
o handle syntax 1.3.6.1.1.16.1 to binary
o check if the value is string and matches the UUID regular expression



Modified:
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java
    directory/studio/trunk/valueeditors/plugin.xml
    directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditor.java

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java?rev=803976&r1=803975&r2=803976&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java
Thu Aug 13 18:13:57 2009
@@ -93,7 +93,8 @@
                 new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.23" ), // Fax //$NON-NLS-1$
                 new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.28" ), // JPEG //$NON-NLS-1$
                 new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.40" ), // Octet String //$NON-NLS-1$
-                new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.49" ) // Supported Algorithm
//$NON-NLS-1$
+                new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.49" ), // Supported Algorithm
//$NON-NLS-1$
+                new BinarySyntax( "1.3.6.1.1.16.1" ), // UUID //$NON-NLS-1$
             };
         BrowserCorePlugin.getDefault().getCorePreferences().setDefaultBinarySyntaxes( defaultBinarySyntaxes
);
     }

Modified: directory/studio/trunk/valueeditors/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/plugin.xml?rev=803976&r1=803975&r2=803976&view=diff
==============================================================================
--- directory/studio/trunk/valueeditors/plugin.xml (original)
+++ directory/studio/trunk/valueeditors/plugin.xml Thu Aug 13 18:13:57 2009
@@ -84,7 +84,9 @@
           class="org.apache.directory.studio.valueeditors.uuid.InPlaceUuidValueEditor"
           icon="resources/icons/passwordeditor.gif"
           name="%ValueEditor_InPlaceEntryUUIDValueEditor_name">
-       <attribute attributeType="entryUUID"/>
+       <syntax
+             syntaxOID="1.3.6.1.1.16.1">
+       </syntax>
     </valueEditor>
     <valueEditor
           class="org.apache.directory.studio.valueeditors.certificate.CertificateValueEditor"

Modified: directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditor.java?rev=803976&r1=803975&r2=803976&view=diff
==============================================================================
--- directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditor.java
(original)
+++ directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditor.java
Thu Aug 13 18:13:57 2009
@@ -20,12 +20,12 @@
 
 package org.apache.directory.studio.valueeditors.uuid;
 
+
 import java.util.UUID;
 
+import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
-import org.apache.directory.studio.valueeditors.AbstractInPlaceStringValueEditor;
-
-
+import org.apache.directory.studio.valueeditors.HexValueEditor;
 
 
 /**
@@ -38,33 +38,35 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class InPlaceUuidValueEditor extends AbstractInPlaceStringValueEditor
+public class InPlaceUuidValueEditor extends HexValueEditor
 {
+    private static final String UUID_REGEX = "^[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}$";
//$NON-NLS-1$
+
 
     /**
      * {@inheritDoc}
      */
     public String getDisplayValue( IValue value )
     {
-    	// OpenLDAP returns entryUUID as a String instead of byte[]
-    	if( value.getRawValue() instanceof String )
-    	{
-    		return ( String ) value.getRawValue();	
-    	}
-    	
-        byte[] displayValue = value.getBinaryValue();
-
         if ( !showRawValues() )
         {
-        	if( displayValue == null )
-        	{
-        		return "NULL";
-        	}
-        	
-        	return UUID.nameUUIDFromBytes( displayValue ).toString(); //$NON-NLS-1$ //$NON-NLS-2$
+            Object rawValue = super.getRawValue( value );
+            if ( rawValue instanceof byte[] )
+            {
+                byte[] bytes = ( byte[] ) rawValue;
+                String string = StringTools.utf8ToString( bytes );
+                if ( string.matches( UUID_REGEX ) || StringTools.isEmpty( string ) )
+                {
+                    return string;
+                }
+                else
+                {
+                    return UUID.nameUUIDFromBytes( bytes ).toString();
+                }
+            }
         }
 
-        return "Binay entryUUID value";
+        return super.getDisplayValue( value );
     }
 
 }



Mime
View raw message