[MRM-144] fix some minor issues

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@437570 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-08-28 06:48:46 +00:00
parent a0b0073b59
commit 6d9088f7e6
3 changed files with 86 additions and 12 deletions

View File

@ -75,8 +75,6 @@ public class SearchAction
*/
private ConfigurationStore configurationStore;
private static final String NO_RESULTS = "noResults";
private static final String RESULTS = "results";
private static final String ARTIFACT = "artifact";
@ -97,7 +95,6 @@ public class SearchAction
return ERROR;
}
// TODO! this is correct, but ugly
MultiFieldQueryParser parser = new MultiFieldQueryParser( new String[]{StandardIndexRecordFields.GROUPID,
StandardIndexRecordFields.ARTIFACTID, StandardIndexRecordFields.BASE_VERSION,
StandardIndexRecordFields.CLASSIFIER, StandardIndexRecordFields.CLASSES, StandardIndexRecordFields.FILES,
@ -105,6 +102,12 @@ public class SearchAction
StandardIndexRecordFields.PROJECT_DESCRIPTION}, new StandardAnalyzer() );
searchResults = index.search( new LuceneQuery( parser.parse( q ) ) );
if ( searchResults.isEmpty() )
{
addActionError( "No results found" );
return INPUT;
}
return SUCCESS;
}
@ -128,7 +131,8 @@ public class SearchAction
if ( searchResults.isEmpty() )
{
return NO_RESULTS;
addActionError( "No results found" );
return INPUT;
}
if ( searchResults.size() == 1 )
{

View File

@ -32,6 +32,7 @@ import org.apache.maven.archiva.indexer.record.StandardArtifactIndexRecord;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;
@ -45,10 +46,12 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Browse the repository.
@ -278,7 +281,10 @@ public class ShowArtifactAction
private final String artifactId;
private List versions = new ArrayList();
/**
* Versions added. We ignore duplicates since you might add those with varying classifiers.
*/
private Set versions = new HashSet();
private String version;
@ -318,9 +324,77 @@ public class ShowArtifactAction
return classifier;
}
private static class Ver
{
private int buildNumber;
private int major;
private int minor;
private int incremental;
private String qualifier;
}
public void addVersion( String version )
{
versions.add( version );
// We use DefaultArtifactVersion to get the correct sorting order later, however it does not have
// hashCode properly implemented, so we add it here.
// TODO: add these methods to the actual DefaultArtifactVersion and use that.
versions.add( new DefaultArtifactVersion( version )
{
public int hashCode()
{
int result;
result = getBuildNumber();
result = 31 * result + getMajorVersion();
result = 31 * result + getMinorVersion();
result = 31 * result + getIncrementalVersion();
result = 31 * result + ( getQualifier() != null ? getQualifier().hashCode() : 0 );
return result;
}
public boolean equals( Object o )
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
DefaultArtifactVersion that = (DefaultArtifactVersion) o;
if ( getBuildNumber() != that.getBuildNumber() )
{
return false;
}
if ( getIncrementalVersion() != that.getIncrementalVersion() )
{
return false;
}
if ( getMajorVersion() != that.getMajorVersion() )
{
return false;
}
if ( getMinorVersion() != that.getMinorVersion() )
{
return false;
}
if ( getQualifier() != null ? !getQualifier().equals( that.getQualifier() )
: that.getQualifier() != null )
{
return false;
}
return true;
}
} );
if ( versions.size() == 1 )
{
@ -329,8 +403,6 @@ public class ShowArtifactAction
else
{
this.version = null;
// TODO: use version comparator!
Collections.sort( versions );
}
}
@ -346,6 +418,8 @@ public class ShowArtifactAction
public List getVersions()
{
List versions = new ArrayList( this.versions );
Collections.sort( versions );
return versions;
}

View File

@ -76,8 +76,6 @@
<result name="input">/WEB-INF/jsp/quickSearch.jsp</result>
<result>/WEB-INF/jsp/results.jsp</result>
<result name="error">/WEB-INF/jsp/quickSearch.jsp</result>
<result name="noResults">/WEB-INF/jsp/noResults.jsp</result>
<!-- TODO! -->
</action>
<action name="findArtifact" class="searchAction" method="input">
@ -88,8 +86,6 @@
<result name="input">/WEB-INF/jsp/findArtifact.jsp</result>
<result name="results">/WEB-INF/jsp/results.jsp</result>
<result name="error">/WEB-INF/jsp/findArtifact.jsp</result>
<result name="noResults">/WEB-INF/jsp/noResults.jsp</result>
<!-- TODO! -->
<result name="artifact" type="redirect">
/browse/${searchResults[0].groupId}/${searchResults[0].artifactId}/${searchResults[0].version}
</result>