directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r721053 - /directory/apacheds/branches/apacheds-mina2/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
Date Thu, 27 Nov 2008 01:01:29 GMT
Author: elecharny
Date: Wed Nov 26 17:01:29 2008
New Revision: 721053

URL: http://svn.apache.org/viewvc?rev=721053&view=rev
Log:
Some minor refactoring : generics, for()...

Modified:
    directory/apacheds/branches/apacheds-mina2/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java

Modified: directory/apacheds/branches/apacheds-mina2/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java?rev=721053&r1=721052&r2=721053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mina2/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
(original)
+++ directory/apacheds/branches/apacheds-mina2/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
Wed Nov 26 17:01:29 2008
@@ -84,7 +84,7 @@
 {
     private Registries bootstrapRegistries = new DefaultRegistries( "bootstrap", new BootstrapSchemaLoader(),
         new DefaultOidRegistry() );
-    private Set exclusions = new HashSet();
+    private Set<String> exclusions = new HashSet<String>();
     private boolean includeOperational = false;
 
 
@@ -135,6 +135,7 @@
 
         // If not present then we need to abort 
         File schemaDirectory = new File( getLayout().getPartitionsDirectory(), "schema" );
+
         if ( !schemaDirectory.exists() )
         {
             throw new LdapConfigurationException( "The following schema directory from "
@@ -146,6 +147,7 @@
         schemaPartition.setCacheSize( 1000 );
 
         DbFileListing listing;
+        
         try
         {
             listing = new DbFileListing();
@@ -172,7 +174,6 @@
         // --------------------------------------------------------------------
         // Initialize schema subsystem and reset registries
         // --------------------------------------------------------------------
-
         PartitionSchemaLoader schemaLoader = new PartitionSchemaLoader( schemaPartition,
registries );
         Registries globalRegistries = new DefaultRegistries( "global", schemaLoader, oidRegistry
);
         schemaLoader.loadEnabled( globalRegistries );
@@ -192,12 +193,14 @@
         PrintWriter out = null;
 
         String[] excludedAttributes = cmdline.getOptionValues( 'e' );
+        
         if ( excludedAttributes != null )
         {
             AttributeTypeRegistry registry = bootstrapRegistries.getAttributeTypeRegistry();
-            for ( int ii = 0; ii < excludedAttributes.length; ii++ )
+            
+            for ( String attributeType:excludedAttributes)
             {
-                AttributeType type = registry.lookup( excludedAttributes[ii] );
+                AttributeType type = registry.lookup( attributeType );
                 exclusions.add( type.getName() );
             }
         }
@@ -211,9 +214,9 @@
             out = new PrintWriter( new FileWriter( outputFile ) );
         }
 
-        for ( int ii = 0; ii < partitions.length; ii++ )
+        for ( String partition:partitions )
         {
-            File partitionDirectory = new File( getLayout().getPartitionsDirectory(), partitions[ii]
);
+            File partitionDirectory = new File( getLayout().getPartitionsDirectory(), partition
);
             out.println( "\n\n" );
             dump( partitionDirectory, out );
         }
@@ -250,6 +253,7 @@
         out.println( "#---------------------" );
         Cursor<Tuple<Long,ServerEntry>> list = master.cursor();
         StringBuffer buf = new StringBuffer();
+        
         while ( list.next() )
         {
             Tuple<Long,ServerEntry> tuple = list.get();
@@ -260,6 +264,7 @@
             filterAttributes( dn, entry );
 
             buf.append( "# Entry: " ).append( id ).append( "\n#---------------------\n\n"
);
+        
             if ( !LdifUtils.isLDIFSafe( dn ) )
             {
                 // If the DN isn't LdifSafe, it needs to be Base64 encoded.
@@ -270,11 +275,14 @@
             {
                 buf.append( "dn: " ).append( dn );
             }
+            
             buf.append( "\n" ).append( LdifUtils.convertToLdif( entry ) );
+
             if ( list.next() )
             {
                 buf.append( "\n\n#---------------------\n" );
             }
+            
             out.print( buf.toString() );
             out.flush();
             buf.setLength( 0 );
@@ -284,12 +292,14 @@
 
     private void filterAttributes( String dn, Attributes entry ) throws Exception
     {
-        List toRemove = new ArrayList();
+        List<String> toRemove = new ArrayList<String>();
         AttributeTypeRegistry registry = bootstrapRegistries.getAttributeTypeRegistry();
-        NamingEnumeration attrs = entry.getAll();
+        NamingEnumeration<? extends Attribute> attrs = entry.getAll();
+        
         while ( attrs.hasMore() )
         {
-            Attribute attr = ( Attribute ) attrs.next();
+            Attribute attr = attrs.next();
+            
             if ( !registry.hasAttributeType( attr.getID() ) )
             {
                 if ( !isQuietEnabled() )
@@ -302,15 +312,17 @@
 
             AttributeType type = registry.lookup( attr.getID() );
             boolean isOperational = type.getUsage() != UsageEnum.USER_APPLICATIONS;
+            
             if ( exclusions.contains( attr.getID() ) || ( isOperational && ( !includeOperational
) ) )
             {
                 toRemove.add( attr.getID() );
             }
         }
-        for ( int ii = 0; ii < toRemove.size(); ii++ )
+        
+        for ( String id:toRemove )
         {
-            String id = ( String ) toRemove.get( ii );
             entry.remove( id );
+            
             if ( isDebugEnabled() )
             {
                 System.out.println( "# Excluding attribute " + id + " in " + dn );



Mime
View raw message