aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-09-14 16:03:01 +0000
committerOlivier Lamy <olamy@apache.org>2012-09-14 16:03:01 +0000
commitaaf625b9975985c150150f5f87e5ba53aea96bf6 (patch)
tree2f6604f2bf8245be44711726894aed90f7ba3cad
parent1fa95137da3db790902f52edff1cb9282687612e (diff)
downloadarchiva-aaf625b9975985c150150f5f87e5ba53aea96bf6.tar.gz
archiva-aaf625b9975985c150150f5f87e5ba53aea96bf6.zip
prevent npe
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1384832 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/FileTypes.java21
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/tags/DependencyTreeTest.java2
2 files changed, 13 insertions, 10 deletions
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/FileTypes.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/FileTypes.java
index 23a189086..93df992d6 100644
--- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/FileTypes.java
+++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/FileTypes.java
@@ -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 ) )
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/tags/DependencyTreeTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/tags/DependencyTreeTest.java
index 2aaffa9db..4c5e3a563 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/tags/DependencyTreeTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/tags/DependencyTreeTest.java
@@ -31,6 +31,7 @@ import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
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 );