aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-webapp
diff options
context:
space:
mode:
authorJames William Dumay <jdumay@apache.org>2008-12-16 02:13:25 +0000
committerJames William Dumay <jdumay@apache.org>2008-12-16 02:13:25 +0000
commit20080174a488ad524cdacedc14048ad042b55648 (patch)
tree75acc2a5ea7e980b6f927d0ec33201dae467b994 /archiva-modules/archiva-web/archiva-webapp
parent679221b1eac8128a9f923363bbc67108057c538d (diff)
downloadarchiva-20080174a488ad524cdacedc14048ad042b55648.tar.gz
archiva-20080174a488ad524cdacedc14048ad042b55648.zip
MRM-1037 - Search Usability
* timestamp versions are merged to -SNAPSHOT versions * duplicate artifacts are now merge by use of boolean filters * we now search the correct fields * content search has been removed (more accurate results) * added more tokenizers for groupId, artifactId, version, etc * Artifact Id's are weighted to improve quicksearch results git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@726928 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webapp')
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java41
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java7
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp29
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/tags/showArtifactLink.tag5
4 files changed, 56 insertions, 26 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
index 939dbc51a..c3d9194fb 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
@@ -46,6 +46,9 @@ import org.apache.maven.archiva.security.UserRepositories;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.Preparable;
+import org.apache.maven.archiva.common.utils.VersionUtil;
+import org.apache.maven.archiva.database.constraints.UniqueVersionConstraint;
+import org.apache.maven.archiva.indexer.search.SearchResultHit;
/**
* Search all indexed fields by the given criteria.
@@ -127,8 +130,6 @@ public class SearchAction
private boolean fromResultsPage;
- private int num;
-
public boolean isFromResultsPage()
{
return fromResultsPage;
@@ -231,7 +232,8 @@ public class SearchAction
return GlobalResults.ACCESS_TO_NO_REPOS;
}
- if( SearchUtil.isBytecodeSearch( q ) )
+ final boolean isbytecodeSearch = SearchUtil.isBytecodeSearch( q );
+ if( isbytecodeSearch )
{
results = crossRepoSearch.searchForBytecode( getPrincipal(), selectedRepos, SearchUtil.removeBytecodeKeyword( q ), limits );
}
@@ -274,9 +276,41 @@ public class SearchAction
buildCompleteQueryString( q );
}
+ if (!isbytecodeSearch)
+ {
+ //Lets get the versions for the artifact we just found and display them
+ //Yes, this is in the lucene index but its more challenging to get them out when we are searching by project
+ for (SearchResultHit resultHit : results.getHits())
+ {
+ final List<String> versions = dao.query(new UniqueVersionConstraint(getObservableRepos(), resultHit.getGroupId(), resultHit.getArtifactId()));
+ if (versions != null && !versions.isEmpty())
+ {
+ resultHit.setVersion(null);
+ resultHit.setVersions(filterTimestampedSnapshots(versions));
+ }
+ }
+ }
+
return SUCCESS;
}
+ /**
+ * Remove timestamped snapshots from versions
+ */
+ private static List<String> filterTimestampedSnapshots(List<String> versions)
+ {
+ final List<String> filtered = new ArrayList<String>();
+ for (final String version : versions)
+ {
+ final String baseVersion = VersionUtil.getBaseVersion(version);
+ if (!filtered.contains(baseVersion))
+ {
+ filtered.add(baseVersion);
+ }
+ }
+ return filtered;
+ }
+
public String findArtifact()
throws Exception
{
@@ -329,7 +363,6 @@ public class SearchAction
catch ( AccessDeniedException e )
{
getLogger().warn( e.getMessage(), e );
- // TODO: pass this onto the screen.
}
catch ( ArchivaSecurityException e )
{
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
index 56fd71aa0..8ec411f0d 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
@@ -108,10 +108,10 @@ public class ShowArtifactAction
this.repositoryId =
repoBrowsing.getRepositoryId( getPrincipal(), getObservableRepos(), groupId, artifactId, version );
}
- catch ( ObjectNotFoundException oe )
+ catch ( ObjectNotFoundException e )
{
- addActionError( "Unable to find project model for [" + groupId + ":" + artifactId + ":" + version + "]." );
-
+ getLogger().debug(e.getMessage(), e);
+ addActionError( e.getMessage() );
return ERROR;
}
@@ -208,6 +208,7 @@ public class ShowArtifactAction
return Collections.emptyList();
}
+ @Override
public void validate()
{
if ( StringUtils.isBlank( groupId ) )
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
index 57ba124db..971f00252 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
@@ -20,7 +20,7 @@
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ 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" %>
+<%@ taglib prefix="archiva" tagdir="/WEB-INF/tags" %>
<html>
<head>
@@ -135,10 +135,10 @@
<s:param name="className" value="%{#attr.className}"/>
<s:param name="repositoryId" value="%{#attr.repositoryId}"/>
<s:param name="filterSearch" value="%{#attr.filterSearch}"/>
- <s:param name="fromResultsPage" value="true"/>
+ <s:param name="fromResultsPage" value="true"/>
<s:param name="currentPage" value="%{#attr.currentPage - 1}"/>
- <s:param name="searchResultsOnly" value="%{#attr.searchResultsOnly}"/>
- <s:param name="completeQueryString" value="%{#attr.completeQueryString}"/>
+ <s:param name="searchResultsOnly" value="%{#attr.searchResultsOnly}"/>
+ <s:param name="completeQueryString" value="%{#attr.completeQueryString}"/>
</s:url>
</c:set>
<c:set var="nextPageUrl">
@@ -151,10 +151,10 @@
<s:param name="className" value="%{#attr.className}"/>
<s:param name="repositoryId" value="%{#attr.repositoryId}"/>
<s:param name="filterSearch" value="%{#attr.filterSearch}"/>
- <s:param name="fromResultsPage" value="true"/>
+ <s:param name="fromResultsPage" value="true"/>
<s:param name="currentPage" value="%{#attr.currentPage + 1}"/>
- <s:param name="searchResultsOnly" value="%{#attr.searchResultsOnly}"/>
- <s:param name="completeQueryString" value="%{#attr.completeQueryString}"/>
+ <s:param name="searchResultsOnly" value="%{#attr.searchResultsOnly}"/>
+ <s:param name="completeQueryString" value="%{#attr.completeQueryString}"/>
</s:url>
</c:set>
</c:if>
@@ -259,12 +259,12 @@
<c:choose>
<c:when test="${not empty (record.groupId)}">
<h3 class="artifact-title">
- <my:showArtifactTitle groupId="${record.groupId}" artifactId="${record.artifactId}"
- version="${record.version}"/>
+
+ <archiva:showArtifactTitle groupId="${record.groupId}" artifactId="${record.artifactId}"/>
</h3>
<p>
- <my:showArtifactLink groupId="${record.groupId}" artifactId="${record.artifactId}"
- version="${record.version}" versions="${record.versions}" repositoryId="${record.repositoryId}"/>
+ <archiva:showArtifactLink groupId="${record.groupId}" artifactId="${record.artifactId}"
+ versions="${record.versions}" repositoryId="${record.repositoryId}"/>
</p>
</c:when>
<c:otherwise>
@@ -292,12 +292,11 @@
<c:choose>
<c:when test="${not empty (artifactModel.groupId)}">
<h3 class="artifact-title">
- <my:showArtifactTitle groupId="${artifactModel.groupId}" artifactId="${artifactModel.artifactId}"
- version="${artifactModel.version}"/>
+ <archiva:showArtifactTitle groupId="${artifactModel.groupId}" artifactId="${artifactModel.artifactId}"/>
</h3>
<p>
- <my:showArtifactLink groupId="${artifactModel.groupId}" artifactId="${artifactModel.artifactId}"
- version="${artifactModel.version}" versions="${artifactModel.versions}"/>
+ <archiva:showArtifactLink groupId="${artifactModel.groupId}" artifactId="${artifactModel.artifactId}"
+ versions="${artifactModel.versions}"/>
</p>
</c:when>
<c:otherwise>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/tags/showArtifactLink.tag b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/tags/showArtifactLink.tag
index a5327a1a3..3377bf1bb 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/tags/showArtifactLink.tag
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/tags/showArtifactLink.tag
@@ -30,10 +30,7 @@
<%@ attribute name="repositoryId" %>
<span class="artifact-link">
- <a href="${pageContext.request.contextPath}/repository/${repositoryId}">${repositoryId}</a>
- <strong> : </strong>
- <archiva:groupIdLink var="${groupId}" includeTop="false" />
-
+ <archiva:groupIdLink var="${groupId}" includeTop="false" />
<c:if test="${!empty (artifactId)}">
<c:set var="url">
<s:url action="browseArtifact" namespace="/">