diff options
author | Olivier Lamy <olamy@apache.org> | 2011-09-28 21:37:22 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2011-09-28 21:37:22 +0000 |
commit | 6b77912095c84491cbec88f7b5a67602378306ca (patch) | |
tree | 8843b9a68edace4f9ff73e029ad0cb36de8f992e /archiva-modules/archiva-base/archiva-indexer | |
parent | 45ff9153bf1c6a6483ac5ce171ab24f6e0bd3c1e (diff) | |
download | archiva-6b77912095c84491cbec88f7b5a67602378306ca.tar.gz archiva-6b77912095c84491cbec88f7b5a67602378306ca.zip |
move maven url calculation to NexusRepositorySearch rest services will just add baseUrl
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1177072 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-indexer')
-rw-r--r-- | archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java index 9c6432290..957b22627 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java @@ -248,27 +248,7 @@ public class NexusRepositorySearch { throw new RepositorySearchException( e ); } - /* - olamy : don't understand why this ?? it remove content from index ?? - comment until someone explain WTF ?? :-)) - finally - { - Map<String, IndexingContext> indexingContexts = indexer.getIndexingContexts(); - for ( Map.Entry<String, IndexingContext> entry : indexingContexts.entrySet() ) - { - try - { - indexer.removeIndexingContext( entry.getValue(), false ); - log.debug( "Indexing context '{}' removed from search.", entry.getKey() ); - } - catch ( IOException e ) - { - log.warn( "IOException occurred while removing indexing content '" + entry.getKey() + "'." ); - continue; - } - } - }*/ } private List<IndexingContext> getIndexingContexts( List<String> ids ) @@ -466,7 +446,7 @@ public class NexusRepositorySearch hit.setPrefix( artifactInfo.prefix ); hit.setPackaging( artifactInfo.packaging ); hit.setClassifier( artifactInfo.classifier ); - hit.setUrl( artifactInfo.remoteUrl ); + hit.setUrl( getBaseUrl( artifactInfo ) ); } results.addHit( id, hit ); @@ -486,6 +466,29 @@ public class NexusRepositorySearch } } + /** + * calculate baseUrl without the context and base Archiva Url + * @param artifactInfo + * @return + */ + protected String getBaseUrl( ArtifactInfo artifactInfo ) + { + StringBuilder sb = new StringBuilder( ); + + sb.append( '/' ).append( StringUtils.replaceChars( artifactInfo.groupId, '.', '/' ) ); + sb.append( '/' ).append( artifactInfo.artifactId ); + sb.append( '/' ).append( artifactInfo.version ); + sb.append( '/' ).append( artifactInfo.artifactId ); + sb.append( '-' ).append( artifactInfo.version ); + if ( StringUtils.isNotBlank( artifactInfo.classifier ) ) + { + sb.append( '-' ).append( artifactInfo.classifier ); + } + sb.append( '.' ).append( artifactInfo.packaging ); + + return sb.toString(); + } + private boolean applyArtifactInfoFilters( ArtifactInfo artifactInfo, List<? extends ArtifactInfoFiler> artifactInfoFilers, Map<String, SearchResultHit> currentResult ) |