diff options
author | Brett Porter <brett@apache.org> | 2011-06-28 06:44:30 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2011-06-28 06:44:30 +0000 |
commit | 2db95ef56d57f3e919ecb83b6da7bcc184197654 (patch) | |
tree | 4e09410aecf792b60b9ec61f5f10ecbbba3b66f3 /archiva-modules/plugins | |
parent | c03b07252eb64b2452feb652616aae104476dd1f (diff) | |
download | archiva-2db95ef56d57f3e919ecb83b6da7bcc184197654.tar.gz archiva-2db95ef56d57f3e919ecb83b6da7bcc184197654.zip |
[MRM-1324] repository statistics report doesn't appear to be working correctly
Submitted by: Greg Michael Meneses
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1140450 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins')
-rw-r--r-- | archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java index 9c288278d..8e0863478 100644 --- a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java +++ b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java @@ -19,14 +19,14 @@ package org.apache.archiva.metadata.repository.stats; * under the License. */ +import org.apache.archiva.metadata.model.MetadataFacet; + import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.TimeZone; -import org.apache.archiva.metadata.model.MetadataFacet; - public class RepositoryStatistics implements MetadataFacet { @@ -50,7 +50,7 @@ public class RepositoryStatistics static final String SCAN_TIMESTAMP_FORMAT = "yyyy/MM/dd/HHmmss.SSS"; - private Map<String, Long> totalCountForType = new HashMap<String, Long>(); + private Map<String, Long> totalCountForType = new ZeroForNullHashMap<String, Long>(); private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" ); @@ -279,12 +279,21 @@ public class RepositoryStatistics public long getTotalCountForType( String type ) { - Long value = totalCountForType.get( type ); - return value != null ? value : 0; + return totalCountForType.get( type ); } public void setTotalCountForType( String type, long count ) { totalCountForType.put( type, count ); } + + private static final class ZeroForNullHashMap<K, V extends Long> extends HashMap<K, V> + { + @Override + public V get(Object key) { + V value = super.get( key ); + + return value != null ? value : ( V ) Long.valueOf( 0L ); + } + } } |