archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1384832 - in /archiva/trunk/archiva-modules: archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/FileTypes.java archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/tags/DependencyTreeTest.java
Date Fri, 14 Sep 2012 16:03:01 GMT
Author: olamy
Date: Fri Sep 14 16:03:01 2012
New Revision: 1384832

URL: http://svn.apache.org/viewvc?rev=1384832&view=rev
Log:
prevent npe

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/FileTypes.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/tags/DependencyTreeTest.java

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/FileTypes.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/FileTypes.java?rev=1384832&r1=1384831&r2=1384832&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/FileTypes.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/FileTypes.java
Fri Sep 14 16:03:01 2012
@@ -44,10 +44,8 @@ import java.util.Map;
 
 /**
  * FileTypes
- *
- *
  */
-@Service( "fileTypes" )
+@Service ("fileTypes")
 public class FileTypes
     implements RegistryListener
 {
@@ -63,7 +61,7 @@ public class FileTypes
      *
      */
     @Inject
-    @Named( value = "archivaConfiguration#default" )
+    @Named (value = "archivaConfiguration#default")
     private ArchivaConfiguration archivaConfiguration;
 
     /**
@@ -108,14 +106,17 @@ public class FileTypes
     {
         Configuration config = archivaConfiguration.getConfiguration();
         Predicate selectedFiletype = new FiletypeSelectionPredicate( id );
-        FileType filetype =
-            (FileType) CollectionUtils.find( config.getRepositoryScanning().getFileTypes(),
selectedFiletype );
-
-        if ( ( filetype != null ) && CollectionUtils.isNotEmpty( filetype.getPatterns()
) )
+        RepositoryScanningConfiguration repositoryScanningConfiguration = config.getRepositoryScanning();
+        if ( repositoryScanningConfiguration != null )
         {
-            return filetype.getPatterns();
-        }
+            FileType filetype =
+                (FileType) CollectionUtils.find( config.getRepositoryScanning().getFileTypes(),
selectedFiletype );
 
+            if ( ( filetype != null ) && CollectionUtils.isNotEmpty( filetype.getPatterns()
) )
+            {
+                return filetype.getPatterns();
+            }
+        }
         List<String> defaultPatterns = defaultTypeMap.get( id );
 
         if ( CollectionUtils.isEmpty( defaultPatterns ) )

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/tags/DependencyTreeTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/tags/DependencyTreeTest.java?rev=1384832&r1=1384831&r2=1384832&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/tags/DependencyTreeTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/tags/DependencyTreeTest.java
Fri Sep 14 16:03:01 2012
@@ -31,6 +31,7 @@ import org.apache.archiva.common.plexusb
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.RepositoryScanningConfiguration;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.repository.RepositorySession;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
@@ -100,6 +101,7 @@ public class DependencyTreeTest
         configuration.addManagedRepository( repoConfig );
 
         ArchivaConfiguration archivaConfiguration = applicationContext.getBean( ArchivaConfiguration.class
);
+        archivaConfiguration.getConfiguration().setRepositoryScanning( new RepositoryScanningConfiguration()
);
         archivaConfiguration.save( configuration );
 
         TestMetadataResolver metadataResolver = applicationContext.getBean( TestMetadataResolver.class
);



Mime
View raw message