]> source.dussan.org Git - archiva.git/commitdiff
fix formatting
authorOlivier Lamy <olamy@apache.org>
Wed, 26 Oct 2011 12:23:23 +0000 (12:23 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 26 Oct 2011 12:23:23 +0000 (12:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1189165 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java

index fd3f5446a4030cfec72b738c36e4086df3897792..91970535a7d4e0d41aae98a029cd99860bf0246b 100644 (file)
@@ -138,12 +138,12 @@ public class DefaultArchivaConfiguration
     /**
      * Configuration Listeners we've registered.
      */
-    private Set<ConfigurationListener> listeners = new HashSet<ConfigurationListener>( );
+    private Set<ConfigurationListener> listeners = new HashSet<ConfigurationListener>();
 
     /**
      * Registry Listeners we've registered.
      */
-    private Set<RegistryListener> registryListeners = new HashSet<RegistryListener>( );
+    private Set<RegistryListener> registryListeners = new HashSet<RegistryListener>();
 
     /**
      * Boolean to help determine if the configuration exists as a result of pulling in
@@ -153,16 +153,16 @@ public class DefaultArchivaConfiguration
 
     private static final String KEY = "org.apache.archiva";
 
-    public Configuration getConfiguration( )
+    public Configuration getConfiguration()
     {
-        return loadConfiguration( );
+        return loadConfiguration();
     }
 
-    private synchronized Configuration loadConfiguration( )
+    private synchronized Configuration loadConfiguration()
     {
         if ( configuration == null )
         {
-            configuration = load( );
+            configuration = load();
             configuration = unescapeExpressions( configuration );
             if ( isConfigurationDefaulted )
             {
@@ -174,113 +174,113 @@ public class DefaultArchivaConfiguration
     }
 
     @SuppressWarnings( "unchecked" )
-    private Configuration load( )
+    private Configuration load()
     {
         // TODO: should this be the same as section? make sure unnamed sections still work (eg, sys properties)
         Registry subset = registry.getSubset( KEY );
         if ( subset.getString( "version" ) == null )
         {
             // a little autodetection of v1, even if version is omitted (this was previously allowed)
-            if ( subset.getSubset( "repositoryScanning" ).isEmpty( ) )
+            if ( subset.getSubset( "repositoryScanning" ).isEmpty() )
             {
                 // only for empty, or v < 1
-                subset = readDefaultConfiguration( );
+                subset = readDefaultConfiguration();
             }
         }
 
-        Configuration config = new ConfigurationRegistryReader( ).read( subset );
+        Configuration config = new ConfigurationRegistryReader().read( subset );
 
-        config.getRepositoryGroups( );
-        config.getRepositoryGroupsAsMap( );
-        if ( !config.getRepositories( ).isEmpty( ) )
+        config.getRepositoryGroups();
+        config.getRepositoryGroupsAsMap();
+        if ( !config.getRepositories().isEmpty() )
         {
-            for ( Iterator<V1RepositoryConfiguration> i = config.getRepositories( ).iterator( ); i.hasNext( ); )
+            for ( Iterator<V1RepositoryConfiguration> i = config.getRepositories().iterator(); i.hasNext(); )
             {
-                V1RepositoryConfiguration r = i.next( );
-                r.setScanned( r.isIndexed( ) );
+                V1RepositoryConfiguration r = i.next();
+                r.setScanned( r.isIndexed() );
 
-                if ( StringUtils.startsWith( r.getUrl( ), "file://" ) )
+                if ( StringUtils.startsWith( r.getUrl(), "file://" ) )
                 {
-                    r.setLocation( r.getUrl( ).substring( 7 ) );
+                    r.setLocation( r.getUrl().substring( 7 ) );
                     config.addManagedRepository( r );
                 }
-                else if ( StringUtils.startsWith( r.getUrl( ), "file:" ) )
+                else if ( StringUtils.startsWith( r.getUrl(), "file:" ) )
                 {
-                    r.setLocation( r.getUrl( ).substring( 5 ) );
+                    r.setLocation( r.getUrl().substring( 5 ) );
                     config.addManagedRepository( r );
                 }
-                else if ( StringUtils.isEmpty( r.getUrl( ) ) )
+                else if ( StringUtils.isEmpty( r.getUrl() ) )
                 {
                     // in case of empty url we can consider it as a managed one
                     // check if location is null
                     //file://${appserver.base}/repositories/${id}
-                    if ( StringUtils.isEmpty( r.getLocation( ) ) )
+                    if ( StringUtils.isEmpty( r.getLocation() ) )
                     {
-                        r.setLocation( "file://${appserver.base}/repositories/" + r.getId( ) );
+                        r.setLocation( "file://${appserver.base}/repositories/" + r.getId() );
                     }
                     config.addManagedRepository( r );
                 }
                 else
                 {
-                    RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration( );
-                    repo.setId( r.getId( ) );
-                    repo.setLayout( r.getLayout( ) );
-                    repo.setName( r.getName( ) );
-                    repo.setUrl( r.getUrl( ) );
+                    RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
+                    repo.setId( r.getId() );
+                    repo.setLayout( r.getLayout() );
+                    repo.setName( r.getName() );
+                    repo.setUrl( r.getUrl() );
                     config.addRemoteRepository( repo );
                 }
             }
 
             // Prevent duplicate repositories from showing up.
-            config.getRepositories( ).clear( );
+            config.getRepositories().clear();
 
             registry.removeSubset( KEY + ".repositories" );
         }
 
-        if ( !CollectionUtils.isEmpty( config.getRemoteRepositories( ) ) )
+        if ( !CollectionUtils.isEmpty( config.getRemoteRepositories() ) )
         {
-            List<RemoteRepositoryConfiguration> remoteRepos = config.getRemoteRepositories( );
+            List<RemoteRepositoryConfiguration> remoteRepos = config.getRemoteRepositories();
             for ( RemoteRepositoryConfiguration repo : remoteRepos )
             {
                 // [MRM-582] Remote Repositories with empty <username> and <password> fields shouldn't be created in configuration.
-                if ( StringUtils.isBlank( repo.getUsername( ) ) )
+                if ( StringUtils.isBlank( repo.getUsername() ) )
                 {
                     repo.setUsername( null );
                 }
 
-                if ( StringUtils.isBlank( repo.getPassword( ) ) )
+                if ( StringUtils.isBlank( repo.getPassword() ) )
                 {
                     repo.setPassword( null );
                 }
             }
         }
 
-        if ( !config.getProxyConnectors( ).isEmpty( ) )
+        if ( !config.getProxyConnectors().isEmpty() )
         {
             // Fix Proxy Connector Settings.
 
-            List<ProxyConnectorConfiguration> proxyConnectorList = new ArrayList<ProxyConnectorConfiguration>( );
+            List<ProxyConnectorConfiguration> proxyConnectorList = new ArrayList<ProxyConnectorConfiguration>();
             // Create a copy of the list to read from (to prevent concurrent modification exceptions)
-            proxyConnectorList.addAll( config.getProxyConnectors( ) );
+            proxyConnectorList.addAll( config.getProxyConnectors() );
             // Remove the old connector list.
-            config.getProxyConnectors( ).clear( );
+            config.getProxyConnectors().clear();
 
             for ( ProxyConnectorConfiguration connector : proxyConnectorList )
             {
                 // Fix policies
                 boolean connectorValid = true;
 
-                Map<String, String> policies = new HashMap<String, String>( );
+                Map<String, String> policies = new HashMap<String, String>();
                 // Make copy of policies
-                policies.putAll( connector.getPolicies( ) );
+                policies.putAll( connector.getPolicies() );
                 // Clear out policies
-                connector.getPolicies( ).clear( );
+                connector.getPolicies().clear();
 
                 // Work thru policies. cleaning them up.
-                for ( Entry<String, String> entry : policies.entrySet( ) )
+                for ( Entry<String, String> entry : policies.entrySet() )
                 {
-                    String policyId = entry.getKey( );
-                    String setting = entry.getValue( );
+                    String policyId = entry.getKey();
+                    String setting = entry.getValue();
 
                     // Upgrade old policy settings.
                     if ( "releases".equals( policyId ) || "snapshots".equals( policyId ) )
@@ -318,9 +318,9 @@ public class DefaultArchivaConfiguration
                     {
                         Policy policy = findPolicy( policyId );
                         // Does option exist?
-                        if ( !policy.getOptions( ).contains( setting ) )
+                        if ( !policy.getOptions().contains( setting ) )
                         {
-                            setting = policy.getDefaultOption( );
+                            setting = policy.getDefaultOption();
                         }
                         connector.addPolicy( policyId, setting );
                     }
@@ -339,12 +339,12 @@ public class DefaultArchivaConfiguration
 
             // Normalize the order fields in the proxy connectors.
             Map<String, java.util.List<ProxyConnectorConfiguration>> proxyConnectorMap =
-                config.getProxyConnectorAsMap( );
+                config.getProxyConnectorAsMap();
 
-            for ( List<ProxyConnectorConfiguration> connectors : proxyConnectorMap.values( ) )
+            for ( List<ProxyConnectorConfiguration> connectors : proxyConnectorMap.values() )
             {
                 // Sort connectors by order field.
-                Collections.sort( connectors, ProxyConnectorConfigurationOrderComparator.getInstance( ) );
+                Collections.sort( connectors, ProxyConnectorConfigurationOrderComparator.getInstance() );
 
                 // Normalize the order field values.
                 int order = 1;
@@ -406,7 +406,7 @@ public class DefaultArchivaConfiguration
         return ( prePolicies.containsKey( policyId ) || postPolicies.containsKey( policyId ) );
     }
 
-    private Registry readDefaultConfiguration( )
+    private Registry readDefaultConfiguration()
     {
         // if it contains some old configuration, remove it (Archiva 0.9)
         registry.removeSubset( KEY );
@@ -435,16 +435,16 @@ public class DefaultArchivaConfiguration
             section = baseSection;
             if ( section == null )
             {
-                section = createDefaultConfigurationFile( );
+                section = createDefaultConfigurationFile();
             }
         }
         else if ( baseSection != null )
         {
-            Collection<String> keys = baseSection.getKeys( );
+            Collection<String> keys = baseSection.getKeys();
             boolean foundList = false;
-            for ( Iterator<String> i = keys.iterator( ); i.hasNext( ) && !foundList; )
+            for ( Iterator<String> i = keys.iterator(); i.hasNext() && !foundList; )
             {
-                String key = i.next( );
+                String key = i.next();
 
                 // a little aggressive with the repositoryScanning and databaseScanning - should be no need to split
                 // that configuration
@@ -470,45 +470,45 @@ public class DefaultArchivaConfiguration
         escapeCronExpressions( configuration );
 
         // [MRM-661] Due to a bug in the modello registry writer, we need to take these out by hand. They'll be put back by the writer.
-        if ( configuration.getManagedRepositories( ).isEmpty( ) && section != null )
+        if ( configuration.getManagedRepositories().isEmpty() && section != null )
         {
             section.removeSubset( "managedRepositories" );
         }
-        if ( configuration.getRemoteRepositories( ).isEmpty( ) && section != null )
+        if ( configuration.getRemoteRepositories().isEmpty() && section != null )
         {
             section.removeSubset( "remoteRepositories" );
 
         }
-        if ( configuration.getProxyConnectors( ).isEmpty( ) && section != null )
+        if ( configuration.getProxyConnectors().isEmpty() && section != null )
         {
             section.removeSubset( "proxyConnectors" );
         }
-        if ( configuration.getNetworkProxies( ).isEmpty( ) && section != null )
+        if ( configuration.getNetworkProxies().isEmpty() && section != null )
         {
             section.removeSubset( "networkProxies" );
         }
-        if ( configuration.getLegacyArtifactPaths( ).isEmpty( ) && section != null )
+        if ( configuration.getLegacyArtifactPaths().isEmpty() && section != null )
         {
             section.removeSubset( "legacyArtifactPaths" );
         }
-        if ( configuration.getRepositoryGroups( ).isEmpty( ) && section != null )
+        if ( configuration.getRepositoryGroups().isEmpty() && section != null )
         {
             section.removeSubset( "repositoryGroups" );
         }
-        if ( configuration.getRepositoryScanning( ) != null )
+        if ( configuration.getRepositoryScanning() != null )
         {
-            if ( configuration.getRepositoryScanning( ).getKnownContentConsumers( ).isEmpty( ) && section != null )
+            if ( configuration.getRepositoryScanning().getKnownContentConsumers().isEmpty() && section != null )
             {
                 section.removeSubset( "repositoryScanning.knownContentConsumers" );
             }
-            if ( configuration.getRepositoryScanning( ).getInvalidContentConsumers( ).isEmpty( ) && section != null )
+            if ( configuration.getRepositoryScanning().getInvalidContentConsumers().isEmpty() && section != null )
             {
                 section.removeSubset( "repositoryScanning.invalidContentConsumers" );
             }
         }
 
-        new ConfigurationRegistryWriter( ).write( configuration, section );
-        section.save( );
+        new ConfigurationRegistryWriter().write( configuration, section );
+        section.save();
 
         this.configuration = unescapeExpressions( configuration );
 
@@ -517,15 +517,15 @@ public class DefaultArchivaConfiguration
 
     private void escapeCronExpressions( Configuration configuration )
     {
-        for ( ManagedRepositoryConfiguration c : (List<ManagedRepositoryConfiguration>) configuration.getManagedRepositories( ) )
+        for ( ManagedRepositoryConfiguration c : (List<ManagedRepositoryConfiguration>) configuration.getManagedRepositories() )
         {
-            c.setRefreshCronExpression( escapeCronExpression( c.getRefreshCronExpression( ) ) );
+            c.setRefreshCronExpression( escapeCronExpression( c.getRefreshCronExpression() ) );
         }
 
 
     }
 
-    private Registry createDefaultConfigurationFile( )
+    private Registry createDefaultConfigurationFile()
         throws RegistryException
     {
         // TODO: may not be needed under commons-configuration 1.4 - check
@@ -552,7 +552,7 @@ public class DefaultArchivaConfiguration
 
         ( (CommonsConfigurationRegistry) registry ).setProperties( contents );
 
-        registry.initialize( );
+        registry.initialize();
 
         for ( RegistryListener regListener : registryListeners )
         {
@@ -562,7 +562,7 @@ public class DefaultArchivaConfiguration
         triggerEvent( ConfigurationEvent.SAVED );
 
         Registry section = registry.getSection( KEY + ".user" );
-        return section == null ? new CommonsConfigurationRegistry( new BaseConfiguration( ) ) : section;
+        return section == null ? new CommonsConfigurationRegistry( new BaseConfiguration() ) : section;
     }
 
     /**
@@ -582,10 +582,10 @@ public class DefaultArchivaConfiguration
         try
         {
             // Check parent directory (if it is declared)
-            if ( file.getParentFile( ) != null )
+            if ( file.getParentFile() != null )
             {
                 // Check that directory exists
-                if ( ( file.getParentFile( ).exists( ) == false ) || ( file.getParentFile( ).isDirectory( ) == false ) )
+                if ( ( file.getParentFile().exists() == false ) || ( file.getParentFile().isDirectory() == false ) )
                 {
                     // Directory to file must exist for file to be created
                     return false;
@@ -597,7 +597,7 @@ public class DefaultArchivaConfiguration
         }
         catch ( IOException e )
         {
-            log.error( "Unable to create " + filetype + " file: " + e.getMessage( ), e );
+            log.error( "Unable to create " + filetype + " file: " + e.getMessage(), e );
             return false;
         }
     }
@@ -654,7 +654,7 @@ public class DefaultArchivaConfiguration
     }
 
     @PostConstruct
-    public void initialize( )
+    public void initialize()
     {
 
         this.postPolicies = componentContainer.buildMapWithRole( PostDownloadPolicy.class );
@@ -662,8 +662,8 @@ public class DefaultArchivaConfiguration
         // Resolve expressions in the userConfigFilename and altConfigFilename
         try
         {
-            ExpressionEvaluator expressionEvaluator = new DefaultExpressionEvaluator( );
-            expressionEvaluator.addExpressionSource( new SystemPropertyExpressionSource( ) );
+            ExpressionEvaluator expressionEvaluator = new DefaultExpressionEvaluator();
+            expressionEvaluator.addExpressionSource( new SystemPropertyExpressionSource() );
             String userConfigFileNameSysProps = System.getProperty( "archiva.user.configFileName" );
             if ( StringUtils.isNotBlank( userConfigFileNameSysProps ) )
             {
@@ -674,16 +674,16 @@ public class DefaultArchivaConfiguration
                 userConfigFilename = expressionEvaluator.expand( userConfigFilename );
             }
             altConfigFilename = expressionEvaluator.expand( altConfigFilename );
-            loadConfiguration( );
-            handleUpgradeConfiguration( );
+            loadConfiguration();
+            handleUpgradeConfiguration();
         }
         catch ( IndeterminateConfigurationException e )
         {
-            throw new RuntimeException( "failed during upgrade from previous version" + e.getMessage( ), e );
+            throw new RuntimeException( "failed during upgrade from previous version" + e.getMessage(), e );
         }
         catch ( RegistryException e )
         {
-            throw new RuntimeException( "failed during upgrade from previous version" + e.getMessage( ), e );
+            throw new RuntimeException( "failed during upgrade from previous version" + e.getMessage(), e );
         }
         catch ( EvaluatorException e )
         {
@@ -696,7 +696,7 @@ public class DefaultArchivaConfiguration
     /**
      * upgrade from 1.3
      */
-    private void handleUpgradeConfiguration( )
+    private void handleUpgradeConfiguration()
         throws RegistryException, IndeterminateConfigurationException
     {
 
@@ -704,13 +704,13 @@ public class DefaultArchivaConfiguration
 
         // remove database consumers  if here
         List<String> intersec =
-            ListUtils.intersection( dbConsumers, configuration.getRepositoryScanning( ).getKnownContentConsumers( ) );
+            ListUtils.intersection( dbConsumers, configuration.getRepositoryScanning().getKnownContentConsumers() );
 
-        if ( !intersec.isEmpty( ) )
+        if ( !intersec.isEmpty() )
         {
 
-            List<String> knowContentConsumers = new ArrayList<String>( );
-            for ( String knowContentConsumer : configuration.getRepositoryScanning( ).getKnownContentConsumers( ) )
+            List<String> knowContentConsumers = new ArrayList<String>();
+            for ( String knowContentConsumer : configuration.getRepositoryScanning().getKnownContentConsumers() )
             {
                 if ( !dbConsumers.contains( knowContentConsumer ) )
                 {
@@ -718,42 +718,42 @@ public class DefaultArchivaConfiguration
                 }
             }
 
-            configuration.getRepositoryScanning( ).setKnownContentConsumers( knowContentConsumers );
+            configuration.getRepositoryScanning().setKnownContentConsumers( knowContentConsumers );
         }
 
         // ensure create-archiva-metadata is here
-        if ( !configuration.getRepositoryScanning( ).getKnownContentConsumers( ).contains( "create-archiva-metadata" ) )
+        if ( !configuration.getRepositoryScanning().getKnownContentConsumers().contains( "create-archiva-metadata" ) )
         {
             List<String> knowContentConsumers =
-                new ArrayList<String>( configuration.getRepositoryScanning( ).getKnownContentConsumers( ) );
+                new ArrayList<String>( configuration.getRepositoryScanning().getKnownContentConsumers() );
             knowContentConsumers.add( "create-archiva-metadata" );
-            configuration.getRepositoryScanning( ).setKnownContentConsumers( knowContentConsumers );
+            configuration.getRepositoryScanning().setKnownContentConsumers( knowContentConsumers );
         }
 
         // ensure duplicate-artifacts is here
-        if ( !configuration.getRepositoryScanning( ).getKnownContentConsumers( ).contains( "duplicate-artifacts" ) )
+        if ( !configuration.getRepositoryScanning().getKnownContentConsumers().contains( "duplicate-artifacts" ) )
         {
             List<String> knowContentConsumers =
-                new ArrayList<String>( configuration.getRepositoryScanning( ).getKnownContentConsumers( ) );
+                new ArrayList<String>( configuration.getRepositoryScanning().getKnownContentConsumers() );
             knowContentConsumers.add( "duplicate-artifacts" );
-            configuration.getRepositoryScanning( ).setKnownContentConsumers( knowContentConsumers );
+            configuration.getRepositoryScanning().setKnownContentConsumers( knowContentConsumers );
         }
         // save ??
         //save( configuration );
     }
 
-    public void reload( )
+    public void reload()
     {
         this.configuration = null;
         try
         {
-            this.registry.initialize( );
+            this.registry.initialize();
         }
         catch ( RegistryException e )
         {
-            throw new ConfigurationRuntimeException( e.getMessage( ), e );
+            throw new ConfigurationRuntimeException( e.getMessage(), e );
         }
-        this.initialize( );
+        this.initialize();
     }
 
     public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
@@ -788,11 +788,11 @@ public class DefaultArchivaConfiguration
     private Configuration unescapeExpressions( Configuration config )
     {
         // TODO: for commons-configuration 1.3 only
-        for ( Iterator<ManagedRepositoryConfiguration> i = config.getManagedRepositories( ).iterator( ); i.hasNext( ); )
+        for ( Iterator<ManagedRepositoryConfiguration> i = config.getManagedRepositories().iterator(); i.hasNext(); )
         {
-            ManagedRepositoryConfiguration c = i.next( );
-            c.setLocation( removeExpressions( c.getLocation( ) ) );
-            c.setRefreshCronExpression( unescapeCronExpression( c.getRefreshCronExpression( ) ) );
+            ManagedRepositoryConfiguration c = i.next();
+            c.setLocation( removeExpressions( c.getLocation() ) );
+            c.setRefreshCronExpression( unescapeCronExpression( c.getRefreshCronExpression() ) );
         }
 
         return config;
@@ -802,37 +802,37 @@ public class DefaultArchivaConfiguration
     {
         // additional check for [MRM-789], ensure that the location of the default repositories 
         // are not installed in the server installation        
-        for ( ManagedRepositoryConfiguration repo : (List<ManagedRepositoryConfiguration>) config.getManagedRepositories( ) )
+        for ( ManagedRepositoryConfiguration repo : (List<ManagedRepositoryConfiguration>) config.getManagedRepositories() )
         {
-            String repoPath = repo.getLocation( );
+            String repoPath = repo.getLocation();
             File repoLocation = new File( repoPath );
 
-            if ( repoLocation.exists( ) && repoLocation.isDirectory( ) && !repoPath.endsWith(
-                "data/repositories/" + repo.getId( ) ) )
+            if ( repoLocation.exists() && repoLocation.isDirectory() && !repoPath.endsWith(
+                "data/repositories/" + repo.getId() ) )
             {
-                repo.setLocation( repoPath + "/data/repositories/" + repo.getId( ) );
+                repo.setLocation( repoPath + "/data/repositories/" + repo.getId() );
             }
         }
 
         return config;
     }
 
-    public String getUserConfigFilename( )
+    public String getUserConfigFilename()
     {
         return userConfigFilename;
     }
 
-    public String getAltConfigFilename( )
+    public String getAltConfigFilename()
     {
         return altConfigFilename;
     }
 
-    public boolean isDefaulted( )
+    public boolean isDefaulted()
     {
         return this.isConfigurationDefaulted;
     }
 
-    public Registry getRegistry( )
+    public Registry getRegistry()
     {
         return registry;
     }