summaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-09-28 21:37:22 +0000
committerOlivier Lamy <olamy@apache.org>2011-09-28 21:37:22 +0000
commit6b77912095c84491cbec88f7b5a67602378306ca (patch)
tree8843b9a68edace4f9ff73e029ad0cb36de8f992e /archiva-modules
parent45ff9153bf1c6a6483ac5ce171ab24f6e0bd3c1e (diff)
downloadarchiva-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')
-rw-r--r--archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java45
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java26
3 files changed, 31 insertions, 42 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 )
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
index 6fbabbb46..120d30ead 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
@@ -31,6 +31,7 @@
<properties>
<jettyVersion>7.4.5.v20110725</jettyVersion>
<archiva.baseRestUrl></archiva.baseRestUrl>
+ <rest.admin.pwd></rest.admin.pwd>
</properties>
<dependencies>
@@ -255,6 +256,7 @@
<appserver.base>${basedir}/target/appserver-base</appserver.base>
<java.io.tmpdir>${project.build.outputDirectory}</java.io.tmpdir>
<archiva.baseRestUrl>${archiva.baseRestUrl}</archiva.baseRestUrl>
+ <rest.admin.pwd>${rest.admin.pwd}</rest.admin.pwd>
</systemPropertyVariables>
</configuration>
</plugin>
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java
index 016e816e2..78baad589 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java
@@ -251,30 +251,14 @@ public class DefaultSearchService
{
return null;
}
- StringBuilder sb = new StringBuilder( getBaseUrl( httpContext.getHttpServletRequest() ) );
-
- sb.append( "/repository" );
-
- if ( StringUtils.startsWith( artifact.getContext(), "remote-" ) )
- {
- // if context is 'remote-*' we have to set a repo which the current user can use
- }
- else
+ if (StringUtils.isEmpty( 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() );
- if ( StringUtils.isNotBlank( artifact.getClassifier() ) )
- {
- sb.append( '-' ).append( artifact.getClassifier() );
+ return null;
}
- sb.append( '-' ).append( artifact.getVersion() );
- sb.append( '.' ).append( artifact.getPackaging() );
+ StringBuilder sb = new StringBuilder( getBaseUrl( httpContext.getHttpServletRequest() ) );
+ sb.append( "/repository/" );
+ sb.append( artifact.getUrl() );
return sb.toString();
}