aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/plugins/problem-reports
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2019-08-04 22:40:04 +0200
committerMartin Stockhammer <martin_s@apache.org>2019-08-04 22:40:04 +0200
commiteca0097d857aa4739a6387c67d22a9a355a46fa1 (patch)
tree48752d7b63424b3e8b2bf47d11a692bfa69a6ff5 /archiva-modules/plugins/problem-reports
parentee2c1a7b2b623cf76c8a5deff5e8ddb836de2eaa (diff)
downloadarchiva-eca0097d857aa4739a6387c67d22a9a355a46fa1.tar.gz
archiva-eca0097d857aa4739a6387c67d22a9a355a46fa1.zip
Changing session handling for metadata API
Diffstat (limited to 'archiva-modules/plugins/problem-reports')
-rw-r--r--archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/RepositoryProblemEventListener.java6
-rw-r--r--archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java13
-rw-r--r--archiva-modules/plugins/problem-reports/src/test/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest.java20
3 files changed, 23 insertions, 16 deletions
diff --git a/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/RepositoryProblemEventListener.java b/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/RepositoryProblemEventListener.java
index 304866a24..64b067b76 100644
--- a/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/RepositoryProblemEventListener.java
+++ b/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/RepositoryProblemEventListener.java
@@ -49,7 +49,7 @@ public class RepositoryProblemEventListener
try
{
- metadataRepository.removeMetadataFacet( repositoryId, RepositoryProblemFacet.FACET_ID, name );
+ metadataRepository.removeMetadataFacet( , repositoryId, RepositoryProblemFacet.FACET_ID, name );
}
catch ( MetadataRepositoryException e )
{
@@ -67,7 +67,7 @@ public class RepositoryProblemEventListener
try
{
MetadataRepository metadataRepository = session.getRepository();
- metadataRepository.removeMetadataFacet( repoId, RepositoryProblemFacet.FACET_ID, name );
+ metadataRepository.removeMetadataFacet( , repoId, RepositoryProblemFacet.FACET_ID, name );
session.markDirty();
}
catch ( MetadataRepositoryException e )
@@ -91,7 +91,7 @@ public class RepositoryProblemEventListener
try
{
- session.getRepository().addMetadataFacet( repoId, problem );
+ session.getRepository().addMetadataFacet( , repoId, problem );
session.markDirty();
}
catch ( MetadataRepositoryException e )
diff --git a/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java b/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java
index 95c5ac3d2..dca503eb0 100644
--- a/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java
+++ b/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java
@@ -129,7 +129,14 @@ public class DuplicateArtifactsConsumer
{
repoId = repo.getId();
this.repositoryDir = Paths.get( repo.getLocation() );
- repositorySession = repositorySessionFactory.createSession();
+ try
+ {
+ repositorySession = repositorySessionFactory.createSession();
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ e.printStackTrace( );
+ }
}
@Override
@@ -165,7 +172,7 @@ public class DuplicateArtifactsConsumer
Collection<ArtifactMetadata> results;
try
{
- results = metadataRepository.getArtifactsByChecksum( repoId, checksumSha1 );
+ results = metadataRepository.getArtifactsByChecksum( , repoId, checksumSha1 );
}
catch ( MetadataRepositoryException e )
{
@@ -217,7 +224,7 @@ public class DuplicateArtifactsConsumer
try
{
- metadataRepository.addMetadataFacet( repoId, problem );
+ metadataRepository.addMetadataFacet( , repoId, problem );
}
catch ( MetadataRepositoryException e )
{
diff --git a/archiva-modules/plugins/problem-reports/src/test/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest.java b/archiva-modules/plugins/problem-reports/src/test/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest.java
index 31c58c7e5..1dc1739c2 100644
--- a/archiva-modules/plugins/problem-reports/src/test/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest.java
+++ b/archiva-modules/plugins/problem-reports/src/test/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest.java
@@ -114,14 +114,14 @@ public class DuplicateArtifactsConsumerTest
public void testConsumerArtifactNotDuplicated()
throws Exception
{
- when( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ) ).thenReturn(
+ when( metadataRepository.getArtifactsByChecksum( , TEST_REPO, TEST_CHECKSUM ) ).thenReturn(
Arrays.asList( TEST_METADATA ) );
consumer.beginScan( config, new Date() );
consumer.processFile( TEST_FILE );
consumer.completeScan();
- verify( metadataRepository, never() ).addMetadataFacet( eq( TEST_REPO ), Matchers.<MetadataFacet>anyObject() );
+ verify( metadataRepository, never() ).addMetadataFacet( , eq( TEST_REPO ), Matchers.<MetadataFacet>anyObject() );
}
// TODO: Doesn't currently work
@@ -142,7 +142,7 @@ public class DuplicateArtifactsConsumerTest
public void testConsumerArtifactDuplicated()
throws Exception
{
- when( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ) ).thenReturn(
+ when( metadataRepository.getArtifactsByChecksum( , TEST_REPO, TEST_CHECKSUM ) ).thenReturn(
Arrays.asList( TEST_METADATA, createMetadata( "1.0" ) ) );
consumer.beginScan( config, new Date() );
@@ -150,7 +150,7 @@ public class DuplicateArtifactsConsumerTest
consumer.completeScan();
ArgumentCaptor<RepositoryProblemFacet> argument = ArgumentCaptor.forClass( RepositoryProblemFacet.class );
- verify( metadataRepository ).addMetadataFacet( eq( TEST_REPO ), argument.capture() );
+ verify( metadataRepository ).addMetadataFacet( , eq( TEST_REPO ), argument.capture() );
RepositoryProblemFacet problem = argument.getValue();
assertProblem( problem );
}
@@ -159,7 +159,7 @@ public class DuplicateArtifactsConsumerTest
public void testConsumerArtifactDuplicatedButSelfNotInMetadataRepository()
throws Exception
{
- when( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ) ).thenReturn(
+ when( metadataRepository.getArtifactsByChecksum( , TEST_REPO, TEST_CHECKSUM ) ).thenReturn(
Arrays.asList( createMetadata( "1.0" ) ) );
consumer.beginScan( config, new Date() );
@@ -167,7 +167,7 @@ public class DuplicateArtifactsConsumerTest
consumer.completeScan();
ArgumentCaptor<RepositoryProblemFacet> argument = ArgumentCaptor.forClass( RepositoryProblemFacet.class );
- verify( metadataRepository ).addMetadataFacet( eq( TEST_REPO ), argument.capture() );
+ verify( metadataRepository ).addMetadataFacet( , eq( TEST_REPO ), argument.capture() );
RepositoryProblemFacet problem = argument.getValue();
assertProblem( problem );
}
@@ -191,7 +191,7 @@ public class DuplicateArtifactsConsumerTest
consumer.completeScan();
}
- verify( metadataRepository, never() ).addMetadataFacet( eq( TEST_REPO ), Matchers.<MetadataFacet>anyObject() );
+ verify( metadataRepository, never() ).addMetadataFacet( , eq( TEST_REPO ), Matchers.<MetadataFacet>anyObject() );
}
@Test
@@ -203,14 +203,14 @@ public class DuplicateArtifactsConsumerTest
consumer.processFile( "com/example/invalid-artifact.txt" );
consumer.completeScan();
- verify( metadataRepository, never() ).addMetadataFacet( eq( TEST_REPO ), Matchers.<MetadataFacet>anyObject() );
+ verify( metadataRepository, never() ).addMetadataFacet( , eq( TEST_REPO ), Matchers.<MetadataFacet>anyObject() );
}
@Test
public void testConsumerArtifactNotAnArtifactPathResults()
throws Exception
{
- when( metadataRepository.getArtifactsByChecksum( eq( TEST_REPO ), anyString() ) ).thenReturn(
+ when( metadataRepository.getArtifactsByChecksum( , eq( TEST_REPO ), anyString() ) ).thenReturn(
Arrays.asList( TEST_METADATA, createMetadata( "1.0" ) ) );
// override, this feels a little overspecified though
@@ -222,7 +222,7 @@ public class DuplicateArtifactsConsumerTest
consumer.processFile( "com/example/invalid-artifact.txt" );
consumer.completeScan();
- verify( metadataRepository, never() ).addMetadataFacet( eq( TEST_REPO ), Matchers.<MetadataFacet>anyObject() );
+ verify( metadataRepository, never() ).addMetadataFacet( , eq( TEST_REPO ), Matchers.<MetadataFacet>anyObject() );
}
private static void assertProblem( RepositoryProblemFacet problem )