directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1805153 - /directory/studio/branches/studio-value/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java
Date Wed, 16 Aug 2017 08:55:08 GMT
Author: elecharny
Date: Wed Aug 16 08:55:07 2017
New Revision: 1805153

URL: http://svn.apache.org/viewvc?rev=1805153&view=rev
Log:
Fixed soem Sonar warnings

Modified:
    directory/studio/branches/studio-value/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java

Modified: directory/studio/branches/studio-value/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-value/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java?rev=1805153&r1=1805152&r2=1805153&view=diff
==============================================================================
--- directory/studio/branches/studio-value/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java
(original)
+++ directory/studio/branches/studio-value/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java
Wed Aug 16 08:55:07 2017
@@ -28,6 +28,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.ldap.model.name.Rdn;
@@ -224,11 +225,18 @@ public class SchemaEditorSchemaLoaderUti
      */
     private static Dn getDn( SchemaObject schemaObject, String objectPath ) throws LdapInvalidDnException
     {
-        return Dn.EMPTY_DN
-            .add( new Rdn( SchemaConstants.OU_SCHEMA ) )
-            .add( new Rdn( SchemaConstants.CN_AT, Rdn.escapeValue( schemaObject.getSchemaName()
) ) )
-            .add( new Rdn( objectPath ) )
-            .add( new Rdn( M_OID, schemaObject.getOid() ) );
+		try
+		{	
+		    return Dn.EMPTY_DN
+		        .add( new Rdn( SchemaConstants.OU_SCHEMA ) )
+		        .add( new Rdn( SchemaConstants.CN_AT, Rdn.escapeValue( schemaObject.getSchemaName()
) ) )
+		        .add( new Rdn( objectPath ) )
+		        .add( new Rdn( M_OID, schemaObject.getOid() ) );
+		}
+		catch ( LdapInvalidAttributeValueException liave )
+		{
+			throw new LdapInvalidDnException( liave.getLocalizedMessage(), liave );
+		}
     }
 
 
@@ -317,7 +325,7 @@ public class SchemaEditorSchemaLoaderUti
     private static void addNamesValue( SchemaObject schemaObject, Entry entry ) throws LdapException
     {
         List<String> names = schemaObject.getNames();
-        if ( ( names != null ) && ( names.size() > 0 ) )
+        if ( ( names != null ) && !names.isEmpty() )
         {
             Attribute attribute = new DefaultAttribute( M_NAME );
             entry.add( attribute );
@@ -469,7 +477,7 @@ public class SchemaEditorSchemaLoaderUti
             long syntaxLength = attributeType.getSyntaxLength();
             if ( syntaxLength != -1 )
             {
-                attribute = new DefaultAttribute( M_LENGTH, "" + syntaxLength ); //$NON-NLS-1$
+                attribute = new DefaultAttribute( M_LENGTH, Long.toString( syntaxLength)
); //$NON-NLS-1$
                 entry.add( attribute );
             }
         }
@@ -565,7 +573,7 @@ public class SchemaEditorSchemaLoaderUti
     private static void addSuperiorsValue( ObjectClass objectClass, Entry entry ) throws
LdapException
     {
         List<String> superiors = objectClass.getSuperiorOids();
-        if ( ( superiors != null ) && ( superiors.size() > 0 ) )
+        if ( ( superiors != null ) && !superiors.isEmpty() )
         {
             Attribute attribute = new DefaultAttribute( M_SUP_OBJECT_CLASS );
             entry.add( attribute );
@@ -610,7 +618,7 @@ public class SchemaEditorSchemaLoaderUti
     private static void addMustsValue( ObjectClass objectClass, Entry entry ) throws LdapException
     {
         List<String> musts = objectClass.getMustAttributeTypeOids();
-        if ( ( musts != null ) && ( musts.size() > 0 ) )
+        if ( ( musts != null ) && !musts.isEmpty() )
         {
             Attribute attribute = new DefaultAttribute( M_MUST );
             entry.add( attribute );
@@ -635,7 +643,7 @@ public class SchemaEditorSchemaLoaderUti
     private static void addMaysValue( ObjectClass objectClass, Entry entry ) throws LdapException
     {
         List<String> mays = objectClass.getMayAttributeTypeOids();
-        if ( ( mays != null ) && ( mays.size() > 0 ) )
+        if ( ( mays != null ) && !mays.isEmpty() )
         {
             Attribute attribute = new DefaultAttribute( M_MAY );
             entry.add( attribute );



Mime
View raw message