directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1682271 - in /directory/shared/trunk: asn1/api/src/main/java/org/apache/directory/api/asn1/util/ ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/ ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extract...
Date Thu, 28 May 2015 16:05:11 GMT
Author: elecharny
Date: Thu May 28 16:05:11 2015
New Revision: 1682271

URL: http://svn.apache.org/r1682271
Log:
get rid of some Sonar warnings

Modified:
    directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java
    directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/ResourceMap.java

Modified: directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java?rev=1682271&r1=1682270&r2=1682271&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java
(original)
+++ directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java
Thu May 28 16:05:11 2015
@@ -83,7 +83,8 @@ public final class Oid
     private Oid( String oidString, byte[] oidBytes )
     {
         this.oidString = oidString;
-        this.oidBytes = oidBytes;
+        this.oidBytes = new byte[oidBytes.length];
+        System.arraycopy( oidBytes, 0, this.oidBytes, 0, oidBytes.length );
     }
 
 
@@ -166,10 +167,7 @@ public final class Oid
             throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, Arrays.toString(
oidBytes ) ) );
         }
 
-        byte[] oidBytesCopy = new byte[oidBytes.length];
-        System.arraycopy( oidBytes, 0, oidBytesCopy, 0, oidBytes.length );
-
-        return new Oid( builder.toString(), oidBytesCopy );
+        return new Oid( builder.toString(), oidBytes );
     }
 
 

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java?rev=1682271&r1=1682270&r2=1682271&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifRevertor.java
Thu May 28 16:05:11 2015
@@ -486,75 +486,41 @@ public final class LdifRevertor
             if ( oldRdn.size() == 1 )
             {
                 // The old Rdn is simple
-                boolean overlapping = false;
                 boolean existInEntry = false;
 
                 // Does it overlap ?
                 // Is the new Rdn AVAs contained into the entry?
                 for ( Ava atav : newRdn )
                 {
-                    if ( atav.equals( oldRdn.getAva() ) )
+                    if ( !atav.equals( oldRdn.getAva() ) &&
+                         ( entry.contains( atav.getNormType(), atav.getNormValue().getString()
) ) )
                     {
-                        // They overlap
-                        overlapping = true;
-                    }
-                    else
-                    {
-                        if ( entry.contains( atav.getNormType(), atav.getNormValue().getString()
) )
-                        {
-                            existInEntry = true;
-                        }
+                        existInEntry = true;
                     }
                 }
 
-                if ( overlapping )
+                // The new Rdn includes the old one
+                if ( existInEntry )
                 {
-                    // The new Rdn includes the old one
-                    if ( existInEntry )
-                    {
-                        // Some of the new Rdn AVAs existed in the entry
-                        // We have to restore them, but we also have to remove
-                        // the new values
-                        reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn,
KEEP_OLD_RDN );
+                    // Some of the new Rdn AVAs existed in the entry
+                    // We have to restore them, but we also have to remove
+                    // the new values
+                    reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn, KEEP_OLD_RDN
);
 
-                        entries.add( reverted );
+                    entries.add( reverted );
 
-                        // Now, restore the initial values
-                        LdifEntry restored = generateModify( parentDn, entry, oldRdn, newRdn
);
+                    // Now, restore the initial values
+                    LdifEntry restored = generateModify( parentDn, entry, oldRdn, newRdn
);
 
-                        entries.add( restored );
-                    }
-                    else
-                    {
-                        // This is the simplest case, we don't have to restore
-                        // some existing values (case 8.1 and 9.1)
-                        reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn,
DELETE_OLD_RDN );
-
-                        entries.add( reverted );
-                    }
+                    entries.add( restored );
                 }
                 else
                 {
-                    if ( existInEntry )
-                    {
-                        // Some of the new Rdn AVAs existed in the entry
-                        // We have to restore them, but we also have to remove
-                        // the new values
-                        reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn,
KEEP_OLD_RDN );
-
-                        entries.add( reverted );
+                    // This is the simplest case, we don't have to restore
+                    // some existing values (case 8.1 and 9.1)
+                    reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn, DELETE_OLD_RDN
);
 
-                        LdifEntry restored = generateModify( parentDn, entry, oldRdn, newRdn
);
-
-                        entries.add( restored );
-                    }
-                    else
-                    {
-                        // A much simpler case, as we just have to remove the newRDN
-                        reverted = generateReverted( newSuperior, newRdn, newDn, oldRdn,
DELETE_OLD_RDN );
-
-                        entries.add( reverted );
-                    }
+                    entries.add( reverted );
                 }
             }
             else

Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/ResourceMap.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/ResourceMap.java?rev=1682271&r1=1682270&r2=1682271&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/ResourceMap.java
(original)
+++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/extractor/impl/ResourceMap.java
Thu May 28 16:05:11 2015
@@ -178,29 +178,32 @@ public final class ResourceMap
     {
         File[] fileList = directory.listFiles();
 
-        for ( File file : fileList )
+        if ( fileList != null )
         {
-            if ( file.isDirectory() )
+            for ( File file : fileList )
             {
-                getResourcesFromDirectory( map, file, pattern );
-            }
-            else
-            {
-                try
+                if ( file.isDirectory() )
                 {
-                    String fileName = file.getCanonicalPath();
-                    boolean accept = pattern.matcher( fileName ).matches();
-
-                    if ( accept )
-                    {
-                        map.put( fileName, Boolean.FALSE );
-                    }
+                    getResourcesFromDirectory( map, file, pattern );
                 }
-                catch ( IOException e )
+                else
                 {
-                    LOG.error( "Cannot load file {} : {}", file.getAbsolutePath(), e.getMessage()
);
-
-                    // Continue...
+                    try
+                    {
+                        String fileName = file.getCanonicalPath();
+                        boolean accept = pattern.matcher( fileName ).matches();
+    
+                        if ( accept )
+                        {
+                            map.put( fileName, Boolean.FALSE );
+                        }
+                    }
+                    catch ( IOException e )
+                    {
+                        LOG.error( "Cannot load file {} : {}", file.getAbsolutePath(), e.getMessage()
);
+    
+                        // Continue...
+                    }
                 }
             }
         }



Mime
View raw message