maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r424579 - in /maven/repository-manager/trunk/maven-repository-indexer/src: main/java/org/apache/maven/repository/indexing/ test/java/org/apache/maven/repository/indexing/ test/repository/org/apache/maven/maven-corrupt-jar/ test/repository/o...
Date Sat, 22 Jul 2006 14:19:13 GMT
Author: brett
Date: Sat Jul 22 07:19:12 2006
New Revision: 424579

URL: http://svn.apache.org/viewvc?rev=424579&view=rev
Log:
test and better handling for corrupt JARs when indexing

Added:
    maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/
    maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/2.0/
    maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/2.0/maven-corrupt-jar-2.0.jar
    maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/2.0/maven-corrupt-jar-2.0.pom
  (with props)
Modified:
    maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndex.java
    maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java

Modified: maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndex.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndex.java?rev=424579&r1=424578&r2=424579&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndex.java
(original)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndex.java
Sat Jul 22 07:19:12 2006
@@ -111,10 +111,8 @@
      *
      * @param artifactList
      * @return
-     * @throws RepositoryIndexException
      */
     private List getDocumentList( List artifactList )
-        throws RepositoryIndexException
     {
         List list = new ArrayList();
 
@@ -122,7 +120,15 @@
         {
             Artifact artifact = (Artifact) artifacts.next();
 
-            list.add( createDocument( artifact ) );
+            try
+            {
+                list.add( createDocument( artifact ) );
+            }
+            catch ( RepositoryIndexException e )
+            {
+                // TODO: log the problem and record it as a repository error
+                // We log the problem, but do not add the document to the list to be added
to the index
+            }
         }
 
         return list;
@@ -268,7 +274,7 @@
 
         try
         {
-            for ( int i = 0; i < indexReader.numDocs(); i ++ )
+            for ( int i = 0; i < indexReader.numDocs(); i++ )
             {
                 Document doc = indexReader.document( i );
                 groups.add( doc.getField( FLD_GROUPID ).stringValue() );
@@ -293,7 +299,7 @@
 
         try
         {
-            for ( int i = 0; i < indexReader.numDocs(); i ++ )
+            for ( int i = 0; i < indexReader.numDocs(); i++ )
             {
                 Document doc = indexReader.document( i );
                 if ( doc.getField( FLD_GROUPID ).stringValue().equals( groupId ) )
@@ -321,7 +327,7 @@
 
         try
         {
-            for ( int i = 0; i < indexReader.numDocs(); i ++ )
+            for ( int i = 0; i < indexReader.numDocs(); i++ )
             {
                 Document doc = indexReader.document( i );
                 if ( doc.getField( FLD_GROUPID ).stringValue().equals( groupId ) &&

Modified: maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java?rev=424579&r1=424578&r2=424579&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java
(original)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java
Sat Jul 22 07:19:12 2006
@@ -30,9 +30,9 @@
 import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.ArrayList;
 
 /**
  * @author Edwin Punzalan
@@ -449,6 +449,30 @@
         Artifact artifact = getArtifact( "org.apache.maven", "maven-artifact", "2.0.1" );
         artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact
) ) );
         indexer.deleteDocument( RepositoryIndex.FLD_ID, RepositoryIndex.ARTIFACT + artifact.getId()
);
+
+        Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_ID, RepositoryIndex.ARTIFACT
+ artifact.getId() );
+        List artifacts = repoSearcher.search( qry, indexer );
+        assertEquals( 0, artifacts.size() );
+    }
+
+    /**
+     * Test delete of document from the artifact index.
+     *
+     * @throws Exception
+     */
+    public void testCorruptJar()
+        throws Exception
+    {
+        createTestIndex();
+
+        RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE
);
+        RepositoryIndexSearcher repoSearcher = (RepositoryIndexSearcher) lookup( RepositoryIndexSearcher.ROLE
);
+
+        ArtifactRepositoryIndex indexer = factory.createArtifactRepositoryIndex( indexPath,
repository );
+
+        Artifact artifact = getArtifact( "org.apache.maven", "maven-corrupt-jar", "2.0" );
+        artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact
) ) );
+        indexer.indexArtifact( artifact );
 
         Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_ID, RepositoryIndex.ARTIFACT
+ artifact.getId() );
         List artifacts = repoSearcher.search( qry, indexer );

Added: maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/2.0/maven-corrupt-jar-2.0.jar
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/2.0/maven-corrupt-jar-2.0.jar?rev=424579&view=auto
==============================================================================
    (empty)

Added: maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/2.0/maven-corrupt-jar-2.0.pom
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/2.0/maven-corrupt-jar-2.0.pom?rev=424579&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/2.0/maven-corrupt-jar-2.0.pom
(added)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/2.0/maven-corrupt-jar-2.0.pom
Sat Jul 22 07:19:12 2006
@@ -0,0 +1,95 @@
+<project>
+  <parent>
+    <artifactId>maven</artifactId>
+    <groupId>org.apache.maven</groupId>
+    <version>2.0</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven</groupId>
+  <artifactId>maven-corrupt-jar</artifactId>
+  <name>Maven Model</name>
+  <version>2.0</version>
+  <description>Maven Model</description>
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.modello</groupId>
+        <artifactId>modello-maven-plugin</artifactId>
+        <version>2.0</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>xpp3-writer</goal>
+              <goal>java</goal>
+              <goal>xpp3-reader</goal>
+              <goal>xsd</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <version>4.0.0</version>
+          <model>maven.mdo</model>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <profiles>
+    <profile>
+      <id>all-models</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.modello</groupId>
+            <artifactId>modello-maven-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>v3</id>
+                <goals>
+                  <goal>xpp3-writer</goal>
+                  <goal>java</goal>
+                  <goal>xpp3-reader</goal>
+                  <goal>xsd</goal>
+                </goals>
+                <configuration>
+                  <version>3.0.0</version>
+                  <packageWithVersion>true</packageWithVersion>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <artifactId>maven-jar-plugin</artifactId>
+            <executions>
+              <execution>
+                <phase>package</phase>
+                <goals>
+                  <goal>jar</goal>
+                </goals>
+                <configuration>
+                  <classifier>all</classifier>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+  <dependencies>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.0.5</version>
+    </dependency>
+  </dependencies>
+  <distributionManagement>
+    <status>deployed</status>
+  </distributionManagement>
+</project>
\ No newline at end of file

Propchange: maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/2.0/maven-corrupt-jar-2.0.pom
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/repository-manager/trunk/maven-repository-indexer/src/test/repository/org/apache/maven/maven-corrupt-jar/2.0/maven-corrupt-jar-2.0.pom
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message