aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorolivier lamy <olamy@apache.org>2017-08-21 11:13:43 +1000
committerolivier lamy <olamy@apache.org>2017-08-21 11:13:43 +1000
commit33b66d1493a034b4f0211580db4f6d26942d7914 (patch)
tree2a9e3c6dce37f4ae49472589eb50d007ec587823 /archiva-modules
parent6cee4606ca60a6a13607b7fcb3c60deca08e67d2 (diff)
downloadarchiva-33b66d1493a034b4f0211580db4f6d26942d7914.tar.gz
archiva-33b66d1493a034b4f0211580db4f6d26942d7914.zip
get rid of some System.out
Signed-off-by: olivier lamy <olamy@apache.org>
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/AbstractMonitoredConsumer.java5
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java66
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java20
3 files changed, 49 insertions, 42 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/AbstractMonitoredConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/AbstractMonitoredConsumer.java
index 5b9155460..170847865 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/AbstractMonitoredConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/AbstractMonitoredConsumer.java
@@ -20,6 +20,8 @@ package org.apache.archiva.consumers;
*/
import org.apache.archiva.common.FileTypeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.HashSet;
import java.util.List;
@@ -33,6 +35,9 @@ import java.util.Set;
public abstract class AbstractMonitoredConsumer
implements Consumer
{
+
+ protected final Logger logger = LoggerFactory.getLogger( getClass() );
+
private final Set<ConsumerMonitor> monitors = new HashSet<ConsumerMonitor>();
@Override
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
index 9fca6b848..a4d5d5d6c 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
@@ -19,6 +19,7 @@ package org.apache.archiva.metadata.repository.jcr;
* under the License.
*/
+import com.google.common.collect.ImmutableMap;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.CiManagement;
import org.apache.archiva.metadata.model.Dependency;
@@ -40,13 +41,9 @@ import org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics;
import org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsProvider;
import org.apache.commons.lang.StringUtils;
import org.apache.jackrabbit.commons.JcrUtils;
-import org.apache.jackrabbit.oak.plugins.index.IndexUtils;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.ImmutableMap;
-
import javax.jcr.InvalidItemStateException;
import javax.jcr.NamespaceRegistry;
import javax.jcr.Node;
@@ -66,7 +63,6 @@ import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
import javax.jcr.query.Row;
import javax.jcr.query.RowIterator;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -86,7 +82,7 @@ import java.util.Set;
* TODO revise reference storage
*/
public class JcrMetadataRepository
- implements MetadataRepository,RepositoryStatisticsProvider
+ implements MetadataRepository, RepositoryStatisticsProvider
{
private static final String JCR_LAST_MODIFIED = "jcr:lastModified";
@@ -146,7 +142,6 @@ public class JcrMetadataRepository
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.DEPENDENCY_NODE_TYPE );
-
}
private static void registerMixinNodeType( NodeTypeManager nodeTypeManager, String name )
@@ -165,7 +160,6 @@ public class JcrMetadataRepository
}
-
@Override
public void updateProject( String repositoryId, ProjectMetadata project )
throws MetadataRepositoryException
@@ -750,7 +744,7 @@ public class JcrMetadataRepository
long start = Calendar.getInstance().getTimeInMillis();
QueryResult result = query.execute();
long end = Calendar.getInstance().getTimeInMillis();
- log.info( "JCR Query ran in {} milliseconds: {}", end - start , q );
+ log.info( "JCR Query ran in {} milliseconds: {}", end - start, q );
artifacts = new ArrayList<>();
RowIterator rows = result.getRows();
@@ -765,9 +759,10 @@ public class JcrMetadataRepository
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
- log.info("Artifacts found {}", artifacts.size());
- for (ArtifactMetadata meta : artifacts) {
- log.info("Artifact: "+meta.getVersion()+" "+meta.getFacetList());
+ log.info( "Artifacts found {}", artifacts.size() );
+ for ( ArtifactMetadata meta : artifacts )
+ {
+ log.info( "Artifact: " + meta.getVersion() + " " + meta.getFacetList() );
}
return artifacts;
}
@@ -789,9 +784,8 @@ public class JcrMetadataRepository
public List<ArtifactMetadata> getArtifactsByMetadata( String key, String value, String repositoryId )
throws MetadataRepositoryException
{
- String q =
- "SELECT * FROM [" + ARTIFACT_NODE_TYPE + "] AS artifact INNER JOIN [" + FACET_NODE_TYPE
- + "] AS facet ON ISCHILDNODE(facet, artifact) WHERE ([facet].[" + key + "] = $value)";
+ String q = "SELECT * FROM [" + ARTIFACT_NODE_TYPE + "] AS artifact INNER JOIN [" + FACET_NODE_TYPE
+ + "] AS facet ON ISCHILDNODE(facet, artifact) WHERE ([facet].[" + key + "] = $value)";
return runJcrQuery( repositoryId, q, ImmutableMap.of( "value", value ) );
}
@@ -860,8 +854,8 @@ public class JcrMetadataRepository
private static String getArtifactQuery( String repositoryId )
{
- return "SELECT * FROM [" + ARTIFACT_NODE_TYPE + "] AS artifact WHERE ISDESCENDANTNODE(artifact,'/" +
- getRepositoryContentPath( repositoryId ) + "')";
+ return "SELECT * FROM [" + ARTIFACT_NODE_TYPE + "] AS artifact WHERE ISDESCENDANTNODE(artifact,'/"
+ + getRepositoryContentPath( repositoryId ) + "')";
}
@Override
@@ -1109,8 +1103,8 @@ public class JcrMetadataRepository
List<ProjectVersionReference> references = new ArrayList<>();
// TODO: bind variables instead
- String q = "SELECT * FROM [archiva:dependency] WHERE ISDESCENDANTNODE([/repositories/" + repositoryId +
- "/content]) AND [groupId]='" + namespace + "' AND [artifactId]='" + projectId + "'";
+ String q = "SELECT * FROM [archiva:dependency] WHERE ISDESCENDANTNODE([/repositories/" + repositoryId
+ + "/content]) AND [groupId]='" + namespace + "' AND [artifactId]='" + projectId + "'";
if ( projectVersion != null )
{
q += " AND [version]='" + projectVersion + "'";
@@ -1361,7 +1355,9 @@ public class JcrMetadataRepository
try
{
getJcrSession().save();
- } catch ( InvalidItemStateException e ) {
+ }
+ catch ( InvalidItemStateException e )
+ {
// olamy this might happen when deleting a repo while is under scanning
log.warn( "skip InvalidItemStateException:{}", e.getMessage(), e );
}
@@ -1391,7 +1387,7 @@ public class JcrMetadataRepository
}
@Override
- public <T>T obtainAccess( Class<T> aClass )
+ public <T> T obtainAccess( Class<T> aClass )
throws MetadataRepositoryException
{
if ( aClass == Session.class )
@@ -1440,10 +1436,10 @@ public class JcrMetadataRepository
e ? "(projectVersion." + theKey + " = $value)" : "contains([projectVersion]." + theKey + ", $value)";
String facetCondition = e ? "(facet." + theKey + " = $value)" : "contains([facet]." + theKey + ", $value)";
String q =
- "SELECT * FROM [" + PROJECT_VERSION_NODE_TYPE + "] AS projectVersion LEFT OUTER JOIN ["
- + ARTIFACT_NODE_TYPE + "] AS artifact ON ISCHILDNODE(artifact, projectVersion) LEFT OUTER JOIN ["
- + FACET_NODE_TYPE + "] AS facet ON ISCHILDNODE(facet, projectVersion) WHERE ("
- + projectVersionCondition + " OR " + facetCondition + ")";
+ "SELECT * FROM [" + PROJECT_VERSION_NODE_TYPE + "] AS projectVersion LEFT OUTER JOIN [" + ARTIFACT_NODE_TYPE
+ + "] AS artifact ON ISCHILDNODE(artifact, projectVersion) LEFT OUTER JOIN [" + FACET_NODE_TYPE
+ + "] AS facet ON ISCHILDNODE(facet, projectVersion) WHERE (" + projectVersionCondition + " OR "
+ + facetCondition + ")";
return runJcrQuery( repositoryId, q, ImmutableMap.of( "value", text ) );
}
@@ -1454,7 +1450,7 @@ public class JcrMetadataRepository
ArtifactMetadata artifact = new ArtifactMetadata();
artifact.setId( id );
- artifact.setRepositoryId( repositoryId == null ? artifactNode.getAncestor(2).getName() : repositoryId );
+ artifact.setRepositoryId( repositoryId == null ? artifactNode.getAncestor( 2 ).getName() : repositoryId );
Node projectVersionNode = artifactNode.getParent();
Node projectNode = projectVersionNode.getParent();
@@ -1605,7 +1601,7 @@ public class JcrMetadataRepository
private Node getOrAddNodeByPath( Node baseNode, String name, String nodeType )
throws RepositoryException
{
- log.debug("getOrAddNodeByPath"+baseNode+" "+name+" "+nodeType);
+ log.debug( "getOrAddNodeByPath" + baseNode + " " + name + " " + nodeType );
Node node = baseNode;
for ( String n : name.split( "/" ) )
{
@@ -1626,10 +1622,10 @@ public class JcrMetadataRepository
private Node getOrAddRepositoryNode( String repositoryId )
throws RepositoryException
{
- log.debug("getOrAddRepositoryNode "+repositoryId);
+ log.debug( "getOrAddRepositoryNode " + repositoryId );
Node root = getJcrSession().getRootNode();
Node node = JcrUtils.getOrAddNode( root, "repositories" );
- log.debug("Repositories "+node);
+ log.debug( "Repositories " + node );
node = JcrUtils.getOrAddNode( node, repositoryId );
return node;
}
@@ -1711,11 +1707,13 @@ public class JcrMetadataRepository
@Override
public void populateStatistics( MetadataRepository repository, String repositoryId,
- RepositoryStatistics repositoryStatistics )
+ RepositoryStatistics repositoryStatistics )
throws MetadataRepositoryException
{
- if (!(repository instanceof JcrMetadataRepository)) {
- throw new MetadataRepositoryException( "The statistics population is only possible for JcrMetdataRepository implementations" );
+ if ( !( repository instanceof JcrMetadataRepository ) )
+ {
+ throw new MetadataRepositoryException(
+ "The statistics population is only possible for JcrMetdataRepository implementations" );
}
Session session = (Session) repository.obtainAccess( Session.class );
// TODO: these may be best as running totals, maintained by observations on the properties in JCR
@@ -1762,14 +1760,14 @@ public class JcrMetadataRepository
repositoryStatistics.setTotalArtifactFileSize( totalSize );
for ( Map.Entry<String, Integer> entry : totalByType.entrySet() )
{
- System.out.println("Setting count for type: "+entry.getKey()+" = "+entry.getValue());
+ log.info( "Setting count for type: {} = {}", entry.getKey(), entry.getValue() );
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 );
+ Query.SQL );
repositoryStatistics.setTotalProjectCount( query.execute().getRows().getSize() );
// query = queryManager.createQuery(
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java b/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java
index be07e2e73..4ae7aacd8 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java
@@ -35,6 +35,8 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
@@ -55,7 +57,8 @@ import java.util.zip.GZIPInputStream;
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
-public class JcrRepositoryStatisticsGatheringTest extends TestCase
+public class JcrRepositoryStatisticsGatheringTest
+ extends TestCase
{
private static final int TOTAL_FILE_COUNT = 1000;
@@ -73,11 +76,13 @@ public class JcrRepositoryStatisticsGatheringTest extends TestCase
Session session;
-
private static Repository jcrRepository;
+ Logger logger = LoggerFactory.getLogger( getClass() );
+
@BeforeClass
- public static void setupSpec() throws IOException, InvalidFileStoreVersionException
+ public static void setupSpec()
+ throws IOException, InvalidFileStoreVersionException
{
File directory = new File( "target/test-repositories" );
if ( directory.exists() )
@@ -102,7 +107,6 @@ public class JcrRepositoryStatisticsGatheringTest extends TestCase
// TODO: probably don't need to use Spring for this
JcrMetadataRepository jcrMetadataRepository = new JcrMetadataRepository( factories, jcrRepository );
-
session = jcrMetadataRepository.getJcrSession();
try
@@ -136,9 +140,9 @@ public class JcrRepositoryStatisticsGatheringTest extends TestCase
public void tearDown()
throws Exception
{
- if (repository!=null)
+ if ( repository != null )
{
- repository.close( );
+ repository.close();
}
}
@@ -181,9 +185,9 @@ public class JcrRepositoryStatisticsGatheringTest extends TestCase
expectedStatistics.setTotalCountForType( "pom", 144 );
expectedStatistics.setRepositoryId( TEST_REPO );
- System.out.println(testedStatistics.getTotalCountForType());
+ logger.info("getTotalCountForType: {}", testedStatistics.getTotalCountForType() );
- assertEquals( NEW_FILE_COUNT, testedStatistics.getNewFileCount());
+ assertEquals( NEW_FILE_COUNT, testedStatistics.getNewFileCount() );
assertEquals( TOTAL_FILE_COUNT, testedStatistics.getTotalFileCount() );
assertEquals( endTime, testedStatistics.getScanEndTime() );
assertEquals( startTime, testedStatistics.getScanStartTime() );