Author: cstamas
Date: Fri Nov 26 15:58:59 2010
New Revision: 1039430

URL: http://svn.apache.org/viewvc?rev=1039430&view=rev
Log:
Added identify that is able to target IndexingContext to use for identification.

Modified:
    
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java
    
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java

Modified: 
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java
URL: 
http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java?rev=1039430&r1=1039429&r2=1039430&view=diff
==============================================================================
--- 
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java
 (original)
+++ 
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java
 Fri Nov 26 15:58:59 2010
@@ -57,7 +57,6 @@ public class DefaultNexusIndexer
     extends AbstractLogEnabled
     implements NexusIndexer
 {
-    private static final char[] DIGITS = "0123456789abcdef".toCharArray();
 
     @Requirement
     private Scanner scanner;
@@ -503,9 +502,28 @@ public class DefaultNexusIndexer
     // Identification
     // 
----------------------------------------------------------------------------
 
+    @Deprecated
+    public ArtifactInfo identify( String field, String query )
+        throws IOException
+    {
+        return identify( new TermQuery( new Term( field, query ) ) );
+    }
+
+    public ArtifactInfo identify( Field field, String query )
+        throws IOException
+    {
+        return identify( constructQuery( field, query, SearchType.EXACT ) );
+    }
+
     public ArtifactInfo identify( File artifact )
         throws IOException
     {
+        return identify( artifact, indexingContexts.values() );
+    }
+
+    public ArtifactInfo identify( File artifact, Collection<IndexingContext> 
contexts )
+        throws IOException
+    {
         FileInputStream is = null;
 
         try
@@ -525,9 +543,9 @@ public class DefaultNexusIndexer
 
             byte[] digest = sha1.digest();
 
-            // String sha1 = new Sha1Digester().calc( artifact );
+            Query q = constructQuery( MAVEN.SHA1, encode( digest ), 
SearchType.EXACT );
 
-            return identify( MAVEN.SHA1, encode( digest ) );
+            return identify( q, contexts );
         }
         catch ( NoSuchAlgorithmException ex )
         {
@@ -537,35 +555,6 @@ public class DefaultNexusIndexer
         {
             IOUtil.close( is );
         }
-
-    }
-
-    private static String encode( byte[] digest )
-    {
-        char[] buff = new char[digest.length * 2];
-
-        int n = 0;
-
-        for ( byte b : digest )
-        {
-            buff[n++] = DIGITS[( 0xF0 & b ) >> 4];
-            buff[n++] = DIGITS[0x0F & b];
-        }
-
-        return new String( buff );
-    }
-
-    @Deprecated
-    public ArtifactInfo identify( String field, String query )
-        throws IOException
-    {
-        return identify( new TermQuery( new Term( field, query ) ) );
-    }
-
-    public ArtifactInfo identify( Field field, String query )
-        throws IOException
-    {
-        return identify( queryCreator.constructQuery( field, query, 
SearchType.EXACT ) );
     }
 
     public ArtifactInfo identify( Query query )
@@ -591,4 +580,22 @@ public class DefaultNexusIndexer
         }
     }
 
+    // ==
+
+    private static final char[] DIGITS = "0123456789abcdef".toCharArray();
+
+    private static String encode( byte[] digest )
+    {
+        char[] buff = new char[digest.length * 2];
+
+        int n = 0;
+
+        for ( byte b : digest )
+        {
+            buff[n++] = DIGITS[( 0xF0 & b ) >> 4];
+            buff[n++] = DIGITS[0x0F & b];
+        }
+
+        return new String( buff );
+    }
 }

Modified: 
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java
URL: 
http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java?rev=1039430&r1=1039429&r2=1039430&view=diff
==============================================================================
--- 
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java
 (original)
+++ 
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java
 Fri Nov 26 15:58:59 2010
@@ -423,9 +423,6 @@ public interface NexusIndexer
     // Identification
     // 
----------------------------------------------------------------------------
 
-    ArtifactInfo identify( File artifact )
-        throws IOException;
-
     @Deprecated
     ArtifactInfo identify( String field, String query )
         throws IOException;
@@ -433,6 +430,12 @@ public interface NexusIndexer
     ArtifactInfo identify( Field field, String query )
         throws IOException;
 
+    ArtifactInfo identify( File artifact )
+        throws IOException;
+
+    ArtifactInfo identify( File artifact, Collection<IndexingContext> contexts 
)
+        throws IOException;
+
     ArtifactInfo identify( Query query )
         throws IOException;
 


Reply via email to