diff options
author | Martin Stockhammer <martin_s@apache.org> | 2017-07-16 00:13:40 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2017-07-16 17:56:54 +0200 |
commit | f637c02c714952a88b999d00ecf78bb18975d0d1 (patch) | |
tree | e40b9e2d247f286f4f28bcb27682969a16a3df2e /archiva-modules/plugins/repository-statistics | |
parent | 42df217cd095a98ab935885a1c6e6e4f10a37954 (diff) | |
download | archiva-f637c02c714952a88b999d00ecf78bb18975d0d1.tar.gz archiva-f637c02c714952a88b999d00ecf78bb18975d0d1.zip |
[MRM-1957] Spliting statistics plugin module
Adding new API module (metadata-statistics-api) for statistics and move the
jcr specific tasks to the metadata store module.
Providing interfaces for the statistics API.
Removing dependencies to store specific libraries (like JCR) from the statistic
modules.
Diffstat (limited to 'archiva-modules/plugins/repository-statistics')
7 files changed, 64 insertions, 777 deletions
diff --git a/archiva-modules/plugins/repository-statistics/pom.xml b/archiva-modules/plugins/repository-statistics/pom.xml index 2d20acacb..8265ed1eb 100644 --- a/archiva-modules/plugins/repository-statistics/pom.xml +++ b/archiva-modules/plugins/repository-statistics/pom.xml @@ -34,6 +34,10 @@ </dependency> <dependency> <groupId>org.apache.archiva</groupId> + <artifactId>metadata-statistics-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.archiva</groupId> <artifactId>metadata-model-maven2</artifactId> </dependency> <dependency> @@ -41,14 +45,6 @@ <artifactId>slf4j-api</artifactId> </dependency> <dependency> - <groupId>javax.jcr</groupId> - <artifactId>jcr</artifactId> - </dependency> - <dependency> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-jcr-commons</artifactId> - </dependency> - <dependency> <groupId>org.apache.archiva</groupId> <artifactId>archiva-test-utils</artifactId> <version>${project.version}</version> @@ -60,17 +56,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-core</artifactId> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <scope>test</scope> diff --git a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java index b05bea767..f7c4dcc84 100644 --- a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java +++ b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java @@ -19,13 +19,14 @@ package org.apache.archiva.metadata.repository.stats; * under the License. */ -import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.model.maven2.MavenArtifactFacet; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; -import org.apache.archiva.metadata.repository.MetadataResolutionException; +import org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics; +import org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics; +import org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager; +import org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsProvider; +import org.apache.archiva.metadata.repository.stats.model.RepositoryWalkingStatisticsProvider; import org.apache.commons.lang.time.StopWatch; -import org.apache.jackrabbit.commons.JcrUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -33,20 +34,10 @@ import org.springframework.stereotype.Service; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.TimeZone; -import javax.jcr.Node; -import javax.jcr.RepositoryException; -import javax.jcr.Session; -import javax.jcr.query.Query; -import javax.jcr.query.QueryManager; -import javax.jcr.query.QueryResult; -import javax.jcr.query.Row; /** * @@ -59,11 +50,13 @@ public class DefaultRepositoryStatisticsManager private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" ); + private RepositoryWalkingStatisticsProvider walkingProvider = new RepositoryWalkingStatisticsProvider(); + @Override public boolean hasStatistics( MetadataRepository metadataRepository, String repositoryId ) throws MetadataRepositoryException { - return metadataRepository.hasMetadataFacet( repositoryId, RepositoryStatistics.FACET_ID ); + return metadataRepository.hasMetadataFacet( repositoryId, DefaultRepositoryStatistics.FACET_ID ); } @Override @@ -73,7 +66,7 @@ public class DefaultRepositoryStatisticsManager StopWatch stopWatch = new StopWatch(); stopWatch.start(); // TODO: consider a more efficient implementation that directly gets the last one from the content repository - List<String> scans = metadataRepository.getMetadataFacets( repositoryId, RepositoryStatistics.FACET_ID ); + List<String> scans = metadataRepository.getMetadataFacets( repositoryId, DefaultRepositoryStatistics.FACET_ID ); if ( scans == null ) { return null; @@ -95,50 +88,12 @@ public class DefaultRepositoryStatisticsManager } } - private void walkRepository( MetadataRepository metadataRepository, RepositoryStatistics stats, String repositoryId, - String ns ) - throws MetadataResolutionException - { - for ( String namespace : metadataRepository.getNamespaces( repositoryId, ns ) ) - { - walkRepository( metadataRepository, stats, repositoryId, ns + "." + namespace ); - } - - Collection<String> projects = metadataRepository.getProjects( repositoryId, ns ); - if ( !projects.isEmpty() ) - { - stats.setTotalGroupCount( stats.getTotalGroupCount() + 1 ); - stats.setTotalProjectCount( stats.getTotalProjectCount() + projects.size() ); - - for ( String project : projects ) - { - for ( String version : metadataRepository.getProjectVersions( repositoryId, ns, project ) ) - { - for ( ArtifactMetadata artifact : metadataRepository.getArtifacts( repositoryId, ns, project, - version ) ) - { - stats.setTotalArtifactCount( stats.getTotalArtifactCount() + 1 ); - stats.setTotalArtifactFileSize( stats.getTotalArtifactFileSize() + artifact.getSize() ); - - MavenArtifactFacet facet = - (MavenArtifactFacet) artifact.getFacet( MavenArtifactFacet.FACET_ID ); - if ( facet != null ) - { - String type = facet.getType(); - stats.setTotalCountForType( type, stats.getTotalCountForType( type ) + 1 ); - } - } - } - } - } - } - @Override public void addStatisticsAfterScan( MetadataRepository metadataRepository, String repositoryId, Date startTime, Date endTime, long totalFiles, long newFiles ) throws MetadataRepositoryException { - RepositoryStatistics repositoryStatistics = new RepositoryStatistics(); + DefaultRepositoryStatistics repositoryStatistics = new DefaultRepositoryStatistics(); repositoryStatistics.setRepositoryId( repositoryId ); repositoryStatistics.setScanStartTime( startTime ); repositoryStatistics.setScanEndTime( endTime ); @@ -154,23 +109,14 @@ public class DefaultRepositoryStatisticsManager long startGather = System.currentTimeMillis(); - // FIXME what about other implementations ? - - if ( metadataRepository.canObtainAccess( Session.class ) ) + if ( metadataRepository instanceof RepositoryStatisticsProvider) { - // TODO: this is currently very raw and susceptible to changes in content structure. Should we instead - // depend directly on the plugin and interrogate the JCR repository's knowledge of the structure? - populateStatisticsFromJcr( (Session) metadataRepository.obtainAccess( Session.class ), repositoryId, - repositoryStatistics ); + ((RepositoryStatisticsProvider)metadataRepository).populateStatistics( metadataRepository, + repositoryId, repositoryStatistics); } else { - // TODO: - // if the file repository is used more permanently, we may seek a more efficient mechanism - e.g. we could - // build an index, or store the aggregate information and update it on the fly. We can perhaps even walk - // but retrieve less information to speed it up. In the mean time, we walk the repository using the - // standard APIs - populateStatisticsFromRepositoryWalk( metadataRepository, repositoryId, repositoryStatistics ); + walkingProvider.populateStatistics( metadataRepository, repositoryId, repositoryStatistics ); } log.info( "Gathering statistics executed in {} ms", ( System.currentTimeMillis() - startGather ) ); @@ -178,98 +124,11 @@ public class DefaultRepositoryStatisticsManager metadataRepository.addMetadataFacet( repositoryId, repositoryStatistics ); } - private void populateStatisticsFromJcr( Session session, String repositoryId, - RepositoryStatistics repositoryStatistics ) - throws MetadataRepositoryException - { - // TODO: these may be best as running totals, maintained by observations on the properties in JCR - - try - { - QueryManager queryManager = session.getWorkspace().getQueryManager(); - - // TODO: JCR-SQL2 query will not complete on a large repo in Jackrabbit 2.2.0 - see JCR-2835 - // Using the JCR-SQL2 variants gives - // "org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024" -// String whereClause = "WHERE ISDESCENDANTNODE([/repositories/" + repositoryId + "/content])"; -// Query query = queryManager.createQuery( "SELECT size FROM [archiva:artifact] " + whereClause, -// Query.JCR_SQL2 ); - String whereClause = "WHERE jcr:path LIKE '/repositories/" + repositoryId + "/content/%'"; - Query query = queryManager.createQuery( "SELECT size FROM archiva:artifact " + whereClause, Query.SQL ); - - QueryResult queryResult = query.execute(); - - Map<String, Integer> totalByType = new HashMap<>(); - long totalSize = 0, totalArtifacts = 0; - for ( Row row : JcrUtils.getRows( queryResult ) ) - { - Node n = row.getNode(); - totalSize += row.getValue( "size" ).getLong(); - - String type; - if ( n.hasNode( MavenArtifactFacet.FACET_ID ) ) - { - Node facetNode = n.getNode( MavenArtifactFacet.FACET_ID ); - type = facetNode.getProperty( "type" ).getString(); - } - else - { - type = "Other"; - } - Integer prev = totalByType.get( type ); - totalByType.put( type, prev != null ? prev + 1 : 1 ); - - totalArtifacts++; - } - - repositoryStatistics.setTotalArtifactCount( totalArtifacts ); - repositoryStatistics.setTotalArtifactFileSize( totalSize ); - for ( Map.Entry<String, Integer> entry : totalByType.entrySet() ) - { - repositoryStatistics.setTotalCountForType( entry.getKey(), entry.getValue() ); - } - - // The query ordering is a trick to ensure that the size is correct, otherwise due to lazy init it will be -1 -// query = queryManager.createQuery( "SELECT * FROM [archiva:project] " + whereClause, Query.JCR_SQL2 ); - query = queryManager.createQuery( "SELECT * FROM archiva:project " + whereClause + " ORDER BY jcr:score", - Query.SQL ); - repositoryStatistics.setTotalProjectCount( query.execute().getRows().getSize() ); - -// query = queryManager.createQuery( -// "SELECT * FROM [archiva:namespace] " + whereClause + " AND namespace IS NOT NULL", Query.JCR_SQL2 ); - query = queryManager.createQuery( - "SELECT * FROM archiva:namespace " + whereClause + " AND namespace IS NOT NULL ORDER BY jcr:score", - Query.SQL ); - repositoryStatistics.setTotalGroupCount( query.execute().getRows().getSize() ); - } - catch ( RepositoryException e ) - { - throw new MetadataRepositoryException( e.getMessage(), e ); - } - } - - private void populateStatisticsFromRepositoryWalk( MetadataRepository metadataRepository, String repositoryId, - RepositoryStatistics repositoryStatistics ) - throws MetadataRepositoryException - { - try - { - for ( String ns : metadataRepository.getRootNamespaces( repositoryId ) ) - { - walkRepository( metadataRepository, repositoryStatistics, repositoryId, ns ); - } - } - catch ( MetadataResolutionException e ) - { - throw new MetadataRepositoryException( e.getMessage(), e ); - } - } - @Override public void deleteStatistics( MetadataRepository metadataRepository, String repositoryId ) throws MetadataRepositoryException { - metadataRepository.removeMetadataFacets( repositoryId, RepositoryStatistics.FACET_ID ); + metadataRepository.removeMetadataFacets( repositoryId, DefaultRepositoryStatistics.FACET_ID ); } @Override @@ -278,7 +137,7 @@ public class DefaultRepositoryStatisticsManager throws MetadataRepositoryException { List<RepositoryStatistics> results = new ArrayList<>(); - List<String> list = metadataRepository.getMetadataFacets( repositoryId, RepositoryStatistics.FACET_ID ); + List<String> list = metadataRepository.getMetadataFacets( repositoryId, DefaultRepositoryStatistics.FACET_ID ); Collections.sort( list, Collections.reverseOrder() ); for ( String name : list ) { @@ -290,7 +149,7 @@ public class DefaultRepositoryStatisticsManager { RepositoryStatistics stats = (RepositoryStatistics) metadataRepository.getMetadataFacet( repositoryId, - RepositoryStatistics.FACET_ID, + DefaultRepositoryStatistics.FACET_ID, name ); results.add( stats ); } @@ -306,7 +165,7 @@ public class DefaultRepositoryStatisticsManager private static SimpleDateFormat createNameFormat() { - SimpleDateFormat fmt = new SimpleDateFormat( RepositoryStatistics.SCAN_TIMESTAMP_FORMAT ); + SimpleDateFormat fmt = new SimpleDateFormat( DefaultRepositoryStatistics.SCAN_TIMESTAMP_FORMAT ); fmt.setTimeZone( UTC_TIME_ZONE ); return fmt; } 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 deleted file mode 100644 index 71cee371e..000000000 --- a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java +++ /dev/null @@ -1,323 +0,0 @@ -package org.apache.archiva.metadata.repository.stats; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * 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; - -public class RepositoryStatistics - implements MetadataFacet -{ - private Date scanEndTime; - - private Date scanStartTime; - - private long totalArtifactCount; - - private long totalArtifactFileSize; - - private long totalFileCount; - - private long totalGroupCount; - - private long totalProjectCount; - - private long newFileCount; - - public static String FACET_ID = "org.apache.archiva.metadata.repository.stats"; - - static final String SCAN_TIMESTAMP_FORMAT = "yyyy/MM/dd/HHmmss.SSS"; - - private Map<String, Long> totalCountForType = new ZeroForNullHashMap<String, Long>(); - - private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" ); - - private String repositoryId; - - public Date getScanEndTime() - { - return scanEndTime; - } - - public void setScanEndTime( Date scanEndTime ) - { - this.scanEndTime = scanEndTime; - } - - public Date getScanStartTime() - { - return scanStartTime; - } - - public void setScanStartTime( Date scanStartTime ) - { - this.scanStartTime = scanStartTime; - } - - public long getTotalArtifactCount() - { - return totalArtifactCount; - } - - public void setTotalArtifactCount( long totalArtifactCount ) - { - this.totalArtifactCount = totalArtifactCount; - } - - public long getTotalArtifactFileSize() - { - return totalArtifactFileSize; - } - - public void setTotalArtifactFileSize( long totalArtifactFileSize ) - { - this.totalArtifactFileSize = totalArtifactFileSize; - } - - public long getTotalFileCount() - { - return totalFileCount; - } - - public void setTotalFileCount( long totalFileCount ) - { - this.totalFileCount = totalFileCount; - } - - public long getTotalGroupCount() - { - return totalGroupCount; - } - - public void setTotalGroupCount( long totalGroupCount ) - { - this.totalGroupCount = totalGroupCount; - } - - public long getTotalProjectCount() - { - return totalProjectCount; - } - - public void setTotalProjectCount( long totalProjectCount ) - { - this.totalProjectCount = totalProjectCount; - } - - public void setNewFileCount( long newFileCount ) - { - this.newFileCount = newFileCount; - } - - public long getNewFileCount() - { - return newFileCount; - } - - public long getDuration() - { - return scanEndTime.getTime() - scanStartTime.getTime(); - } - - public String getRepositoryId() - { - return repositoryId; - } - - public void setRepositoryId( String repositoryId ) - { - this.repositoryId = repositoryId; - } - - @Override - public String getFacetId() - { - return FACET_ID; - } - - @Override - public String getName() - { - return createNameFormat().format( scanStartTime ); - } - - private static SimpleDateFormat createNameFormat() - { - SimpleDateFormat fmt = new SimpleDateFormat( SCAN_TIMESTAMP_FORMAT ); - fmt.setTimeZone( UTC_TIME_ZONE ); - return fmt; - } - - @Override - public Map<String, String> toProperties() - { - Map<String, String> properties = new HashMap<>(); - properties.put( "scanEndTime", String.valueOf( scanEndTime.getTime() ) ); - properties.put( "scanStartTime", String.valueOf( scanStartTime.getTime() ) ); - properties.put( "totalArtifactCount", String.valueOf( totalArtifactCount ) ); - properties.put( "totalArtifactFileSize", String.valueOf( totalArtifactFileSize ) ); - properties.put( "totalFileCount", String.valueOf( totalFileCount ) ); - properties.put( "totalGroupCount", String.valueOf( totalGroupCount ) ); - properties.put( "totalProjectCount", String.valueOf( totalProjectCount ) ); - properties.put( "newFileCount", String.valueOf( newFileCount ) ); - properties.put( "repositoryId", repositoryId ); - for ( Map.Entry<String, Long> entry : totalCountForType.entrySet() ) - { - properties.put( "count-" + entry.getKey(), String.valueOf( entry.getValue() ) ); - } - return properties; - } - - @Override - public void fromProperties( Map<String, String> properties ) - { - scanEndTime = new Date( Long.parseLong( properties.get( "scanEndTime" ) ) ); - scanStartTime = new Date( Long.parseLong( properties.get( "scanStartTime" ) ) ); - totalArtifactCount = Long.parseLong( properties.get( "totalArtifactCount" ) ); - totalArtifactFileSize = Long.parseLong( properties.get( "totalArtifactFileSize" ) ); - totalFileCount = Long.parseLong( properties.get( "totalFileCount" ) ); - totalGroupCount = Long.parseLong( properties.get( "totalGroupCount" ) ); - totalProjectCount = Long.parseLong( properties.get( "totalProjectCount" ) ); - newFileCount = Long.parseLong( properties.get( "newFileCount" ) ); - repositoryId = properties.get( "repositoryId" ); - totalCountForType.clear(); - for ( Map.Entry<String, String> entry : properties.entrySet() ) - { - if ( entry.getKey().startsWith( "count-" ) ) - { - totalCountForType.put( entry.getKey().substring( 6 ), Long.valueOf( entry.getValue() ) ); - } - } - } - - @Override - public boolean equals( Object o ) - { - if ( this == o ) - { - return true; - } - if ( o == null || getClass() != o.getClass() ) - { - return false; - } - - RepositoryStatistics that = (RepositoryStatistics) o; - - if ( newFileCount != that.newFileCount ) - { - return false; - } - if ( totalArtifactCount != that.totalArtifactCount ) - { - return false; - } - if ( totalArtifactFileSize != that.totalArtifactFileSize ) - { - return false; - } - if ( totalFileCount != that.totalFileCount ) - { - return false; - } - if ( totalGroupCount != that.totalGroupCount ) - { - return false; - } - if ( totalProjectCount != that.totalProjectCount ) - { - return false; - } - if ( !scanEndTime.equals( that.scanEndTime ) ) - { - return false; - } - if ( !scanStartTime.equals( that.scanStartTime ) ) - { - return false; - } - if ( !totalCountForType.equals( that.totalCountForType ) ) - { - return false; - } - if ( !repositoryId.equals( that.repositoryId ) ) - { - return false; - } - - return true; - } - - @Override - public int hashCode() - { - int result = scanEndTime.hashCode(); - result = 31 * result + scanStartTime.hashCode(); - result = 31 * result + (int) ( totalArtifactCount ^ ( totalArtifactCount >>> 32 ) ); - result = 31 * result + (int) ( totalArtifactFileSize ^ ( totalArtifactFileSize >>> 32 ) ); - result = 31 * result + (int) ( totalFileCount ^ ( totalFileCount >>> 32 ) ); - result = 31 * result + (int) ( totalGroupCount ^ ( totalGroupCount >>> 32 ) ); - result = 31 * result + (int) ( totalProjectCount ^ ( totalProjectCount >>> 32 ) ); - result = 31 * result + (int) ( newFileCount ^ ( newFileCount >>> 32 ) ); - result = 31 * result + totalCountForType.hashCode(); - result = 31 * result + repositoryId.hashCode(); - return result; - } - - @Override - public String toString() - { - return "RepositoryStatistics{" + "scanEndTime=" + scanEndTime + ", scanStartTime=" + scanStartTime + - ", totalArtifactCount=" + totalArtifactCount + ", totalArtifactFileSize=" + totalArtifactFileSize + - ", totalFileCount=" + totalFileCount + ", totalGroupCount=" + totalGroupCount + ", totalProjectCount=" + - totalProjectCount + ", newFileCount=" + newFileCount + ", totalCountForType=" + totalCountForType + ", " + - "repositoryId=" + repositoryId + '}'; - } - - public Map<String, Long> getTotalCountForType() - { - return totalCountForType; - } - - public long getTotalCountForType( String type ) - { - return totalCountForType.get( type ); - } - - public void setTotalCountForType( String type, long count ) - { - totalCountForType.put( type.replaceAll( "-", "_" ).replaceAll( "\\.", "_" ), 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 ); - } - } -} diff --git a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsFactory.java b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsFactory.java index 198464688..ceb911803 100644 --- a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsFactory.java +++ b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsFactory.java @@ -21,6 +21,7 @@ package org.apache.archiva.metadata.repository.stats; import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.model.MetadataFacetFactory; +import org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics; import org.springframework.stereotype.Service; /** @@ -33,12 +34,12 @@ public class RepositoryStatisticsFactory @Override public MetadataFacet createMetadataFacet() { - return new RepositoryStatistics(); + return new DefaultRepositoryStatistics(); } @Override public MetadataFacet createMetadataFacet( String repositoryId, String name ) { - return new RepositoryStatistics(); + return new DefaultRepositoryStatistics(); } }
\ No newline at end of file diff --git a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManager.java b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManager.java deleted file mode 100644 index 18332647a..000000000 --- a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManager.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.archiva.metadata.repository.stats; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.archiva.metadata.repository.MetadataRepository; -import org.apache.archiva.metadata.repository.MetadataRepositoryException; - -import java.util.Date; -import java.util.List; - -public interface RepositoryStatisticsManager -{ - RepositoryStatistics getLastStatistics( MetadataRepository metadataRepository, String repositoryId ) - throws MetadataRepositoryException; - - boolean hasStatistics( MetadataRepository metadataRepository, String repositoryId ) - throws MetadataRepositoryException; - - void addStatisticsAfterScan( MetadataRepository metadataRepository, String repositoryId, Date startTime, - Date endTime, long totalFiles, long newFiles ) - throws MetadataRepositoryException; - - void deleteStatistics( MetadataRepository metadataRepository, String repositoryId ) - throws MetadataRepositoryException; - - List<RepositoryStatistics> getStatisticsInRange( MetadataRepository metadataRepository, String repositoryId, - Date startTime, Date endTime ) - throws MetadataRepositoryException; -} diff --git a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java b/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java deleted file mode 100644 index 1a46b8727..000000000 --- a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java +++ /dev/null @@ -1,180 +0,0 @@ -package org.apache.archiva.metadata.repository.stats; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.TestCase; -import org.apache.archiva.metadata.repository.MetadataRepository; -import org.apache.archiva.metadata.repository.RepositorySessionFactory; -import org.apache.commons.io.FileUtils; -import org.apache.jackrabbit.commons.JcrUtils; -import org.apache.jackrabbit.core.TransientRepository; - -import javax.inject.Inject; -import javax.jcr.ImportUUIDBehavior; -import javax.jcr.NamespaceRegistry; -import javax.jcr.Node; -import javax.jcr.RepositoryException; -import javax.jcr.Session; -import javax.jcr.SimpleCredentials; -import javax.jcr.Workspace; -import javax.jcr.nodetype.NodeTypeManager; -import javax.jcr.nodetype.NodeTypeTemplate; -import java.io.File; -import java.io.IOException; -import java.util.Calendar; -import java.util.Date; -import java.util.zip.GZIPInputStream; - -import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.mockito.Mockito.*; - -@RunWith( ArchivaBlockJUnit4ClassRunner.class ) -public class JcrRepositoryStatisticsGatheringTest - extends TestCase -{ - private static final int TOTAL_FILE_COUNT = 1000; - - private static final int NEW_FILE_COUNT = 500; - - private static final String TEST_REPO = "test-repo"; - - private RepositoryStatisticsManager repositoryStatisticsManager; - - private MetadataRepository metadataRepository; - - @Inject - private RepositorySessionFactory repositorySessionFactory; - - private Session session; - - @Override - @Before - public void setUp() - throws Exception - { - super.setUp(); - - File confFile = new File( "src/test/repository.xml" ); - File dir = new File( "target/jcr" ); - FileUtils.deleteDirectory( dir ); - - assertTrue( confFile.exists() ); - assertFalse( dir.exists() ); - - TransientRepository repository = new TransientRepository( confFile, dir ); - session = repository.login( new SimpleCredentials( "username", "password".toCharArray() ) ); - - // TODO: perhaps have an archiva-jcr-utils module shared by these plugins that does this and can contain - // structure information - Workspace workspace = session.getWorkspace(); - NamespaceRegistry registry = workspace.getNamespaceRegistry(); - registry.registerNamespace( "archiva", "http://archiva.apache.org/jcr/" ); - - NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager(); - registerMixinNodeType( nodeTypeManager, "archiva:namespace" ); - registerMixinNodeType( nodeTypeManager, "archiva:project" ); - registerMixinNodeType( nodeTypeManager, "archiva:projectVersion" ); - registerMixinNodeType( nodeTypeManager, "archiva:artifact" ); - registerMixinNodeType( nodeTypeManager, "archiva:facet" ); - - metadataRepository = mock( MetadataRepository.class ); - when( metadataRepository.canObtainAccess( Session.class ) ).thenReturn( true ); - when( metadataRepository.obtainAccess( Session.class ) ).thenReturn( session ); - - repositoryStatisticsManager = new DefaultRepositoryStatisticsManager(); - } - - private static void registerMixinNodeType( NodeTypeManager nodeTypeManager, String type ) - throws RepositoryException - { - NodeTypeTemplate nodeType = nodeTypeManager.createNodeTypeTemplate(); - nodeType.setMixin( true ); - nodeType.setName( type ); - nodeTypeManager.registerNodeType( nodeType, false ); - } - - @Override - @After - public void tearDown() - throws Exception - { - if ( session != null ) - { - session.logout(); - } - - super.tearDown(); - } - - @Test - public void testJcrStatisticsQuery() - throws Exception - { - Calendar cal = Calendar.getInstance(); - Date endTime = cal.getTime(); - cal.add( Calendar.HOUR, -1 ); - Date startTime = cal.getTime(); - - loadContentIntoRepo( TEST_REPO ); - loadContentIntoRepo( "another-repo" ); - - repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO, startTime, endTime, - TOTAL_FILE_COUNT, NEW_FILE_COUNT ); - - RepositoryStatistics expectedStatistics = new RepositoryStatistics(); - expectedStatistics.setNewFileCount( NEW_FILE_COUNT ); - expectedStatistics.setTotalFileCount( TOTAL_FILE_COUNT ); - expectedStatistics.setScanEndTime( endTime ); - expectedStatistics.setScanStartTime( startTime ); - expectedStatistics.setTotalArtifactFileSize( 95954585 ); - expectedStatistics.setTotalArtifactCount( 269 ); - expectedStatistics.setTotalGroupCount( 1 ); - expectedStatistics.setTotalProjectCount( 43 ); - expectedStatistics.setTotalCountForType( "zip", 1 ); - expectedStatistics.setTotalCountForType( "gz", 1 ); // FIXME: should be tar.gz - expectedStatistics.setTotalCountForType( "java-source", 10 ); - expectedStatistics.setTotalCountForType( "jar", 108 ); - expectedStatistics.setTotalCountForType( "xml", 3 ); - expectedStatistics.setTotalCountForType( "war", 2 ); - expectedStatistics.setTotalCountForType( "pom", 144 ); - expectedStatistics.setRepositoryId( TEST_REPO ); - - verify( metadataRepository ).addMetadataFacet( TEST_REPO, expectedStatistics ); - } - - private void loadContentIntoRepo( String repoId ) - throws RepositoryException, IOException - { - Node n = JcrUtils.getOrAddNode( session.getRootNode(), "repositories" ); - n = JcrUtils.getOrAddNode( n, repoId ); - n = JcrUtils.getOrAddNode( n, "content" ); - n = JcrUtils.getOrAddNode( n, "org" ); - n = JcrUtils.getOrAddNode( n, "apache" ); - - GZIPInputStream inputStream = new GZIPInputStream( getClass().getResourceAsStream( "/artifacts.xml.gz" ) ); - session.importXML( n.getPath(), inputStream, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW ); - session.save(); - } -} diff --git a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java b/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java index 2ec08e6b5..b0a1742e9 100644 --- a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java +++ b/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java @@ -23,16 +23,14 @@ import junit.framework.TestCase; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.maven2.MavenArtifactFacet; import org.apache.archiva.metadata.repository.MetadataRepository; +import org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics; +import org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics; import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; import org.easymock.IMocksControl; - -import static org.easymock.EasyMock.*; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import javax.jcr.Session; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -43,6 +41,9 @@ import java.util.List; import java.util.Map; import java.util.TimeZone; +import static org.easymock.EasyMock.createControl; +import static org.easymock.EasyMock.expect; + @RunWith( ArchivaBlockJUnit4ClassRunner.class ) public class RepositoryStatisticsManagerTest extends TestCase @@ -65,7 +66,7 @@ public class RepositoryStatisticsManagerTest private static SimpleDateFormat createTimestampFormat() { - SimpleDateFormat fmt = new SimpleDateFormat( RepositoryStatistics.SCAN_TIMESTAMP_FORMAT ); + SimpleDateFormat fmt = new SimpleDateFormat( DefaultRepositoryStatistics.SCAN_TIMESTAMP_FORMAT ); fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) ); return fmt; } @@ -90,9 +91,10 @@ public class RepositoryStatisticsManagerTest Date startTime = TIMESTAMP_FORMAT.parse( SECOND_TEST_SCAN ); Date endTime = new Date( startTime.getTime() + 60000 ); - RepositoryStatistics stats = new RepositoryStatistics(); - stats.setScanStartTime( startTime ); - stats.setScanEndTime( endTime ); + DefaultRepositoryStatistics defStats = new DefaultRepositoryStatistics(); + defStats.setScanStartTime( startTime ); + defStats.setScanEndTime( endTime ); + RepositoryStatistics stats = defStats; stats.setTotalArtifactFileSize( 1314527915L ); stats.setNewFileCount( 123 ); stats.setTotalArtifactCount( 10386 ); @@ -101,10 +103,10 @@ public class RepositoryStatisticsManagerTest stats.setTotalFileCount( 56229 ); - expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( Arrays.asList( FIRST_TEST_SCAN, SECOND_TEST_SCAN ) ); - expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, SECOND_TEST_SCAN ) ).andReturn( stats ); metadataRepositoryControl.replay(); @@ -129,7 +131,7 @@ public class RepositoryStatisticsManagerTest throws Exception { - expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( Collections.<String>emptyList() ); metadataRepositoryControl.replay(); @@ -152,14 +154,12 @@ public class RepositoryStatisticsManagerTest metadataRepository.addMetadataFacet( TEST_REPO_ID, stats ); - expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( Arrays.asList( stats.getName() ) ); - expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, stats.getName() ) ).andReturn( stats ); - expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ); - metadataRepositoryControl.replay(); repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, startTime, current, 56345, @@ -188,25 +188,24 @@ public class RepositoryStatisticsManagerTest Date current = new Date(); Date startTime1 = new Date( current.getTime() - 12345 ); - RepositoryStatistics stats1 = createTestStats( startTime1, new Date( current.getTime() - 6000 ) ); + DefaultRepositoryStatistics stats1 = createTestStats( startTime1, new Date( current.getTime() - 6000 ) ); metadataRepository.addMetadataFacet( TEST_REPO_ID, stats1 ); Date startTime2 = new Date( current.getTime() - 3000 ); - RepositoryStatistics stats2 = createTestStats( startTime2, current ); + DefaultRepositoryStatistics stats2 = createTestStats( startTime2, current ); metadataRepository.addMetadataFacet( TEST_REPO_ID, stats2 ); - expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( Arrays.asList( stats1.getName(), stats2.getName() ) ); - expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, stats2.getName() ) ).andReturn( stats2 ); - metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ); + metadataRepository.removeMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ); - expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( Collections.<String>emptyList() ); - expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 2 ); metadataRepositoryControl.replay(); repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, startTime1, @@ -228,9 +227,9 @@ public class RepositoryStatisticsManagerTest throws Exception { - expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( Collections.<String>emptyList() ).times( 2 ); - metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ); + metadataRepository.removeMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ); metadataRepositoryControl.replay(); @@ -257,15 +256,14 @@ public class RepositoryStatisticsManagerTest ArrayList<String> keys = new ArrayList<>( statsCreated.keySet() ); - expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( keys ); // only match the middle one String key = keys.get( 1 ); - expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn( statsCreated.get( key ) ); - expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 ); metadataRepositoryControl.replay(); @@ -301,19 +299,18 @@ public class RepositoryStatisticsManagerTest List<String> keys = new ArrayList<>( statsCreated.keySet() ); - expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( keys ); String key = keys.get( 1 ); - expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn( statsCreated.get( key ) ); key = keys.get( 2 ); - expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn( statsCreated.get( key ) ); - expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 ); metadataRepositoryControl.replay(); @@ -349,19 +346,17 @@ public class RepositoryStatisticsManagerTest List<String> keys = new ArrayList<>( statsCreated.keySet() ); - expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( keys ); String key = keys.get( 0 ); - expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn( statsCreated.get( key ) ); key = keys.get( 1 ); - expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn( statsCreated.get( key ) ); - expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 ); - metadataRepositoryControl.replay(); for ( RepositoryStatistics stats : statsCreated.values() ) @@ -397,23 +392,21 @@ public class RepositoryStatisticsManagerTest ArrayList<String> keys = new ArrayList<>( statsCreated.keySet() ); - expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( keys ); String key = keys.get( 0 ); - expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn( statsCreated.get( key ) ); key = keys.get( 1 ); - expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn( statsCreated.get( key ) ); key = keys.get( 2 ); - expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn( statsCreated.get( key ) ); - expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 ); - metadataRepositoryControl.replay(); for ( RepositoryStatistics stats : statsCreated.values() ) @@ -449,9 +442,7 @@ public class RepositoryStatisticsManagerTest ArrayList<String> keys = new ArrayList<>( statsCreated.keySet() ); - expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys ); - - expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( keys ); metadataRepositoryControl.replay(); @@ -475,7 +466,7 @@ public class RepositoryStatisticsManagerTest private void addStats( Date startTime, Date endTime ) throws Exception { - RepositoryStatistics stats = createTestStats( startTime, endTime ); + DefaultRepositoryStatistics stats = createTestStats( startTime, endTime ); metadataRepository.addMetadataFacet( TEST_REPO_ID, stats ); statsCreated.put( stats.getName(), stats ); } @@ -498,9 +489,9 @@ public class RepositoryStatisticsManagerTest return metadata; } - private RepositoryStatistics createTestStats( Date startTime, Date endTime ) + private DefaultRepositoryStatistics createTestStats( Date startTime, Date endTime ) { - RepositoryStatistics stats = new RepositoryStatistics(); + DefaultRepositoryStatistics stats = new DefaultRepositoryStatistics(); stats.setRepositoryId( TEST_REPO_ID ); stats.setScanStartTime( startTime ); stats.setScanEndTime( endTime ); |