formatting changes only

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@885316 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2009-11-30 02:43:00 +00:00
parent 9f389a48a0
commit 0caebfc6b6
2 changed files with 351 additions and 302 deletions

View File

@ -94,9 +94,8 @@ public class SearchServiceImpl
for ( SearchResultHit resultHit : results.getHits() )
{
// double-check all versions as done in SearchAction
final List<String> versions =
(List<String>) archivaDAO.query( new UniqueVersionConstraint( observableRepos, resultHit.getGroupId(),
resultHit.getArtifactId() ) );
final List<String> versions = (List<String>) archivaDAO.query(
new UniqueVersionConstraint( observableRepos, resultHit.getGroupId(), resultHit.getArtifactId() ) );
if ( versions != null && !versions.isEmpty() )
{
resultHit.setVersion( null );
@ -110,18 +109,23 @@ public class SearchServiceImpl
{
try
{
ArchivaProjectModel model = repoBrowsing.selectVersion( "", observableRepos, resultHit.getGroupId(), resultHit.getArtifactId(), version );
ArchivaProjectModel model =
repoBrowsing.selectVersion( "", observableRepos, resultHit.getGroupId(),
resultHit.getArtifactId(), version );
String repoId = repoBrowsing.getRepositoryId( "", observableRepos, resultHit.getGroupId(), resultHit.getArtifactId(), version );
String repoId = repoBrowsing.getRepositoryId( "", observableRepos, resultHit.getGroupId(),
resultHit.getArtifactId(), version );
Artifact artifact = null;
if ( model == null )
{
artifact = new Artifact( repoId, resultHit.getGroupId(), resultHit.getArtifactId(), version, "jar" );
artifact = new Artifact( repoId, resultHit.getGroupId(), resultHit.getArtifactId(), version,
"jar" );
}
else
{
artifact = new Artifact( repoId, model.getGroupId(), model.getArtifactId(), version, model.getPackaging() );
artifact = new Artifact( repoId, model.getGroupId(), model.getArtifactId(), version,
model.getPackaging() );
}
artifacts.add( artifact );
}
@ -173,8 +177,10 @@ public class SearchServiceImpl
for ( ArchivaArtifact archivaArtifact : artifacts )
{
Artifact artifact = new Artifact( archivaArtifact.getModel().getRepositoryId(), archivaArtifact.getModel().getGroupId(),
archivaArtifact.getModel().getArtifactId(), archivaArtifact.getModel().getVersion(), archivaArtifact.getType() );
Artifact artifact =
new Artifact( archivaArtifact.getModel().getRepositoryId(), archivaArtifact.getModel().getGroupId(),
archivaArtifact.getModel().getArtifactId(), archivaArtifact.getModel().getVersion(),
archivaArtifact.getType() );
//archivaArtifact.getModel().getWhenGathered() );
results.add( artifact );
}
@ -228,8 +234,9 @@ public class SearchServiceImpl
List<org.apache.maven.archiva.model.Dependency> modelDeps = model.getDependencies();
for ( org.apache.maven.archiva.model.Dependency dep : modelDeps )
{
Dependency dependency = new Dependency(
dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier(), dep.getType(), dep.getScope() );
Dependency dependency =
new Dependency( dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier(),
dep.getType(), dep.getScope() );
dependencies.add( dependency );
}
}
@ -256,11 +263,11 @@ public class SearchServiceImpl
List<Artifact> artifacts = new ArrayList<Artifact>();
List<String> observableRepos = xmlRpcUserRepositories.getObservableRepositories();
List<ArchivaProjectModel> dependees = repoBrowsing.getUsedBy( "", observableRepos, groupId, artifactId, version );
List<ArchivaProjectModel> dependees =
repoBrowsing.getUsedBy( "", observableRepos, groupId, artifactId, version );
for ( ArchivaProjectModel model : dependees )
{
Artifact artifact =
new Artifact( "", model.getGroupId(), model.getArtifactId(), model.getVersion(), "" );
Artifact artifact = new Artifact( "", model.getGroupId(), model.getArtifactId(), model.getVersion(), "" );
//model.getWhenIndexed() );
artifacts.add( artifact );
}

View File

@ -128,10 +128,12 @@ public class SearchServiceImplTest
SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ), results );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ),
results );
archivaDAOControl.expectAndReturn( archivaDAO.query( new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(),
resultHit.getArtifactId() ) ), null );
archivaDAOControl.expectAndReturn( archivaDAO.query(
new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(), resultHit.getArtifactId() ) ),
null );
ArchivaProjectModel model = new ArchivaProjectModel();
model.setGroupId( ARCHIVA_TEST_GROUP_ID );
@ -139,9 +141,13 @@ public class SearchServiceImplTest
model.setVersion( "1.0" );
model.setPackaging( "war" );
repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, "archiva-webapp", "1.0" ), model );
repoBrowsingControl.expectAndReturn(
repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, "archiva-webapp", "1.0" ),
model );
repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, "archiva-webapp", "1.0" ), "repo1.mirror" );
repoBrowsingControl.expectAndReturn(
repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, "archiva-webapp", "1.0" ),
"repo1.mirror" );
userReposControl.replay();
searchControl.replay();
@ -191,16 +197,20 @@ public class SearchServiceImplTest
SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ), results );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ),
results );
archivaDAOControl.expectAndReturn( archivaDAO.query( new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(),
resultHit.getArtifactId() ) ), null );
archivaDAOControl.expectAndReturn( archivaDAO.query(
new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(), resultHit.getArtifactId() ) ),
null );
repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), null );
repoBrowsingControl.expectAndReturn(
repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
null );
repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), null );
repoBrowsingControl.expectAndReturn(
repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID,
"1.0" ), null );
userReposControl.replay();
searchControl.replay();
@ -222,7 +232,8 @@ public class SearchServiceImplTest
assertEquals( ARCHIVA_TEST_ARTIFACT_ID, artifact.getArtifactId() );
assertEquals( "1.0", artifact.getVersion() );
assertEquals( "jar", artifact.getType() );
assertNull( "Repository should be null since the model was not found in the database!", artifact.getRepositoryId() );
assertNull( "Repository should be null since the model was not found in the database!",
artifact.getRepositoryId() );
}
/*
@ -305,12 +316,14 @@ public class SearchServiceImplTest
results.addHit( SearchUtil.getHitId( resultHit.getGroupId(), resultHit.getArtifactId() ), resultHit );
archivaDAOControl.expectAndReturn( archivaDAO.query( new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(),
resultHit.getArtifactId() ) ), null );
archivaDAOControl.expectAndReturn( archivaDAO.query(
new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(), resultHit.getArtifactId() ) ),
null );
SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ), results );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ),
results );
ArchivaProjectModel model = new ArchivaProjectModel();
model.setGroupId( ARCHIVA_TEST_GROUP_ID );
@ -318,11 +331,13 @@ public class SearchServiceImplTest
model.setVersion( "1.0" );
model.setPackaging( "jar" );
repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), model );
repoBrowsingControl.expectAndReturn(
repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
model );
repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), "repo1.mirror" );
repoBrowsingControl.expectAndReturn(
repoBrowsing.getRepositoryId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID,
"1.0" ), "repo1.mirror" );
userReposControl.replay();
searchControl.replay();
@ -360,7 +375,8 @@ public class SearchServiceImplTest
SearchResults results = new SearchResults();
SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "non-existent", limits, null ), results );
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "non-existent", limits, null ),
results );
userReposControl.replay();
searchControl.replay();
@ -382,7 +398,8 @@ public class SearchServiceImplTest
ArtifactsByChecksumConstraint constraint = new ArtifactsByChecksumConstraint( "a1b2c3aksjhdasfkdasasd" );
List<ArchivaArtifact> artifacts = new ArrayList<ArchivaArtifact>();
ArchivaArtifact artifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0", "", "jar", "test-repo" );
ArchivaArtifact artifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0", "", "jar", "test-repo" );
artifact.getModel().setWhenGathered( whenGathered );
artifacts.add( artifact );
@ -427,47 +444,66 @@ public class SearchServiceImplTest
results.setVersions( versions );
List<ArchivaArtifact> archivaArtifacts = new ArrayList<ArchivaArtifact>();
ArchivaArtifact archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 0 ), "", "pom", "repo1.mirror" );
ArchivaArtifact archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 0 ), "", "pom",
"repo1.mirror" );
archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact );
archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 1 ), "", "pom", "public.releases" );
archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 1 ), "", "pom",
"public.releases" );
archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact );
archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 2 ), "", "pom", "repo1.mirror" );
archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 2 ), "", "pom",
"repo1.mirror" );
archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact );
archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 3 ), "", "pom", "public.releases" );
archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 3 ), "", "pom",
"public.releases" );
archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact );
archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 4 ), "", "pom", "repo1.mirror" );
archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 4 ), "", "pom",
"repo1.mirror" );
archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact );
archivaArtifact = new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 5 ), "", "pom", "public.releases" );
archivaArtifact =
new ArchivaArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 5 ), "", "pom",
"public.releases" );
archivaArtifact.getModel().setWhenGathered( whenGathered );
archivaArtifacts.add( archivaArtifact );
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
repoBrowsingControl.expectAndReturn( repoBrowsing.selectArtifactId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID ), results );
repoBrowsingControl.expectAndReturn(
repoBrowsing.selectArtifactId( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID ),
results );
archivaDAOControl.expectAndReturn( archivaDAO.getArtifactDAO(), artifactDAO );
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 0 ), "", "pom", "repo1.mirror" ), archivaArtifacts.get( 0 ) );
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 1 ), "", "pom", "public.releases" ), archivaArtifacts.get( 1 ) );
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 2 ), "", "pom", "repo1.mirror" ), archivaArtifacts.get( 2 ) );
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 3 ), "", "pom", "public.releases" ), archivaArtifacts.get( 3 ) );
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 4 ), "", "pom", "repo1.mirror" ), archivaArtifacts.get( 4 ) );
artifactDAOControl.expectAndDefaultReturn( artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, versions.get( 5 ), "", "pom", "public.releases" ), archivaArtifacts.get( 5 ) );
artifactDAOControl.expectAndDefaultReturn(
artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 0 ), "", "pom",
"repo1.mirror" ), archivaArtifacts.get( 0 ) );
artifactDAOControl.expectAndDefaultReturn(
artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 1 ), "", "pom",
"public.releases" ), archivaArtifacts.get( 1 ) );
artifactDAOControl.expectAndDefaultReturn(
artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 2 ), "", "pom",
"repo1.mirror" ), archivaArtifacts.get( 2 ) );
artifactDAOControl.expectAndDefaultReturn(
artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 3 ), "", "pom",
"public.releases" ), archivaArtifacts.get( 3 ) );
artifactDAOControl.expectAndDefaultReturn(
artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 4 ), "", "pom",
"repo1.mirror" ), archivaArtifacts.get( 4 ) );
artifactDAOControl.expectAndDefaultReturn(
artifactDAO.getArtifact( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, versions.get( 5 ), "", "pom",
"public.releases" ), archivaArtifacts.get( 5 ) );
userReposControl.replay();
repoBrowsingControl.replay();
@ -528,12 +564,14 @@ public class SearchServiceImplTest
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
repoBrowsingControl.expectAndReturn(
repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), model );
repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
model );
repoBrowsingControl.replay();
userReposControl.replay();
List<Dependency> dependencies = searchService.getDependencies( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" );
List<Dependency> dependencies =
searchService.getDependencies( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" );
repoBrowsingControl.verify();
userReposControl.verify();
@ -551,7 +589,8 @@ public class SearchServiceImplTest
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
repoBrowsingControl.expectAndThrow(
repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), new ObjectNotFoundException( "Artifact does not exist." ) );
repoBrowsing.selectVersion( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
new ObjectNotFoundException( "Artifact does not exist." ) );
userReposControl.replay();
repoBrowsingControl.replay();
@ -606,8 +645,9 @@ public class SearchServiceImplTest
dependeeModels.add( dependeeModel );
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
repoBrowsingControl.expectAndReturn( repoBrowsing.getUsedBy( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), dependeeModels );
repoBrowsingControl.expectAndReturn(
repoBrowsing.getUsedBy( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
dependeeModels );
repoBrowsingControl.replay();
userReposControl.replay();
@ -645,15 +685,17 @@ public class SearchServiceImplTest
dependeeModels.add( dependeeModel );
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
repoBrowsingControl.expectAndReturn( repoBrowsing.getUsedBy( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), null );
repoBrowsingControl.expectAndReturn(
repoBrowsing.getUsedBy( "", observableRepoIds, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ),
null );
repoBrowsingControl.replay();
userReposControl.replay();
try
{
List<Artifact> dependees = searchService.getDependees( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" );
List<Artifact> dependees =
searchService.getDependees( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" );
fail( "An exception should have been thrown." );
}
catch ( Exception e )