summaryrefslogtreecommitdiffstats
path: root/archiva-web
diff options
context:
space:
mode:
authorJoakim Erdfelt <joakime@apache.org>2007-05-25 15:05:51 +0000
committerJoakim Erdfelt <joakime@apache.org>2007-05-25 15:05:51 +0000
commit0c61521ddeacaa239a4dede80efabe0642e9f463 (patch)
tree19905f2c11e5814fbdb048c910bafde9e7c56196 /archiva-web
parentcb92f4907fd38a99468204d83c7ab257a69eda8c (diff)
downloadarchiva-0c61521ddeacaa239a4dede80efabe0642e9f463.tar.gz
archiva-0c61521ddeacaa239a4dede80efabe0642e9f463.zip
[MRM-330]: Searching gives an HTTP 500
Next phase of work towards a search/find fix. Many improvements in indexer / configuration git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@541680 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-web')
-rw-r--r--archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java41
-rw-r--r--archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp81
2 files changed, 60 insertions, 62 deletions
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
index 54ae70edb..a67aca9f8 100644
--- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
+++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
@@ -19,10 +19,12 @@ package org.apache.maven.archiva.web.action;
* under the License.
*/
+import org.apache.commons.lang.StringUtils;
import org.apache.lucene.queryParser.ParseException;
import org.apache.maven.archiva.indexer.RepositoryIndexException;
import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
import org.apache.maven.archiva.indexer.search.CrossRepositorySearch;
+import org.apache.maven.archiva.indexer.search.SearchResultLimits;
import org.apache.maven.archiva.indexer.search.SearchResults;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
@@ -42,11 +44,6 @@ public class SearchAction
private String q;
/**
- * The MD5 to search by.
- */
- private String md5;
-
- /**
* The Search Results.
*/
private SearchResults results;
@@ -65,13 +62,15 @@ public class SearchAction
{
/* TODO: give action message if indexing is in progress.
* This should be based off a count of 'unprocessed' artifacts.
- * This (yet to be written) routine could tell the user that X artifacts are not yet
+ * This (yet to be written) routine could tell the user that X (unprocessed) artifacts are not yet
* present in the full text search.
*/
assert q != null && q.length() != 0;
- results = crossRepoSearch.searchForTerm( q );
+ SearchResultLimits limits = new SearchResultLimits( 0 );
+
+ results = crossRepoSearch.searchForTerm( q, limits );
if ( results.isEmpty() )
{
@@ -80,7 +79,7 @@ public class SearchAction
}
// TODO: filter / combine the artifacts by version? (is that even possible with non-artifact hits?)
-
+
/* I don't think that we should, as I expect us to utilize the 'score' system in lucene in
* the future to return relevant links better.
* I expect the lucene scoring system to take multiple hits on different areas of a single document
@@ -96,18 +95,25 @@ public class SearchAction
{
// TODO: give action message if indexing is in progress
- assert md5 != null && md5.length() != 0;
+ if ( StringUtils.isBlank( q ) )
+ {
+ addActionError( "Unable to search for a blank checksum" );
+ return INPUT;
+ }
+
+ SearchResultLimits limits = new SearchResultLimits( 0 );
+
+ results = crossRepoSearch.searchForChecksum( q, limits );
- results = crossRepoSearch.searchForMd5( q );
-
if ( results.isEmpty() )
{
addActionError( "No results found" );
return INPUT;
}
-
- if ( results.getHashcodeHits().size() == 1 )
+
+ if ( results.getHits().size() == 1 )
{
+ // 1 hit? return it's information directly!
return ARTIFACT;
}
else
@@ -131,13 +137,8 @@ public class SearchAction
this.q = q;
}
- public String getMd5()
- {
- return md5;
- }
-
- public void setMd5( String md5 )
+ public SearchResults getResults()
{
- this.md5 = md5;
+ return results;
}
}
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
index b0e1ac38d..5c11f5a4c 100644
--- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
+++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
@@ -19,6 +19,7 @@
<%@ taglib uri="/webwork" prefix="ww" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
<html>
@@ -39,48 +40,44 @@
<h1>Results</h1>
<div id="resultsBox">
- <ww:set name="searchResults" value="searchResults"/>
- <c:forEach items="${searchResults}" var="record" varStatus="i">
-
-
- <h3 class="artifact-title">
- <my:showArtifactTitle groupId="${record.groupId}" artifactId="${record.artifactId}"
- version="${record.version}"/>
- </h3>
-
- <p>
- <my:showArtifactLink groupId="${record.groupId}" artifactId="${record.artifactId}"
- version="${record.version}" versions="${record.versions}"/>
-
- <%-- TODO: hits
- <table border="1px" width="100%" cellspacing="0">
- <c:forEach items="${result.fieldMatchesEntrySet}" var="entry">
- <tr>
- <td valign="top" width="15%" align="right"><c:out value="${entry.key}"/></td>
- <td valign="top">
- <c:forEach items="${entry.value}" var="item">
- <c:out value="${item}" />
- </c:forEach>
- <br/>
- </td>
- </tr>
- </c:forEach>
- </table>
- </td>
- <td>
-
- <code>org.apache.maven</code>
- (package)
- <br/>
- <code>org.apache.maven.model</code>
- (package)
- </td>
- <td>
- <a href="artifact.html">Details</a>
- </td>
- --%>
- </p>
- </c:forEach>
+ <p>Hits: ${fn:length(results.hits)}</p>
+
+ <c:choose>
+ <c:when test="${empty results.hits}">
+ <p>No results</p>
+ </c:when>
+ <c:otherwise>
+ <c:forEach items="${results.hits}" var="record" varStatus="i">
+ <p>${record.url}</p>
+ <p>${record.groupId}</p>
+ <p>${record.artifactId}</p>
+ </c:forEach>
+ <%--
+ <c:forEach items="${results.hachcodeHits}" var="record" varStatus="i">
+ <p>${record}</p>
+ <h3 class="artifact-title">
+ <my:showArtifactTitle groupId="${record.groupId}" artifactId="${record.artifactId}"
+ version="${record.version}"/>
+ </h3>
+ <p>
+ <my:showArtifactLink groupId="${record.groupId}" artifactId="${record.artifactId}"
+ version="${record.version}" versions="${record.versions}"/>
+ </p>
+ </c:forEach>
+ <c:forEach items="${results.bytecodeHits}" var="record" varStatus="i">
+ <p>${record}</p>
+ <h3 class="artifact-title">
+ <my:showArtifactTitle groupId="${record.groupId}" artifactId="${record.artifactId}"
+ version="${record.version}"/>
+ </h3>
+ <p>
+ <my:showArtifactLink groupId="${record.groupId}" artifactId="${record.artifactId}"
+ version="${record.version}" versions="${record.versions}"/>
+ </p>
+ </c:forEach>
+ --%>
+ </c:otherwise>
+ </c:choose>
</div>
</div>
</body>