]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1025] separate metadata consumer so that it can be run from the CLI without...
authorBrett Porter <brett@apache.org>
Mon, 1 Dec 2008 13:47:06 +0000 (13:47 +0000)
committerBrett Porter <brett@apache.org>
Mon, 1 Dec 2008 13:47:06 +0000 (13:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@722073 13f79535-47bb-0310-9956-ffa450edef68

MRM-1025/archiva-cli/pom.xml
MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArchivaMetadataCreationConsumer.java [deleted file]
MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/pom.xml
MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml [new file with mode: 0644]
MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java [new file with mode: 0644]
MRM-1025/archiva-modules/archiva-base/archiva-consumers/pom.xml
MRM-1025/archiva-modules/archiva-web/archiva-webapp/pom.xml

index 70f20a3ce9c5ab3b806a1b5a158320453a550e4b..6fc0f2cc73c8a7af563b5232c8952007e45b8154 100644 (file)
       <version>1.2-SNAPSHOT</version>
       <scope>runtime</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-metadata-consumer</artifactId>
+      <version>1.2-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
     <dependency>
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-xml-tools</artifactId>
index 2d1e5c78de9d00d65f98931ef26174dd5167bbee..cbf3e0557c9eff246342c1a539970ad65bcad25f 100644 (file)
       <artifactId>plexus-spring</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency> <!--  TODO: version into parent -->
-      <groupId>org.apache.archiva</groupId>
-      <artifactId>metadata-model</artifactId>
-      <version>1.2-SNAPSHOT</version>
-    </dependency>
-    <dependency> <!--  TODO: version into parent -->
-      <groupId>org.apache.archiva</groupId>
-      <artifactId>metadata-repository-api</artifactId>
-      <version>1.2-SNAPSHOT</version>
-    </dependency>
-    <dependency> <!--  TODO: version into parent, temporary coupling to file based repo -->
-      <groupId>org.apache.archiva</groupId>
-      <artifactId>metadata-repository-file</artifactId>
-      <version>1.2-SNAPSHOT</version>
-    </dependency>
 
     <!-- test dependencies -->
     <dependency>
diff --git a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArchivaMetadataCreationConsumer.java b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ArchivaMetadataCreationConsumer.java
deleted file mode 100644 (file)
index 593f72c..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-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 java.io.File;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.model.ProjectBuildMetadata;
-import org.apache.archiva.metadata.model.ProjectMetadata;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.file.FileMetadataRepository;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.ConfigurationNames;
-import org.apache.maven.archiva.configuration.FileTypes;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
-import org.apache.maven.archiva.consumers.ConsumerException;
-import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
-import org.apache.maven.archiva.model.ArtifactReference;
-import org.apache.maven.archiva.repository.ManagedRepositoryContent;
-import org.apache.maven.archiva.repository.RepositoryContentFactory;
-import org.apache.maven.archiva.repository.RepositoryException;
-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;
-
-/**
- * ArtifactUpdateDatabaseConsumer - Take an artifact off of disk and put it into the repository.
- * 
- * @version $Id: ArtifactUpdateDatabaseConsumer.java 718864 2008-11-19 06:33:35Z brett $
- * @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
- *                   role-hint="create-archiva-metadata" instantiation-strategy="per-lookup"
- */
-public class ArchivaMetadataCreationConsumer
-    extends AbstractMonitoredConsumer
-    implements KnownRepositoryContentConsumer, RegistryListener, Initializable
-{
-    /**
-     * @plexus.configuration default-value="create-archiva-metadata"
-     */
-    private String id;
-
-    /**
-     * @plexus.configuration default-value="Create basic metadata for Archiva to be able to reference the artifact"
-     */
-    private String description;
-
-    /**
-     * @plexus.requirement
-     */
-    private ArchivaConfiguration configuration;
-
-    /**
-     * @plexus.requirement
-     */
-    private FileTypes filetypes;
-
-    /**
-     * @plexus.requirement
-     */
-    private RepositoryContentFactory repositoryFactory;
-
-    private Date whenGathered;
-
-    private ManagedRepositoryContent repository;
-
-    private List<String> includes = new ArrayList<String>();
-
-    private MetadataRepository metadataRepository;
-
-    public String getId()
-    {
-        return this.id;
-    }
-
-    public String getDescription()
-    {
-        return this.description;
-    }
-
-    public boolean isPermanent()
-    {
-        return true;
-    }
-
-    public List<String> getExcludes()
-    {
-        return getDefaultArtifactExclusions();
-    }
-
-    public List<String> getIncludes()
-    {
-        return this.includes;
-    }
-
-    public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered )
-        throws ConsumerException
-    {
-        try
-        {
-            this.repository = repositoryFactory.getManagedRepositoryContent( repo.getId() );
-            this.metadataRepository = new FileMetadataRepository( new File( repository.getRepoRoot(), ".metadata" ) );
-            this.whenGathered = whenGathered;
-        }
-        catch ( RepositoryException e )
-        {
-            throw new ConsumerException( "Unable to start ArtifactUpdateDatabaseConsumer: " + e.getMessage(), e );
-        }
-    }
-
-    public void processFile( String path )
-        throws ConsumerException
-    {
-        // note that we do minimal processing including checksums and POM information for performance of
-        // the initial scan. Any request for this information will be intercepted and populated on-demand
-        // or picked up by subsequent scans
-        ArtifactReference artifact;
-        try
-        {
-            artifact = repository.toArtifactReference( path );
-        }
-        catch ( LayoutException e )
-        {
-            throw new ConsumerException( e.getMessage(), e );
-        }
-        
-        File file = new File( repository.getRepoRoot(), path );
-
-        // TODO: needed in a more central place, but trying to isolate impact to start with
-        String metadataId = artifact.getGroupId() + "." + artifact.getArtifactId();
-
-        ProjectMetadata project = new ProjectMetadata();
-        project.setId( metadataId );
-
-        ProjectBuildMetadata build = new ProjectBuildMetadata();
-        build.setId( artifact.getVersion() );
-
-        ArtifactMetadata artifactMeta = new ArtifactMetadata();
-        artifactMeta.setId( file.getName() );
-        artifactMeta.setUpdated( file.lastModified() );
-        artifactMeta.setSize( file.length() );
-
-        build.addArtifact( artifactMeta );
-        project.addBuild( build );
-
-        // TODO: store "whenGathered"
-        
-        // read the metadata and update it if it is newer or doesn't exist
-        metadataRepository.update( project );
-    }
-
-    public void completeScan()
-    {
-        /* do nothing */
-    }
-
-    public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
-    {
-        if ( ConfigurationNames.isRepositoryScanning( propertyName ) )
-        {
-            initIncludes();
-        }
-    }
-
-    public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
-    {
-        /* do nothing */
-    }
-
-    private void initIncludes()
-    {
-        includes.clear();
-
-        includes.addAll( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
-    }
-
-    public void initialize()
-        throws InitializationException
-    {
-        configuration.addChangeListener( this );
-
-        initIncludes();
-    }
-}
index c675a7c6aa9a6a3e4e908a57eab737b89b088977..e417bcd5a45cd4af8105382817e891376b0931d3 100644 (file)
@@ -1,3 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
diff --git a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml
new file mode 100644 (file)
index 0000000..98fb356
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>archiva-consumers</artifactId>
+    <groupId>org.apache.archiva</groupId>
+    <version>1.2-SNAPSHOT</version>
+  </parent>
+  <artifactId>archiva-metadata-consumer</artifactId>
+  <name>Archiva Metadata Consumer</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-consumer-api</artifactId>
+    </dependency>
+    <dependency> <!--  TODO: version into parent -->
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>metadata-model</artifactId>
+      <version>1.2-SNAPSHOT</version>
+    </dependency>
+    <dependency> <!--  TODO: version into parent -->
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>metadata-repository-api</artifactId>
+      <version>1.2-SNAPSHOT</version>
+    </dependency>
+    <dependency> <!--  TODO: version into parent, temporary coupling to file based repo -->
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>metadata-repository-file</artifactId>
+      <version>1.2-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-repository-layer</artifactId>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java b/MRM-1025/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java
new file mode 100644 (file)
index 0000000..1a65b7c
--- /dev/null
@@ -0,0 +1,195 @@
+package org.apache.archiva.consumers.metadata;
+
+/*
+ * 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.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.model.ProjectBuildMetadata;
+import org.apache.archiva.metadata.model.ProjectMetadata;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.file.FileMetadataRepository;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.ConfigurationNames;
+import org.apache.maven.archiva.configuration.FileTypes;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.maven.archiva.consumers.ConsumerException;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.maven.archiva.model.ArtifactReference;
+import org.apache.maven.archiva.repository.ManagedRepositoryContent;
+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;
+
+/**
+ * Take an artifact off of disk and put it into the metadata repository.
+ * 
+ * @version $Id: ArtifactUpdateDatabaseConsumer.java 718864 2008-11-19 06:33:35Z brett $
+ * @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
+ *                   role-hint="create-archiva-metadata" instantiation-strategy="per-lookup"
+ */
+public class ArchivaMetadataCreationConsumer
+    extends AbstractMonitoredConsumer
+    implements KnownRepositoryContentConsumer, RegistryListener, Initializable
+{
+    /**
+     * @plexus.configuration default-value="create-archiva-metadata"
+     */
+    private String id;
+
+    /**
+     * @plexus.configuration default-value="Create basic metadata for Archiva to be able to reference the artifact"
+     */
+    private String description;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArchivaConfiguration configuration;
+
+    /**
+     * @plexus.requirement
+     */
+    private FileTypes filetypes;
+
+    private Date whenGathered;
+
+    /**
+     * @plexus.requirement
+     */
+    private ManagedRepositoryContent repository;
+
+    private List<String> includes = new ArrayList<String>();
+
+    private MetadataRepository metadataRepository;
+
+    public String getId()
+    {
+        return this.id;
+    }
+
+    public String getDescription()
+    {
+        return this.description;
+    }
+
+    public boolean isPermanent()
+    {
+        return true;
+    }
+
+    public List<String> getExcludes()
+    {
+        return getDefaultArtifactExclusions();
+    }
+
+    public List<String> getIncludes()
+    {
+        return this.includes;
+    }
+
+    public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered )
+        throws ConsumerException
+    {
+        this.repository.setRepository( repo );
+        this.metadataRepository = new FileMetadataRepository( new File( repository.getRepoRoot(), ".metadata" ) );
+        this.whenGathered = whenGathered;
+    }
+
+    public void processFile( String path )
+        throws ConsumerException
+    {
+        // note that we do minimal processing including checksums and POM information for performance of
+        // the initial scan. Any request for this information will be intercepted and populated on-demand
+        // or picked up by subsequent scans
+        ArtifactReference artifact;
+        try
+        {
+            artifact = repository.toArtifactReference( path );
+        }
+        catch ( LayoutException e )
+        {
+            throw new ConsumerException( e.getMessage(), e );
+        }
+
+        File file = new File( repository.getRepoRoot(), path );
+
+        // TODO: needed in a more central place, but trying to isolate impact to start with
+        String metadataId = artifact.getGroupId() + "." + artifact.getArtifactId();
+
+        ProjectMetadata project = new ProjectMetadata();
+        project.setId( metadataId );
+
+        ProjectBuildMetadata build = new ProjectBuildMetadata();
+        build.setId( artifact.getVersion() );
+
+        ArtifactMetadata artifactMeta = new ArtifactMetadata();
+        artifactMeta.setId( file.getName() );
+        artifactMeta.setUpdated( file.lastModified() );
+        artifactMeta.setSize( file.length() );
+
+        build.addArtifact( artifactMeta );
+        project.addBuild( build );
+
+        // TODO: store "whenGathered"
+
+        // read the metadata and update it if it is newer or doesn't exist
+        metadataRepository.update( project );
+    }
+
+    public void completeScan()
+    {
+        /* do nothing */
+    }
+
+    public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+    {
+        if ( ConfigurationNames.isRepositoryScanning( propertyName ) )
+        {
+            initIncludes();
+        }
+    }
+
+    public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
+    {
+        /* do nothing */
+    }
+
+    private void initIncludes()
+    {
+        includes.clear();
+
+        includes.addAll( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
+    }
+
+    public void initialize()
+        throws InitializationException
+    {
+        configuration.addChangeListener( this );
+
+        initIncludes();
+    }
+}
index 4d67521645a19e2bf7516a715036e0bc8773f072..5ffbb940666e95c87a22b3239105a8320d0911e6 100644 (file)
@@ -1,18 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  ~ Copyright 2005-2006 The Apache Software Foundation.
+  ~ 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
   ~
-  ~ Licensed 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
   ~
-  ~      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.
+  ~ 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.
   -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -35,6 +38,7 @@
     <module>archiva-lucene-consumers</module>
     <module>archiva-signature-consumers</module>
     <module>archiva-dependency-tree-consumer</module>
+    <module>archiva-metadata-consumer</module>
   </modules>
 
   <build>
index f353e46b0908c11619cd5286f2ca31aa41aeddf4..768236b3d6478913ffa59f92a9b19757eeb4f689 100644 (file)
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-database-consumers</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-metadata-consumer</artifactId>
+      <version>1.2-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
     <dependency>
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-lucene-consumers</artifactId>