You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by jo...@apache.org on 2007/04/03 17:22:01 UTC

svn commit: r525176 [2/12] - in /maven/archiva/branches/archiva-jpox-database-refactor: ./ archiva-api/src/main/java/org/apache/maven/archiva/configuration/ archiva-api/src/main/java/org/apache/maven/archiva/consumers/ archiva-api/src/main/java/org/apa...

Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java?view=diff&rev=525176&r1=525175&r2=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java Tue Apr  3 08:21:33 2007
@@ -23,7 +23,6 @@
 import org.codehaus.plexus.PlexusTestCase;
 
 import java.io.File;
-import java.util.Properties;
 
 /**
  * Test the configuration store.
@@ -53,13 +52,28 @@
 
         assertEquals( "check repositories", 4, configuration.getRepositories().size() );
         assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() );
-        assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() );
-        assertEquals( "check file processors", 12, configuration.getFileProcessors().size() );
+        assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() );
+
+        RepositoryScanningConfiguration repoScanning = configuration.getRepositoryScanning();
+        assertNotNull( "check repository scanning", repoScanning );
+        assertEquals( "check file types", 4, repoScanning.getFileTypes().size() );
+        assertEquals( "check good consumers", 8, repoScanning.getGoodConsumers().size() );
+        assertEquals( "check bad consumers", 1, repoScanning.getBadConsumers().size() );
+
+        FileType artifactTypes = repoScanning.getFileTypeById( "artifacts" );
+        assertNotNull( "check 'artifacts' file type", artifactTypes );
+        assertEquals( "check 'artifacts' patterns", 13, artifactTypes.getPatterns().size() );
+
+        DatabaseScanningConfiguration dbScanning = configuration.getDatabaseScanning();
+        assertNotNull( "check database scanning", dbScanning );
+        assertEquals( "check unprocessed consumers", 6, dbScanning.getUnprocessedConsumers().size() );
+        assertEquals( "check processed consumers", 3, dbScanning.getProcessedConsumers().size() );
 
         RepositoryConfiguration repository =
             (RepositoryConfiguration) configuration.getRepositories().iterator().next();
 
-        assertEquals( "check managed repositories", "file://${appserver.home}/repositories/internal", repository.getUrl() );
+        assertEquals( "check managed repositories", "file://${appserver.home}/repositories/internal",
+                      repository.getUrl() );
         assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() );
         assertEquals( "check managed repositories", "internal", repository.getId() );
         assertEquals( "check managed repositories", "default", repository.getLayout() );

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr  3 08:21:33 2007
@@ -0,0 +1,15 @@
+target
+*~
+.*.swp
+*.log
+*.patch
+*.diff
+*.ipr
+*.iws
+*.iml
+.classpath
+.project
+.m2eclipse
+.settings
+.wtpmodules
+cobertura.ser

Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml?view=diff&rev=525176&r1=525175&r2=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml Tue Apr  3 08:21:33 2007
@@ -30,6 +30,9 @@
   <packaging>jar</packaging>
 
   <dependencies>
-    
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-model</artifactId>
+    </dependency>
   </dependencies>
 </project>

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java?view=auto&rev=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java Tue Apr  3 08:21:33 2007
@@ -0,0 +1,93 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * AbstractMonitoredConsumer 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractMonitoredConsumer implements BaseConsumer
+{
+    private Set monitors = new HashSet();
+
+    public void addConsumerMonitor( ConsumerMonitor monitor )
+    {
+        monitors.add( monitor );
+    }
+
+    public void removeConsumerMonitor( ConsumerMonitor monitor )
+    {
+        monitors.remove( monitor );
+    }
+
+    protected void triggerConsumerError( String type, String message )
+    {
+        for ( Iterator itmonitors = monitors.iterator(); itmonitors.hasNext(); )
+        {
+            ConsumerMonitor monitor = (ConsumerMonitor) itmonitors.next();
+            try
+            {
+                monitor.consumerError( this, type, message );
+            }
+            catch ( Throwable t )
+            {
+                /* discard error */
+            }
+        }
+    }
+
+    protected void triggerConsumerWarning( String type, String message )
+    {
+        for ( Iterator itmonitors = monitors.iterator(); itmonitors.hasNext(); )
+        {
+            ConsumerMonitor monitor = (ConsumerMonitor) itmonitors.next();
+            try
+            {
+                monitor.consumerWarning( this, type, message );
+            }
+            catch ( Throwable t )
+            {
+                /* discard error */
+            }
+        }
+    }
+
+    protected void triggerConsumerInfo( String message )
+    {
+        for ( Iterator itmonitors = monitors.iterator(); itmonitors.hasNext(); )
+        {
+            ConsumerMonitor monitor = (ConsumerMonitor) itmonitors.next();
+            try
+            {
+                monitor.consumerInfo( this, message );
+            }
+            catch ( Throwable t )
+            {
+                /* discard error */
+            }
+        }
+    }
+}

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/AbstractMonitoredConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ArchivaArtifactConsumer.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ArchivaArtifactConsumer.java?view=auto&rev=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ArchivaArtifactConsumer.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ArchivaArtifactConsumer.java Tue Apr  3 08:21:33 2007
@@ -0,0 +1,81 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.model.ArchivaArtifact;
+
+import java.util.List;
+
+/**
+ * ArchivaArtifactConsumer - consumer for ArchivaArtifact objects. 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public interface ArchivaArtifactConsumer extends BaseConsumer
+{
+    /**
+     * Get the list of included file patterns for this consumer.
+     * 
+     * @return the list of ({@link String}) artifact types to process.
+     */
+    public List getIncludedTypes();
+
+    /**
+     * <p>
+     * Event that triggers at the beginning of a scan.
+     * </p>
+     * 
+     * <p>
+     * NOTE: This would be a good place to initialize the consumer, to lock any resources, and to
+     * generally start tracking the scan as a whole.
+     * </p>
+     */
+    public void beginScan();
+
+    /**
+     * <p>
+     * Event indicating an {@link ArchivaArtifact} is to be processed by this consumer.
+     * </p> 
+     * 
+     * <p>
+     * NOTE: The consumer does not need to process the artifact immediately, can can opt to queue and/or track
+     * the artifact to be processed in batch.  Just be sure to complete the processing by the {@link #completeScan()} 
+     * event. 
+     * </p>
+     * 
+     * @param file the file to process.
+     * @throws ConsumerException if there was a problem processing this file.
+     */
+    public void processArchivaArtifact( ArchivaArtifact artifact ) throws ConsumerException;
+
+    /**
+     * <p>
+     * Event that triggers on the completion of a scan.
+     * </p>
+     * 
+     * <p>
+     * NOTE: If the consumer opted to batch up processing requests in the 
+     * {@link #processArchivaArtifact(ArchivaArtifact)} event this would be the last opportunity to drain 
+     * any processing queue's.
+     * </p>
+     */
+    public void completeScan();
+}

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ArchivaArtifactConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ArchivaArtifactConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ArchivaArtifactConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/BaseConsumer.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/BaseConsumer.java?view=auto&rev=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/BaseConsumer.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/BaseConsumer.java Tue Apr  3 08:21:33 2007
@@ -0,0 +1,64 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * BaseConsumer - the base set of methods for a consumer. 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract interface BaseConsumer
+{
+    /**
+     * This is the id for the consumer.
+     * 
+     * @return the consumer id.
+     */
+    public String getId();
+    
+    /**
+     * The human readable description for this consumer.
+     * 
+     * @return the human readable description for this consumer.
+     */
+    public String getDescription();
+    
+    /**
+     * Flag indicating permanance of consumer. (if it can be disabled or not)
+     * 
+     * @return true indicating that consumer is permanent and cannot be disabled. 
+     */
+    public boolean isPermanent();
+
+    /**
+     * Add a consumer monitor to the consumer.
+     * 
+     * @param monitor the monitor to add.
+     */
+    public void addConsumerMonitor( ConsumerMonitor monitor );
+    
+    /**
+     * Remove a consumer monitor.
+     * 
+     * @param monitor the monitor to remove.
+     */
+    public void removeConsumerMonitor( ConsumerMonitor monitor );
+}

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/BaseConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/BaseConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/BaseConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerException.java (from r521491, maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerException.java)
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerException.java?view=diff&rev=525176&p1=maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerException.java&r1=521491&p2=maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerException.java&r2=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerException.java (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerException.java Tue Apr  3 08:21:33 2007
@@ -1,4 +1,4 @@
-package org.apache.maven.archiva.repository.consumer;
+package org.apache.maven.archiva.consumers;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,7 +20,6 @@
  */
 
 import org.apache.maven.archiva.common.ArchivaException;
-import org.apache.maven.archiva.common.utils.BaseFile;
 
 /**
  * ConsumerException - details about the failure of a consumer.
@@ -31,22 +30,13 @@
 public class ConsumerException
     extends ArchivaException
 {
-    private BaseFile file;
-
-    public ConsumerException( BaseFile file, String message, Throwable cause )
+    public ConsumerException( String message, Throwable cause )
     {
         super( message, cause );
-        this.file = file;
     }
 
-    public ConsumerException( BaseFile file, String message )
+    public ConsumerException( String message )
     {
         super( message );
-        this.file = file;
-    }
-
-    public BaseFile getFile()
-    {
-        return file;
     }
 }

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerMonitor.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerMonitor.java?view=auto&rev=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerMonitor.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerMonitor.java Tue Apr  3 08:21:33 2007
@@ -0,0 +1,55 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * ConsumerMonitor - a monitor for consumers. 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public interface ConsumerMonitor
+{
+    /**
+     * A consumer error event.
+     * 
+     * @param consumer the consumer that caused the error.
+     * @param type the type of error.
+     * @param message the message about the error.
+     */
+    public void consumerError( BaseConsumer consumer, String type, String message );
+    
+    /**
+     * A consumer warning event.
+     * 
+     * @param consumer the consumer that caused the warning.
+     * @param type the type of warning.
+     * @param message the message about the warning.
+     */
+    public void consumerWarning( BaseConsumer consumer, String type, String message );
+
+    /**
+     * A consumer informational event.
+     * 
+     * @param consumer the consumer that caused the informational message.
+     * @param message the message.
+     */
+    public void consumerInfo( BaseConsumer consumer, String message );
+}

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerMonitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerMonitor.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/ConsumerMonitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java?view=auto&rev=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java Tue Apr  3 08:21:33 2007
@@ -0,0 +1,91 @@
+package org.apache.maven.archiva.consumers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.common.utils.BaseFile;
+import org.apache.maven.archiva.model.ArchivaRepository;
+
+import java.util.List;
+
+/**
+ * A consumer of content (files) in the repository. 
+ *
+ * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public interface RepositoryContentConsumer extends BaseConsumer
+{
+    /**
+     * Get the list of included file patterns for this consumer.
+     * 
+     * @return the list of {@link String} patterns. (example: <code>"**<span />/*.pom"</code>)
+     */
+    public List getIncludes();
+    
+    /**
+     * Get the list of excluded file patterns for this consumer.
+     * 
+     * @return the list of {@link String} patterns. (example: <code>"**<span />/*.pom"</code>) - (can be null for no exclusions)
+     */
+    public List getExcludes();
+
+    /**
+     * <p>
+     * Event that triggers at the beginning of a scan.
+     * </p>
+     * 
+     * <p>
+     * NOTE: This would be a good place to initialize the consumer, to lock any resources, and to
+     * generally start tracking the scan as a whole.
+     * </p>
+     * 
+     * @param repository the repository that this consumer is being used for.
+     * @throws ConsumerException if there was a problem with using the provided repository with the consumer.
+     */
+    public void beginScan( ArchivaRepository repository ) throws ConsumerException;
+
+    /**
+     * <p>
+     * Event indicating a file is to be processed by this consumer.
+     * </p> 
+     * 
+     * <p>
+     * NOTE: The consumer does not need to process the file immediately, can can opt to queue and/or track
+     * the files to be processed in batch.  Just be sure to complete the processing by the {@link #completeScan()} 
+     * event.
+     * </p>
+     * 
+     * @param path the relative file path (in the repository) to process.
+     * @throws ConsumerException if there was a problem processing this file.
+     */
+    public void processFile( String path ) throws ConsumerException;
+    
+    /**
+     * <p>
+     * Event that triggers on the completion of a scan.
+     * </p>
+     * 
+     * <p>
+     * NOTE: If the consumer opted to batch up processing requests in the {@link #processFile(BaseFile)} event
+     * this would be the last opportunity to drain any processing queue's.
+     * </p>
+     */
+    public void completeScan();
+}

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/maven/archiva/consumers/RepositoryContentConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr  3 08:21:33 2007
@@ -0,0 +1,15 @@
+target
+*~
+.*.swp
+*.log
+*.patch
+*.diff
+*.ipr
+*.iws
+*.iml
+.classpath
+.project
+.m2eclipse
+.settings
+.wtpmodules
+cobertura.ser

Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml?view=diff&rev=525176&r1=525175&r2=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml Tue Apr  3 08:21:33 2007
@@ -30,6 +30,21 @@
   <packaging>jar</packaging>
 
   <dependencies>
-    
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-configuration</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-consumer-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-repository-layer</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-digest</artifactId>
+    </dependency>
   </dependencies>
 </project>

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java?view=auto&rev=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java Tue Apr  3 08:21:33 2007
@@ -0,0 +1,236 @@
+package org.apache.maven.archiva.consumers.core;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.FileType;
+import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
+import org.apache.maven.archiva.model.ArchivaRepository;
+import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
+import org.codehaus.plexus.digest.ChecksumFile;
+import org.codehaus.plexus.digest.Digester;
+import org.codehaus.plexus.digest.DigesterException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryListener;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * ArtifactMissingChecksumsConsumer - Create missing checksums for the artifact.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ * @plexus.component role-hint="create-missing-checksums"
+ *                   instantiation-strategy="per-lookup"
+ */
+public class ArtifactMissingChecksumsConsumer extends AbstractMonitoredConsumer
+    implements RepositoryContentConsumer, RegistryListener, Initializable
+{
+    /**
+     * @plexus.configuration default-value="create-missing-checksums"
+     */
+    private String id;
+
+    /**
+     * @plexus.configuration default-value="Create Missing Checksums (.sha1 & .md5)"
+     */
+    private String description;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArchivaConfiguration configuration;
+
+    /**
+     * @plexus.requirement role="org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout"
+     */
+    private Map bidirectionalLayoutMap;
+
+    /**
+     * @plexus.requirement role-hint="sha1"
+     */
+    private Digester digestSha1;
+
+    /**
+     * @plexus.requirement role-hint="md5";
+     */
+    private Digester digestMd5;
+
+    /**
+     * @plexus.requirement
+     */
+    private ChecksumFile checksum;
+
+    private static final String TYPE_CHECKSUM_NOT_FILE = "checksum-bad-not-file";
+
+    private static final String TYPE_CHECKSUM_CANNOT_CALC = "checksum-calc-failure";
+
+    private static final String TYPE_CHECKSUM_CANNOT_CREATE = "checksum-create-failure";
+
+    private ArchivaRepository repository;
+
+    private File repositoryDir;
+
+    private BidirectionalRepositoryLayout layout;
+
+    private List propertyNameTriggers = new ArrayList();
+
+    private List includes = new ArrayList();
+
+    public String getId()
+    {
+        return this.id;
+    }
+
+    public String getDescription()
+    {
+        return this.description;
+    }
+
+    public boolean isPermanent()
+    {
+        return false;
+    }
+
+    public void beginScan( ArchivaRepository repository ) throws ConsumerException
+    {
+        if ( !repository.isManaged() )
+        {
+            throw new ConsumerException( "Consumer requires managed repository." );
+        }
+
+        this.repository = repository;
+        this.repositoryDir = new File( repository.getUrl().getPath() );
+
+        String layoutName = repository.getModel().getLayoutName();
+        if ( !bidirectionalLayoutMap.containsKey( layoutName ) )
+        {
+            throw new ConsumerException( "Unable to process repository with layout [" + layoutName
+                            + "] as there is no coresponding " + BidirectionalRepositoryLayout.class.getName()
+                            + " implementation available." );
+        }
+
+        this.layout = (BidirectionalRepositoryLayout) bidirectionalLayoutMap.get( layoutName );
+    }
+
+    public void completeScan()
+    {
+        /* do nothing */
+    }
+
+    public List getExcludes()
+    {
+        return null;
+    }
+
+    public List getIncludes()
+    {
+        return includes;
+    }
+
+    public void processFile( String path ) throws ConsumerException
+    {
+        createIfMissing( path, digestSha1 );
+        createIfMissing( path, digestMd5 );
+    }
+
+    private void createIfMissing( String path, Digester digester )
+    {
+        File checksumFile = new File( this.repositoryDir, path + digester.getFilenameExtension() );
+        if ( !checksumFile.exists() )
+        {
+            try
+            {
+                checksum.createChecksum( new File( this.repositoryDir, path ), digester );
+                triggerConsumerInfo( "Created missing checksum file " + checksumFile.getAbsolutePath() );
+            }
+            catch ( DigesterException e )
+            {
+                triggerConsumerError( TYPE_CHECKSUM_CANNOT_CALC, "Cannot calculate checksum for file " + checksumFile
+                                + ": " + e.getMessage() );
+            }
+            catch ( IOException e )
+            {
+                triggerConsumerError( TYPE_CHECKSUM_CANNOT_CREATE, "Cannot create checksum for file " + checksumFile
+                                + ": " + e.getMessage() );
+            }
+        }
+        else if ( !checksumFile.isFile() )
+        {
+            triggerConsumerWarning( TYPE_CHECKSUM_NOT_FILE, "Checksum file " + checksumFile.getAbsolutePath()
+                            + " is not a file." );
+        }
+
+    }
+
+    public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+    {
+        if ( propertyNameTriggers.contains( propertyName ) )
+        {
+            initIncludes();
+        }
+    }
+
+    public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+    {
+        /* do nothing */
+    }
+
+    private void initIncludes()
+    {
+        includes.clear();
+        
+        FileType artifactTypes = configuration.getConfiguration().getRepositoryScanning().getFileTypeById( "artifacts" );
+        if ( artifactTypes != null )
+        {
+            includes.addAll( artifactTypes.getPatterns() );
+        }
+    }
+
+    public void initialize() throws InitializationException
+    {
+        propertyNameTriggers = new ArrayList();
+        propertyNameTriggers.add( "repositoryScanning" );
+        propertyNameTriggers.add( "fileTypes" );
+        propertyNameTriggers.add( "fileType" );
+        propertyNameTriggers.add( "patterns" );
+        propertyNameTriggers.add( "pattern" );
+
+        configuration.addChangeListener( this );
+
+        initIncludes();
+
+        if ( includes.isEmpty() )
+        {
+            throw new InitializationException( "Unable to use " + getId() + " due to empty includes list." );
+        }
+    }
+}

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java?view=auto&rev=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java Tue Apr  3 08:21:33 2007
@@ -0,0 +1,158 @@
+package org.apache.maven.archiva.consumers.core;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
+import org.apache.maven.archiva.model.ArchivaRepository;
+import org.codehaus.plexus.digest.ChecksumFile;
+import org.codehaus.plexus.digest.Digester;
+import org.codehaus.plexus.digest.DigesterException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * ValidateChecksumConsumer - validate the provided checksum against the file it represents. 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ * 
+ * @plexus.component role-hint="validate-checksums"
+ *                   instantiation-strategy="per-lookup"
+ */
+public class ValidateChecksumConsumer extends AbstractMonitoredConsumer
+    implements RepositoryContentConsumer, Initializable
+{
+    private static final String NOT_VALID_CHECKSUM = "checksum-not-valid";
+
+    private static final String CHECKSUM_NOT_FOUND = "checksum-not-found";
+
+    private static final String CHECKSUM_DIGESTER_FAILURE = "checksum-digester-failure";
+
+    private static final String CHECKSUM_IO_ERROR = "checksum-io-error";
+
+    /**
+     * @plexus.configuration default-value="validate-checksums"
+     */
+    private String id;
+
+    /**
+     * @plexus.configuration default-value="Validate checksums against file."
+     */
+    private String description;
+
+    /**
+     * @plexus.requirement
+     */
+    private ChecksumFile checksum;
+
+    /**
+     * @plexus.requirement role="org.codehaus.plexus.digest.Digester"
+     */
+    private List digesterList;
+
+    private ArchivaRepository repository;
+
+    private File repositoryDir;
+
+    private List includes = new ArrayList();
+
+    public String getId()
+    {
+        return this.id;
+    }
+
+    public String getDescription()
+    {
+        return this.description;
+    }
+
+    public boolean isPermanent()
+    {
+        return false;
+    }
+
+    public void beginScan( ArchivaRepository repository ) throws ConsumerException
+    {
+        if ( !repository.isManaged() )
+        {
+            throw new ConsumerException( "Consumer requires managed repository." );
+        }
+
+        this.repository = repository;
+        this.repositoryDir = new File( repository.getUrl().getPath() );
+    }
+
+    public void completeScan()
+    {
+        /* nothing to do */
+    }
+
+    public List getExcludes()
+    {
+        return null;
+    }
+
+    public List getIncludes()
+    {
+        return this.includes;
+    }
+
+    public void processFile( String path ) throws ConsumerException
+    {
+        File checksumFile = new File( this.repositoryDir, path );
+        try
+        {
+            if ( !checksum.isValidChecksum( checksumFile ) )
+            {
+                triggerConsumerWarning( NOT_VALID_CHECKSUM, "The checksum for " + checksumFile + " is invalid." );
+            }
+        }
+        catch ( FileNotFoundException e )
+        {
+            triggerConsumerError( CHECKSUM_NOT_FOUND, "File not found during checksum validation: " + e.getMessage() );
+        }
+        catch ( DigesterException e )
+        {
+            triggerConsumerError( CHECKSUM_DIGESTER_FAILURE, "Digester failure during checksum validation on " + checksumFile );
+        }
+        catch ( IOException e )
+        {
+            triggerConsumerError( CHECKSUM_IO_ERROR, "Checksum I/O error during validation on " + checksumFile );
+        }
+    }
+
+    public void initialize() throws InitializationException
+    {
+        for ( Iterator itDigesters = digesterList.iterator(); itDigesters.hasNext(); )
+        {
+            Digester digester = (Digester) itDigesters.next();
+            includes.add( "**/*" + digester.getFilenameExtension() );
+        }
+    }
+}

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr  3 08:21:33 2007
@@ -0,0 +1,15 @@
+target
+*~
+.*.swp
+*.log
+*.patch
+*.diff
+*.ipr
+*.iws
+*.iml
+.classpath
+.project
+.m2eclipse
+.settings
+.wtpmodules
+cobertura.ser

Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/pom.xml?view=diff&rev=525176&r1=525175&r2=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/pom.xml (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/pom.xml Tue Apr  3 08:21:33 2007
@@ -30,6 +30,21 @@
   <packaging>jar</packaging>
 
   <dependencies>
-    
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-database</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-configuration</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-consumer-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-repository-layer</artifactId>
+    </dependency>
   </dependencies>
 </project>

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java?view=auto&rev=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java Tue Apr  3 08:21:33 2007
@@ -0,0 +1,213 @@
+package org.apache.maven.archiva.consumers.database;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.FileType;
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.model.ArchivaRepository;
+import org.apache.maven.archiva.model.RepositoryContent;
+import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
+import org.apache.maven.archiva.repository.layout.LayoutException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryListener;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * ArtifactUpdateDatabaseConsumer - Take an artifact off of disk and put it into the repository.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ * 
+ * @plexus.component role-hint="update-db-artifact"
+ *                   instantiation-strategy="per-lookup"
+ */
+public class ArtifactUpdateDatabaseConsumer extends AbstractMonitoredConsumer
+    implements RepositoryContentConsumer, RegistryListener, Initializable
+{
+    private static final String TYPE_NOT_ARTIFACT = "file-not-artifact";
+
+    private static final String DB_ERROR = "db-error";
+    
+    /**
+     * @plexus.configuration default-value="update-db-artifact"
+     */
+    private String id;
+
+    /**
+     * @plexus.configuration default-value="Update the Artifact in the Database"
+     */
+    private String description;
+    
+    /**
+     * @plexus.requirement role-hint="jdo"
+     */
+    private ArchivaDAO dao;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArchivaConfiguration configuration;
+
+    /**
+     * @plexus.requirement role="org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout"
+     */
+    private Map bidirectionalLayoutMap;
+
+    private ArchivaRepository repository;
+
+    private File repositoryDir;
+
+    private BidirectionalRepositoryLayout layout;
+
+    private List propertyNameTriggers = new ArrayList();
+
+    private List includes = new ArrayList();
+
+    public String getId()
+    {
+        return this.id;
+    }
+
+    public String getDescription()
+    {
+        return this.description;
+    }
+
+    public boolean isPermanent()
+    {
+        return true;
+    }
+
+    public List getExcludes()
+    {
+        return null;
+    }
+
+    public List getIncludes()
+    {
+        return this.includes;
+    }
+
+    public void beginScan( ArchivaRepository repository ) throws ConsumerException
+    {
+        if ( !repository.isManaged() )
+        {
+            throw new ConsumerException( "Consumer requires managed repository." );
+        }
+
+        this.repository = repository;
+        this.repositoryDir = new File( repository.getUrl().getPath() );
+
+        String layoutName = repository.getModel().getLayoutName();
+        if ( !bidirectionalLayoutMap.containsKey( layoutName ) )
+        {
+            throw new ConsumerException( "Unable to process repository with layout [" + layoutName
+                            + "] as there is no coresponding " + BidirectionalRepositoryLayout.class.getName()
+                            + " implementation available." );
+        }
+
+        this.layout = (BidirectionalRepositoryLayout) bidirectionalLayoutMap.get( layoutName );
+    }
+
+    public void processFile( String path ) throws ConsumerException
+    {
+        try
+        {
+            ArchivaArtifact artifact = layout.toArtifact( path );
+            
+            RepositoryContent repoContent = artifact.getModel().getContentKey();
+            repoContent.setRepositoryId( this.repository.getId() );
+            
+            // Calculate the hashcodes.
+            
+            
+            dao.saveArtifact( artifact.getModel() );
+        }
+        catch ( LayoutException e )
+        {
+            triggerConsumerError( TYPE_NOT_ARTIFACT, "Path " + path + " cannot be converted to artifact: "
+                            + e.getMessage() );
+        }
+        catch ( ArchivaDatabaseException e )
+        {
+            triggerConsumerError( DB_ERROR, "Unable to save artifact to database: " + e.getMessage() );
+        }
+    }
+
+    public void completeScan()
+    {
+        /* do nothing */
+    }
+
+    public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+    {
+        if ( propertyNameTriggers.contains( propertyName ) )
+        {
+            initIncludes();
+        }
+    }
+
+    public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+    {
+        /* do nothing */
+    }
+
+    private void initIncludes()
+    {
+        includes.clear();
+
+        FileType artifactTypes = configuration.getConfiguration().getRepositoryScanning().getFileTypeById( "artifacts" );
+        if ( artifactTypes != null )
+        {
+            includes.addAll( artifactTypes.getPatterns() );
+        }
+    }
+
+    public void initialize() throws InitializationException
+    {
+        propertyNameTriggers = new ArrayList();
+        propertyNameTriggers.add( "repositoryScanning" );
+        propertyNameTriggers.add( "fileTypes" );
+        propertyNameTriggers.add( "fileType" );
+        propertyNameTriggers.add( "patterns" );
+        propertyNameTriggers.add( "pattern" );
+
+        configuration.addChangeListener( this );
+
+        initIncludes();
+
+        if ( includes.isEmpty() )
+        {
+            throw new InitializationException( "Unable to use " + getId() + " due to empty includes list." );
+        }
+    }
+}

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr  3 08:21:33 2007
@@ -0,0 +1,15 @@
+target
+*~
+.*.swp
+*.log
+*.patch
+*.diff
+*.ipr
+*.iws
+*.iml
+.classpath
+.project
+.m2eclipse
+.settings
+.wtpmodules
+cobertura.ser

Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml?view=diff&rev=525176&r1=525175&r2=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml Tue Apr  3 08:21:33 2007
@@ -30,6 +30,21 @@
   <packaging>jar</packaging>
 
   <dependencies>
-    
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-indexer</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-configuration</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-consumer-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-repository-layer</artifactId>
+    </dependency>
   </dependencies>
 </project>

Copied: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexArtifactConsumer.java (from r521491, maven/archiva/branches/archiva-jpox-database-refactor/archiva-api/src/main/java/org/apache/maven/archiva/consumers/IndexArtifactConsumer.java)
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexArtifactConsumer.java?view=diff&rev=525176&p1=maven/archiva/branches/archiva-jpox-database-refactor/archiva-api/src/main/java/org/apache/maven/archiva/consumers/IndexArtifactConsumer.java&r1=521491&p2=maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexArtifactConsumer.java&r2=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-api/src/main/java/org/apache/maven/archiva/consumers/IndexArtifactConsumer.java (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexArtifactConsumer.java Tue Apr  3 08:21:33 2007
@@ -1,4 +1,4 @@
-package org.apache.maven.archiva.consumers;
+package org.apache.maven.archiva.consumers.lucene;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java?view=auto&rev=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java Tue Apr  3 08:21:33 2007
@@ -0,0 +1,153 @@
+package org.apache.maven.archiva.consumers.lucene;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.FileType;
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
+import org.apache.maven.archiva.model.ArchivaRepository;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryListener;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * IndexContentConsumer - generic full file content indexing consumer. 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ * 
+ * @plexus.component role-hint="index-content"
+ *                   instantiation-strategy="per-lookup"
+ */
+public class IndexContentConsumer extends AbstractMonitoredConsumer
+    implements RepositoryContentConsumer, RegistryListener, Initializable
+{
+    /**
+     * @plexus.configuration default-value="index-content"
+     */
+    private String id;
+
+    /**
+     * @plexus.configuration default-value="Text and XML file contents indexing"
+     */
+    private String description;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArchivaConfiguration configuration;
+
+    private List propertyNameTriggers = new ArrayList();
+
+    private List includes = new ArrayList();
+
+    public String getId()
+    {
+        return this.id;
+    }
+
+    public String getDescription()
+    {
+        return this.description;
+    }
+
+    public boolean isPermanent()
+    {
+        return false;
+    }
+
+    public List getExcludes()
+    {
+        return null;
+    }
+
+    public List getIncludes()
+    {
+        return this.includes;
+    }
+
+    public void beginScan( ArchivaRepository repository ) throws ConsumerException
+    {
+        if ( !repository.isManaged() )
+        {
+            throw new ConsumerException( "Consumer requires managed repository." );
+        }
+    }
+
+    public void processFile( String path ) throws ConsumerException
+    {
+        
+    }
+
+    public void completeScan()
+    {
+        /* do nothing */
+    }
+
+    public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+    {
+        if ( propertyNameTriggers.contains( propertyName ) )
+        {
+            initIncludes();
+        }
+    }
+
+    public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+    {
+        /* do nothing */
+    }
+
+    private void initIncludes()
+    {
+        includes.clear();
+
+        FileType artifactTypes =
+            configuration.getConfiguration().getRepositoryScanning().getFileTypeById( "indexable-content" );
+        if ( artifactTypes != null )
+        {
+            includes.addAll( artifactTypes.getPatterns() );
+        }
+    }
+
+    public void initialize() throws InitializationException
+    {
+        propertyNameTriggers = new ArrayList();
+        propertyNameTriggers.add( "repositoryScanning" );
+        propertyNameTriggers.add( "fileTypes" );
+        propertyNameTriggers.add( "fileType" );
+        propertyNameTriggers.add( "patterns" );
+        propertyNameTriggers.add( "pattern" );
+
+        configuration.addChangeListener( this );
+
+        initIncludes();
+
+        if ( includes.isEmpty() )
+        {
+            throw new InitializationException( "Unable to use " + getId() + " due to empty includes list." );
+        }
+    }
+}

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/archiva-signature-consumers/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr  3 08:21:33 2007
@@ -0,0 +1,15 @@
+target
+*~
+.*.swp
+*.log
+*.patch
+*.diff
+*.ipr
+*.iws
+*.iml
+.classpath
+.project
+.m2eclipse
+.settings
+.wtpmodules
+cobertura.ser

Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/pom.xml?view=diff&rev=525176&r1=525175&r2=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/pom.xml (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-consumers/pom.xml Tue Apr  3 08:21:33 2007
@@ -32,8 +32,10 @@
   <modules>
     <module>archiva-consumer-api</module>
     <module>archiva-core-consumers</module>
+    <!--
     <module>archiva-database-consumers</module>
     <module>archiva-lucene-consumers</module>
     <module>archiva-signature-consumers</module>
+     -->
   </modules>
 </project>

Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/pom.xml?view=diff&rev=525176&r1=525175&r2=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/pom.xml (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/pom.xml Tue Apr  3 08:21:33 2007
@@ -30,26 +30,12 @@
   <name>Archiva Base :: Indexer</name>
   <dependencies>
     <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-artifact</artifactId>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-configuration</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-artifact-manager</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-project</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>org.codehaus.plexus.cache</groupId>
-          <artifactId>plexus-cache-hashmap</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-model</artifactId>
+      <groupId>org.apache.maven.archiva</groupId>
+      <artifactId>archiva-model</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.lucene</groupId>
@@ -67,10 +53,6 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-digest</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-repository-metadata</artifactId>
     </dependency>
     <dependency>
       <groupId>commons-lang</groupId>

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/ArtifactKeys.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/ArtifactKeys.java?view=auto&rev=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/ArtifactKeys.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/ArtifactKeys.java Tue Apr  3 08:21:33 2007
@@ -0,0 +1,20 @@
+package org.apache.maven.archiva.indexer;
+
+public class ArtifactKeys
+{
+    public static final String GROUPID = "groupId";
+
+    public static final String GROUPID_EXACT = GROUPID + "_u";
+
+    public static final String ARTIFACTID = "artifactId";
+
+    public static final String ARTIFACTID_EXACT = ARTIFACTID + "_u";
+
+    public static final String VERSION = "version";
+
+    public static final String VERSION_EXACT = VERSION + "_u";
+
+    public static final String TYPE = "type";
+
+    public static final String CLASSIFIER = "classifier";
+}

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/ArtifactKeys.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/ArtifactKeys.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/ArtifactKeys.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryContentIndex.java (from r521491, maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryArtifactIndex.java)
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryContentIndex.java?view=diff&rev=525176&p1=maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryArtifactIndex.java&r1=521491&p2=maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryContentIndex.java&r2=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryArtifactIndex.java (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryContentIndex.java Tue Apr  3 08:21:33 2007
@@ -19,29 +19,46 @@
  * under the License.
  */
 
+import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
 import org.apache.maven.archiva.indexer.query.Query;
-import org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory;
-import org.apache.maven.artifact.Artifact;
 
+import java.io.File;
 import java.util.Collection;
 import java.util.List;
 
 /**
- * Maintain an artifact index on the repository.
+ * Common access methods for a Repository Content index.
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  */
-public interface RepositoryArtifactIndex
+public interface RepositoryContentIndex
 {
     /**
-     * Indexes the artifacts found within the specified list of index records. If the artifacts are already in the
-     * repository they are updated.
+     * Indexes the records.
      *
-     * @param records the records to index
-     * @throws RepositoryIndexException if there is a problem indexing the records
+     * @param records list of {@link LuceneRepositoryContentRecord} objects.
+     * @throws RepositoryIndexException if there is a problem indexing the records.
      */
     void indexRecords( Collection records )
         throws RepositoryIndexException;
+    
+    /**
+     * Modify (potentially) existing records in the index.
+     * 
+     * @param records the collection of {@link LuceneRepositoryContentRecord} objects to modify in the index.
+     * @throws RepositoryIndexException if there is a problem modifying the records.
+     */
+    public void modifyRecords( Collection records ) 
+        throws RepositoryIndexException;
+    
+    /**
+     * Modify an existing (potential) record in the index.
+     *  
+     * @param record the record to modify.
+     * @throws RepositoryIndexException if there is a problem modifying the record.
+     */
+    public void modifyRecord( LuceneRepositoryContentRecord record ) 
+        throws RepositoryIndexException;
 
     /**
      * Search the index based on the search criteria specified. Returns a list of index records.
@@ -75,7 +92,7 @@
     /**
      * Retrieve all records in the index.
      *
-     * @return the records
+     * @return the collection of {@link LuceneRepositoryContentRecord} objects.
      * @throws RepositoryIndexSearchException if there was an error searching the index
      */
     Collection getAllRecords()
@@ -89,64 +106,11 @@
      */
     Collection getAllRecordKeys()
         throws RepositoryIndexException;
-
-    /**
-     * Indexes the artifact specified. If the artifact is already in the repository they it is updated. 
-     * This method should use less memory than indexRecords as the records can be created and disposed of on the fly.
-     *
-     * @param artifact  the artifact to index
-     * @param factory   the artifact to record factory
-     * @throws RepositoryIndexException if there is a problem indexing the artifacts
-     */
-    void indexArtifact( Artifact artifact, RepositoryIndexRecordFactory factory )
-        throws RepositoryIndexException;
     
     /**
-     * Indexes the artifacts found within the specified list. If the artifacts are already in the
-     * repository they are updated. This method should use less memory than indexRecords as the records can be
-     * created and disposed of on the fly.
-     *
-     * @param artifacts the artifacts to index
-     * @param factory   the artifact to record factory
-     * @throws RepositoryIndexException if there is a problem indexing the artifacts
-     */
-    void indexArtifacts( List artifacts, RepositoryIndexRecordFactory factory )
-        throws RepositoryIndexException;
-
-    /**
-     * Get all the group IDs in the index.
-     *
-     * @return list of groups as strings
-     * @throws RepositoryIndexException if there is a problem searching for the group ID
-     */
-    List getAllGroupIds()
-        throws RepositoryIndexException;
-
-    /**
-     * Get the list of artifact IDs in a group in the index.
-     *
-     * @param groupId the group ID to search
-     * @return the list of artifact ID strings
-     * @throws RepositoryIndexSearchException if there is a problem searching for the group ID
-     */
-    List getArtifactIds( String groupId )
-        throws RepositoryIndexSearchException;
-
-    /**
-     * Get the list of available versions for a given artifact.
-     *
-     * @param groupId    the group ID to search for
-     * @param artifactId the artifact ID to search for
-     * @return the list of version strings
-     * @throws RepositoryIndexSearchException if there is a problem searching for the artifact
-     */
-    List getVersions( String groupId, String artifactId )
-        throws RepositoryIndexSearchException;
-
-    /**
-     * Get the time when the index was last updated. Note that this does not monitor external processes.
-     *
-     * @return the last updated time, or 0 if it has not been updated since the class was instantiated.
+     * Get the index directory.
+     * 
+     * @return the index directory.
      */
-    long getLastUpdatedTime();
+    File getIndexDirectory();
 }

Copied: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryContentIndexFactory.java (from r521491, maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryArtifactIndexFactory.java)
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryContentIndexFactory.java?view=diff&rev=525176&p1=maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryArtifactIndexFactory.java&r1=521491&p2=maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryContentIndexFactory.java&r2=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryArtifactIndexFactory.java (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/RepositoryContentIndexFactory.java Tue Apr  3 08:21:33 2007
@@ -19,33 +19,36 @@
  * under the License.
  */
 
-import java.io.File;
+import org.apache.maven.archiva.model.ArchivaRepository;
 
 /**
  * Obtain an index instance.
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  */
-public interface RepositoryArtifactIndexFactory
+public interface RepositoryContentIndexFactory
 {
     /**
-     * Plexus role.
+     * Method to create an instance of the bytecode index.
+     *
+     * @param repository the repository to create the content index from.
+     * @return the index instance
      */
-    String ROLE = RepositoryArtifactIndexFactory.class.getName();
-
+    RepositoryContentIndex createBytecodeIndex( ArchivaRepository repository );
+    
     /**
-     * Method to create an instance of the standard index.
+     * Method to create an instance of the file content index.
      *
-     * @param indexPath the path where the index will be created/updated
+     * @param repository the repository to create the file content index from.
      * @return the index instance
      */
-    RepositoryArtifactIndex createStandardIndex( File indexPath );
+    RepositoryContentIndex createFileContentIndex( ArchivaRepository repository );
 
     /**
-     * Method to create an instance of the minimal index.
+     * Method to create an instance of the hashcode index.
      *
-     * @param indexPath the path where the index will be created/updated
+     * @param repository the repository to create the content index from.
      * @return the index instance
      */
-    RepositoryArtifactIndex createMinimalIndex( File indexPath );
+    RepositoryContentIndex createHashcodeIndex( ArchivaRepository repository );
 }

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/bytecode/BytecodeAnalyzer.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/bytecode/BytecodeAnalyzer.java?view=auto&rev=525176
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/bytecode/BytecodeAnalyzer.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/bytecode/BytecodeAnalyzer.java Tue Apr  3 08:21:33 2007
@@ -0,0 +1,73 @@
+package org.apache.maven.archiva.indexer.bytecode;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.LowerCaseFilter;
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.analysis.StopFilter;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.maven.archiva.indexer.ArtifactKeys;
+import org.apache.maven.archiva.indexer.lucene.analyzers.ClassnameTokenizer;
+import org.apache.maven.archiva.indexer.lucene.analyzers.FilenamesTokenizer;
+import org.apache.maven.archiva.indexer.lucene.analyzers.GroupIdTokenizer;
+import org.apache.maven.archiva.indexer.lucene.analyzers.VersionTokenizer;
+
+import java.io.Reader;
+
+/**
+ * BytecodeAnalyzer 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class BytecodeAnalyzer extends Analyzer
+{
+    private static final Analyzer STANDARD = new StandardAnalyzer();
+
+    public TokenStream tokenStream( String field, Reader reader )
+    {
+        TokenStream tokenStream = null;
+
+        if ( BytecodeKeys.CLASSES.equals( field ) )
+        {
+            tokenStream = new ClassnameTokenizer( reader );
+        }
+        else if ( BytecodeKeys.FILES.equals( field ) )
+        {
+            tokenStream = new FilenamesTokenizer( reader );
+        }
+        else if ( ArtifactKeys.GROUPID.equals( field ) )
+        {
+            tokenStream = new GroupIdTokenizer( reader );
+        }
+        else if ( ArtifactKeys.VERSION.equals( field ) )
+        {
+            tokenStream = new VersionTokenizer( reader );
+        }
+        else
+        {
+            tokenStream = STANDARD.tokenStream( field, reader );
+        }
+        
+        return new LowerCaseFilter( new StopFilter( tokenStream, StopAnalyzer.ENGLISH_STOP_WORDS ) );
+    }
+}

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/bytecode/BytecodeAnalyzer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/bytecode/BytecodeAnalyzer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/bytecode/BytecodeAnalyzer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain