}
private SearchResults search( SearchResultLimits limits, BooleanQuery q, List<String> indexingContextIds,
- List<? extends ArtifactInfoFilter> filters,
- List<String> selectedRepos, boolean includePoms)
+ List<? extends ArtifactInfoFilter> filters, List<String> selectedRepos,
+ boolean includePoms )
throws RepositorySearchException
{
private SearchResults convertToSearchResults( FlatSearchResponse response, SearchResultLimits limits,
List<? extends ArtifactInfoFilter> artifactInfoFilters,
- List<String>selectedRepos, boolean includePoms)
+ List<String> selectedRepos, boolean includePoms )
throws RepositoryAdminException
{
SearchResults results = new SearchResults();
if ( managedRepoId != null )
{
sb.append( '/' ).append( managedRepoId );
+ artifactInfo.context = managedRepoId;
}
}
else
if ( StringUtils.isNotBlank( version ) )
{
versionned.setVersion( version );
- versionned.setUrl( getArtifactUrl( versionned ) );
+ versionned.setUrl( getArtifactUrl( versionned, version ) );
artifacts.add( versionned );
/**
* TODO add a configuration mechanism to have configured the base archiva url
+ *
* @param artifact
* @return
*/
- private String getArtifactUrl( Artifact artifact )
+ private String getArtifactUrl( Artifact artifact, String version )
{
if ( httpServletRequest == null )
StringBuilder sb = new StringBuilder( getBaseUrl( httpServletRequest ) );
sb.append( "/repository" );
- if ( !StringUtils.startsWith( artifact.getUrl(), "/" ) )
+
+ sb.append( '/' ).append( artifact.getContext() );
+
+ sb.append( '/' ).append( StringUtils.replaceChars( artifact.getGroupId(), '.', '/' ) );
+ sb.append( '/' ).append( artifact.getArtifactId() );
+ sb.append( '/' ).append( artifact.getVersion() );
+ sb.append( '/' ).append( artifact.getArtifactId() );
+ sb.append( '-' ).append( artifact.getVersion() );
+ if ( StringUtils.isNotBlank( artifact.getClassifier() ) )
+ {
+ sb.append( '-' ).append( artifact.getClassifier() );
+ }
+ // maven-plugin packaging is a jar
+ if ( StringUtils.equals( "maven-plugin", artifact.getPackaging() ) )
{
- sb.append( '/' );
+ sb.append( "jar" );
}
- sb.append( artifact.getUrl() );
+ else
+ {
+ sb.append( '.' ).append( artifact.getPackaging() );
+ }
+
return sb.toString();
}
" not 2 results for Bundle Symbolic Name org.apache.karaf.features.core but " + artifacts.size() + ":"
+ artifacts, artifacts.size() == 2 );
+ for ( Artifact artifact : artifacts )
+ {
+ log.info( "url:" + artifact.getUrl() );
+ String version = artifact.getVersion();
+ assertEquals( "http://localhost:" + port
+ + "/repository/test-repo/org/apache/karaf/features/org.apache.karaf.features.core/"
+ + version + "/org.apache.karaf.features.core-" + version + ".bundle", artifact.getUrl() );
+
+
+ }
+
deleteTestRepo( testRepoId );
}