]> source.dussan.org Git - archiva.git/commitdiff
remove unnecessary methods on index
authorBrett Porter <brett@apache.org>
Mon, 9 Jan 2006 03:27:30 +0000 (03:27 +0000)
committerBrett Porter <brett@apache.org>
Mon, 9 Jan 2006 03:27:30 +0000 (03:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@367174 13f79535-47bb-0310-9956-ffa450edef68

maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndex.java
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java

index dc8728c8ec555638b884e4444f577946aa8967c1..eae925e3dbe222d482c0f9378fb0dfcc7f2b6fb6 100644 (file)
@@ -88,25 +88,6 @@ public class ArtifactRepositoryIndex
         return analyzer;
     }
 
-    /**
-     * generic method for indexing
-     *
-     * @param obj the object to be indexed by this indexer
-     */
-    public void index( Object obj )
-        throws RepositoryIndexException
-    {
-        if ( obj instanceof Artifact )
-        {
-            indexArtifact( (Artifact) obj );
-        }
-        else
-        {
-            throw new RepositoryIndexException(
-                "This instance of indexer cannot index instances of " + obj.getClass().getName() );
-        }
-    }
-
     /**
      * method to index a given artifact
      *
@@ -126,12 +107,10 @@ public class ArtifactRepositoryIndex
 
         String sha1sum;
         String md5sum;
-        ZipFile jar;
         try
         {
             sha1sum = digester.createChecksum( artifact.getFile(), Digester.SHA1 );
             md5sum = digester.createChecksum( artifact.getFile(), Digester.MD5 );
-            jar = new ZipFile( artifact.getFile() );
         }
         catch ( NoSuchAlgorithmException e )
         {
@@ -141,23 +120,36 @@ public class ArtifactRepositoryIndex
         {
             throw new RepositoryIndexException( "Error reading from artifact file", e );
         }
-        catch ( ZipException e )
-        {
-            throw new RepositoryIndexException( "Error reading from artifact file", e );
-        }
         catch ( IOException e )
         {
             throw new RepositoryIndexException( "Error reading from artifact file", e );
         }
 
-        for ( Enumeration entries = jar.entries(); entries.hasMoreElements(); )
+        try
         {
-            ZipEntry entry = (ZipEntry) entries.nextElement();
-            if ( addIfClassEntry( entry, classes ) )
+            // TODO: improve
+            if ( "jar".equals( artifact.getType() ) )
             {
-                addClassPackage( entry.getName(), packages );
+                ZipFile jar = new ZipFile( artifact.getFile() );
+
+                for ( Enumeration entries = jar.entries(); entries.hasMoreElements(); )
+                {
+                    ZipEntry entry = (ZipEntry) entries.nextElement();
+                    if ( addIfClassEntry( entry, classes ) )
+                    {
+                        addClassPackage( entry.getName(), packages );
+                    }
+                    addFile( entry, files );
+                }
             }
-            addFile( entry, files );
+        }
+        catch ( ZipException e )
+        {
+            throw new RepositoryIndexException( "Error reading from artifact file: " + artifact.getFile(), e );
+        }
+        catch ( IOException e )
+        {
+            throw new RepositoryIndexException( "Error reading from artifact file", e );
         }
 
         //@todo should some of these fields be Keyword instead of Text ?
index 498fa71fdbdc3a4fcfd86a9bb053a396dda8f713..3fb579dde1b6cf8c60b03f60d84d40e66113a692 100644 (file)
@@ -24,13 +24,8 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
  */
 public interface RepositoryIndex
 {
-    String ROLE = RepositoryIndex.class.getName();
-
     boolean isOpen();
 
-    void index( Object obj )
-        throws RepositoryIndexException;
-
     void close()
         throws RepositoryIndexException;
 
index e3aaefa59eff2fb67b166206a314ab8582a3b693..e6d687a65824e0f32484be5c9718b29dc012eae5 100644 (file)
@@ -136,16 +136,6 @@ public class ArtifactRepositoryIndexingTest
 
         indexer = factory.createArtifactRepositoryIndex( indexPath, repository );
 
-        try
-        {
-            indexer.index( "should fail" );
-            fail( "Must throw exception on add non-Artifact object." );
-        }
-        catch ( RepositoryIndexException e )
-        {
-            // expected
-        }
-
         indexer.close();
     }
 
@@ -170,7 +160,7 @@ public class ArtifactRepositoryIndexingTest
 
         artifact = getArtifact( "test", "test-artifactId", "1.0" );
         artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact ) ) );
-        indexer.index( artifact );
+        indexer.indexArtifact( artifact );
 
         indexer.optimize();
         indexer.close();