archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r437570 - in /maven/archiva/trunk/archiva-webapp/src/main: java/org/apache/maven/archiva/web/action/SearchAction.java java/org/apache/maven/archiva/web/action/ShowArtifactAction.java resources/xwork.xml
Date Mon, 28 Aug 2006 06:48:47 GMT
Author: brett
Date: Sun Aug 27 23:48:46 2006
New Revision: 437570

URL: http://svn.apache.org/viewvc?rev=437570&view=rev
Log:
[MRM-144] fix some minor issues

Modified:
    maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
    maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
    maven/archiva/trunk/archiva-webapp/src/main/resources/xwork.xml

Modified: maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java?rev=437570&r1=437569&r2=437570&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
(original)
+++ maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
Sun Aug 27 23:48:46 2006
@@ -75,8 +75,6 @@
      */
     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 @@
             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 @@
             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 @@
 
         if ( searchResults.isEmpty() )
         {
-            return NO_RESULTS;
+            addActionError( "No results found" );
+            return INPUT;
         }
         if ( searchResults.size() == 1 )
         {

Modified: maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java?rev=437570&r1=437569&r2=437570&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
(original)
+++ maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
Sun Aug 27 23:48:46 2006
@@ -32,6 +32,7 @@
 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.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 @@
 
         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 @@
             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 @@
             else
             {
                 this.version = null;
-                // TODO: use version comparator!
-                Collections.sort( versions );
             }
         }
 
@@ -346,6 +418,8 @@
 
         public List getVersions()
         {
+            List versions = new ArrayList( this.versions );
+            Collections.sort( versions );
             return versions;
         }
 

Modified: maven/archiva/trunk/archiva-webapp/src/main/resources/xwork.xml
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-webapp/src/main/resources/xwork.xml?rev=437570&r1=437569&r2=437570&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-webapp/src/main/resources/xwork.xml (original)
+++ maven/archiva/trunk/archiva-webapp/src/main/resources/xwork.xml Sun Aug 27 23:48:46 2006
@@ -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>



Mime
View raw message