]> source.dussan.org Git - archiva.git/commitdiff
move maven url calculation to NexusRepositorySearch rest services will just add baseUrl
authorOlivier Lamy <olamy@apache.org>
Wed, 28 Sep 2011 21:37:22 +0000 (21:37 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 28 Sep 2011 21:37:22 +0000 (21:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1177072 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java

index 9c6432290a4771ff9733d8252c5f52b70f95ac94..957b22627e942323bb32945ea9327f0af8481bcd 100644 (file)
@@ -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 )
index 6fbabbb4697423c89428eb1974bb3b03749fc3c6..120d30eadeaaf13b4fb59413e4863d3d0c662062 100644 (file)
@@ -31,6 +31,7 @@
   <properties>
     <jettyVersion>7.4.5.v20110725</jettyVersion>
     <archiva.baseRestUrl></archiva.baseRestUrl>
+    <rest.admin.pwd></rest.admin.pwd>
   </properties>
 
   <dependencies>
             <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>
index 016e816e23f00aed0b53df1ef5a67ac70fe9e880..78baad589bb3f7153332f82d7352c69c3647d352 100644 (file)
@@ -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();
     }