mirror of https://github.com/apache/archiva.git
[MRM-130] send single result for find artifact straight to the artifact page
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@428280 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3c2fd21b53
commit
8f10c68001
|
@ -76,6 +76,12 @@ public class SearchAction
|
||||||
*/
|
*/
|
||||||
private ConfigurationStore configurationStore;
|
private ConfigurationStore configurationStore;
|
||||||
|
|
||||||
|
private static final String NO_RESULTS = "noResults";
|
||||||
|
|
||||||
|
private static final String RESULTS = "results";
|
||||||
|
|
||||||
|
private static final String ARTIFACT = "artifact";
|
||||||
|
|
||||||
public String quickSearch()
|
public String quickSearch()
|
||||||
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException,
|
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException,
|
||||||
ConfigurationStoreException, ParseException
|
ConfigurationStoreException, ParseException
|
||||||
|
@ -104,7 +110,7 @@ public class SearchAction
|
||||||
}
|
}
|
||||||
|
|
||||||
public String findArtifact()
|
public String findArtifact()
|
||||||
throws ConfigurationStoreException, RepositoryIndexException, RepositoryIndexSearchException
|
throws Exception
|
||||||
{
|
{
|
||||||
// TODO: give action message if indexing is in progress
|
// TODO: give action message if indexing is in progress
|
||||||
|
|
||||||
|
@ -121,7 +127,18 @@ public class SearchAction
|
||||||
searchResults = index.search(
|
searchResults = index.search(
|
||||||
new LuceneQuery( new TermQuery( new Term( StandardIndexRecordFields.MD5, md5.toLowerCase() ) ) ) );
|
new LuceneQuery( new TermQuery( new Term( StandardIndexRecordFields.MD5, md5.toLowerCase() ) ) ) );
|
||||||
|
|
||||||
return SUCCESS;
|
if ( searchResults.isEmpty() )
|
||||||
|
{
|
||||||
|
return NO_RESULTS;
|
||||||
|
}
|
||||||
|
if ( searchResults.size() == 1 )
|
||||||
|
{
|
||||||
|
return ARTIFACT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return RESULTS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RepositoryArtifactIndex getIndex()
|
private RepositoryArtifactIndex getIndex()
|
||||||
|
@ -164,5 +181,4 @@ public class SearchAction
|
||||||
{
|
{
|
||||||
return searchResults;
|
return searchResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,8 @@
|
||||||
<result name="input">/WEB-INF/jsp/quickSearch.jsp</result>
|
<result name="input">/WEB-INF/jsp/quickSearch.jsp</result>
|
||||||
<result>/WEB-INF/jsp/results.jsp</result>
|
<result>/WEB-INF/jsp/results.jsp</result>
|
||||||
<result name="error">/WEB-INF/jsp/quickSearch.jsp</result>
|
<result name="error">/WEB-INF/jsp/quickSearch.jsp</result>
|
||||||
|
<result name="noResults">/WEB-INF/jsp/noResults.jsp</result>
|
||||||
|
<!-- TODO! -->
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
<action name="findArtifact" class="searchAction" method="input">
|
<action name="findArtifact" class="searchAction" method="input">
|
||||||
|
@ -58,8 +60,14 @@
|
||||||
|
|
||||||
<action name="checksumSearch" class="searchAction" method="findArtifact">
|
<action name="checksumSearch" class="searchAction" method="findArtifact">
|
||||||
<result name="input">/WEB-INF/jsp/findArtifact.jsp</result>
|
<result name="input">/WEB-INF/jsp/findArtifact.jsp</result>
|
||||||
<result>/WEB-INF/jsp/results.jsp</result>
|
<result name="results">/WEB-INF/jsp/results.jsp</result>
|
||||||
<result name="error">/WEB-INF/jsp/findArtifact.jsp</result>
|
<result name="error">/WEB-INF/jsp/findArtifact.jsp</result>
|
||||||
|
<result name="noResults">/WEB-INF/jsp/noResults.jsp</result>
|
||||||
|
<!-- TODO! -->
|
||||||
|
<!-- TODO! use redirect-action instead -->
|
||||||
|
<result name="artifact" type="redirect">
|
||||||
|
/browse/${searchResults[0].groupId}/${searchResults[0].artifactId}/${searchResults[0].version}
|
||||||
|
</result>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
<action name="browse" class="browseAction" method="browse">
|
<action name="browse" class="browseAction" method="browse">
|
||||||
|
|
Loading…
Reference in New Issue