]> source.dussan.org Git - archiva.git/commitdiff
o breaking out the converter to a separate component to keep the application componen...
authorJason van Zyl <jvanzyl@apache.org>
Fri, 3 Nov 2006 02:08:35 +0000 (02:08 +0000)
committerJason van Zyl <jvanzyl@apache.org>
Fri, 3 Nov 2006 02:08:35 +0000 (02:08 +0000)
  over crowded.

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@470634 13f79535-47bb-0310-9956-ffa450edef68

archiva-core/src/main/java/org/apache/maven/archiva/Archiva.java [new file with mode: 0644]
archiva-core/src/main/java/org/apache/maven/archiva/DefaultArchiva.java [new file with mode: 0644]
archiva-core/src/main/java/org/apache/maven/archiva/DefaultRepositoryManager.java [deleted file]
archiva-core/src/main/java/org/apache/maven/archiva/RepositoryManager.java [deleted file]
archiva-core/src/main/java/org/apache/maven/archiva/conversion/DefaultLegacyRepositoryConverter.java [new file with mode: 0644]
archiva-core/src/main/java/org/apache/maven/archiva/conversion/LegacyRepositoryConverter.java [new file with mode: 0644]
archiva-core/src/test/java/org/apache/maven/archiva/RepositoryManagerTest.java

diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/Archiva.java b/archiva-core/src/main/java/org/apache/maven/archiva/Archiva.java
new file mode 100644 (file)
index 0000000..460cad7
--- /dev/null
@@ -0,0 +1,44 @@
+package org.apache.maven.archiva;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * 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
+ *
+ * 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.converter.RepositoryConversionException;
+import org.apache.maven.archiva.discoverer.DiscovererException;
+
+import java.io.File;
+
+/**
+ * @author Jason van Zyl
+ */
+public interface Archiva
+{
+    /**
+     * Role of the Repository Manager
+     */
+    String ROLE = Archiva.class.getName();
+
+    /**
+     * Convert a legacy repository to a modern repository. This means a Maven 1.x repository
+     * using v3 POMs to a Maven 2.x repository using v4.0.0 POMs.
+     *
+     * @param legacyRepositoryDirectory
+     * @param repositoryDirectory
+     * @throws RepositoryConversionException
+     */
+    void convertLegacyRepository( File legacyRepositoryDirectory, File repositoryDirectory, boolean includeSnapshots )
+        throws RepositoryConversionException, DiscovererException;
+}
diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/DefaultArchiva.java b/archiva-core/src/main/java/org/apache/maven/archiva/DefaultArchiva.java
new file mode 100644 (file)
index 0000000..59fc606
--- /dev/null
@@ -0,0 +1,46 @@
+package org.apache.maven.archiva;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * 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
+ *
+ * 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.conversion.LegacyRepositoryConverter;
+import org.apache.maven.archiva.converter.RepositoryConversionException;
+import org.apache.maven.archiva.discoverer.DiscovererException;
+
+import java.io.File;
+
+/**
+ * @author Jason van Zyl
+ * @plexus.component
+ * @todo turn this into a general conversion component and hide all this crap here.
+ */
+public class DefaultArchiva
+    implements Archiva
+{
+    /**
+     * @plexus.requirement
+     */
+    private LegacyRepositoryConverter legacyRepositoryConverter;
+
+    public void convertLegacyRepository( File legacyRepositoryDirectory,
+                                         File repositoryDirectory,
+                                         boolean includeSnapshots )
+        throws RepositoryConversionException, DiscovererException
+    {
+        legacyRepositoryConverter.convertLegacyRepository( legacyRepositoryDirectory, repositoryDirectory,
+                                                           includeSnapshots );
+    }
+}
diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/DefaultRepositoryManager.java b/archiva-core/src/main/java/org/apache/maven/archiva/DefaultRepositoryManager.java
deleted file mode 100644 (file)
index b9622cf..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.apache.maven.archiva;
-
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * 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
- *
- * 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.converter.RepositoryConversionException;
-import org.apache.maven.archiva.converter.RepositoryConverter;
-import org.apache.maven.archiva.discoverer.ArtifactDiscoverer;
-import org.apache.maven.archiva.discoverer.DiscovererException;
-import org.apache.maven.archiva.discoverer.filter.AcceptAllArtifactFilter;
-import org.apache.maven.archiva.discoverer.filter.SnapshotArtifactFilter;
-import org.apache.maven.archiva.reporting.ReportGroup;
-import org.apache.maven.archiva.reporting.ReportingDatabase;
-import org.apache.maven.archiva.reporting.ReportingStore;
-import org.apache.maven.archiva.reporting.ReportingStoreException;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.List;
-
-/**
- * @author Jason van Zyl
- * @plexus.component
- */
-public class DefaultRepositoryManager
-    implements RepositoryManager
-{
-    /**
-     * @plexus.requirement role-hint="legacy"
-     */
-    private ArtifactDiscoverer artifactDiscoverer;
-
-    /**
-     * @plexus.requirement role-hint="legacy"
-     */
-    private ArtifactRepositoryLayout legacyLayout;
-
-    /**
-     * @plexus.requirement role-hint="default"
-     */
-    private ArtifactRepositoryLayout defaultLayout;
-
-    /**
-     * @plexus.requirement
-     */
-    private ArtifactRepositoryFactory artifactRepositoryFactory;
-
-    /**
-     * @plexus.requirement
-     */
-    private RepositoryConverter repositoryConverter;
-
-    /**
-     * @plexus.requirement
-     */
-    private ReportingStore reportingStore;
-
-    /**
-     * @plexus.requirement role-hint="health"
-     */
-    private ReportGroup reportGroup;
-
-    public void convertLegacyRepository( File legacyRepositoryDirectory, File repositoryDirectory,
-                                         boolean includeSnapshots )
-        throws RepositoryConversionException, DiscovererException
-    {
-        ArtifactRepository legacyRepository;
-
-        ArtifactRepository repository;
-
-        try
-        {
-            legacyRepository = artifactRepositoryFactory.createArtifactRepository( "legacy",
-                                                                                   legacyRepositoryDirectory.toURI().toURL().toString(),
-                                                                                   legacyLayout, null, null );
-
-            repository = artifactRepositoryFactory.createArtifactRepository( "default",
-                                                                             repositoryDirectory.toURI().toURL().toString(),
-                                                                             defaultLayout, null, null );
-        }
-        catch ( MalformedURLException e )
-        {
-            throw new RepositoryConversionException( "Error convering legacy repository.", e );
-        }
-
-        ArtifactFilter filter =
-            includeSnapshots ? new AcceptAllArtifactFilter() : (ArtifactFilter) new SnapshotArtifactFilter();
-        List legacyArtifacts = artifactDiscoverer.discoverArtifacts( legacyRepository, null, filter );
-
-        ReportingDatabase reporter;
-        try
-        {
-            reporter = reportingStore.getReportsFromStore( repository, reportGroup );
-
-            repositoryConverter.convert( legacyArtifacts, repository, reporter );
-
-            reportingStore.storeReports( reporter, repository );
-        }
-        catch ( ReportingStoreException e )
-        {
-            throw new RepositoryConversionException( "Error convering legacy repository.", e );
-        }
-    }
-}
diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/RepositoryManager.java b/archiva-core/src/main/java/org/apache/maven/archiva/RepositoryManager.java
deleted file mode 100644 (file)
index 56b47f3..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.apache.maven.archiva;
-
-/*
- * Copyright 2005-2006 The Apache Software Foundation.
- *
- * 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
- *
- * 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.converter.RepositoryConversionException;
-import org.apache.maven.archiva.discoverer.DiscovererException;
-
-import java.io.File;
-
-/**
- * @author Jason van Zyl
- */
-public interface RepositoryManager
-{
-    /**
-     * Role of the Repository Manager
-     */
-    String ROLE = RepositoryManager.class.getName();
-
-    /**
-     * Convert a legacy repository to a modern repository. This means a Maven 1.x repository
-     * using v3 POMs to a Maven 2.x repository using v4.0.0 POMs.
-     *
-     * @param legacyRepositoryDirectory
-     * @param repositoryDirectory
-     * @throws RepositoryConversionException
-     */
-    void convertLegacyRepository( File legacyRepositoryDirectory, File repositoryDirectory, boolean includeSnapshots )
-        throws RepositoryConversionException, DiscovererException;
-}
diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/conversion/DefaultLegacyRepositoryConverter.java b/archiva-core/src/main/java/org/apache/maven/archiva/conversion/DefaultLegacyRepositoryConverter.java
new file mode 100644 (file)
index 0000000..6673f19
--- /dev/null
@@ -0,0 +1,107 @@
+package org.apache.maven.archiva.conversion;
+
+import org.apache.maven.archiva.Archiva;
+import org.apache.maven.archiva.reporting.ReportingStore;
+import org.apache.maven.archiva.reporting.ReportGroup;
+import org.apache.maven.archiva.reporting.ReportingDatabase;
+import org.apache.maven.archiva.reporting.ReportingStoreException;
+import org.apache.maven.archiva.converter.RepositoryConverter;
+import org.apache.maven.archiva.converter.RepositoryConversionException;
+import org.apache.maven.archiva.discoverer.ArtifactDiscoverer;
+import org.apache.maven.archiva.discoverer.DiscovererException;
+import org.apache.maven.archiva.discoverer.filter.AcceptAllArtifactFilter;
+import org.apache.maven.archiva.discoverer.filter.SnapshotArtifactFilter;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.List;
+
+/**
+ * @author Jason van Zyl
+ * @plexus.component
+ * @todo turn this into a general conversion component and hide all this crap here.
+ */
+public class DefaultLegacyRepositoryConverter
+    implements LegacyRepositoryConverter
+{
+    /**
+     * @plexus.requirement role-hint="legacy"
+     */
+    private ArtifactDiscoverer artifactDiscoverer;
+
+    /**
+     * @plexus.requirement role-hint="legacy"
+     */
+    private ArtifactRepositoryLayout legacyLayout;
+
+    /**
+     * @plexus.requirement role-hint="default"
+     */
+    private ArtifactRepositoryLayout defaultLayout;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArtifactRepositoryFactory artifactRepositoryFactory;
+
+    /**
+     * @plexus.requirement
+     */
+    private RepositoryConverter repositoryConverter;
+
+    /**
+     * @plexus.requirement
+     */
+    private ReportingStore reportingStore;
+
+    /**
+     * @plexus.requirement role-hint="health"
+     */
+    private ReportGroup reportGroup;
+
+    public void convertLegacyRepository( File legacyRepositoryDirectory, File repositoryDirectory,
+                                         boolean includeSnapshots )
+        throws RepositoryConversionException, DiscovererException
+    {
+        ArtifactRepository legacyRepository;
+
+        ArtifactRepository repository;
+
+        try
+        {
+            legacyRepository = artifactRepositoryFactory.createArtifactRepository( "legacy",
+                                                                                   legacyRepositoryDirectory.toURI().toURL().toString(),
+                                                                                   legacyLayout, null, null );
+
+            repository = artifactRepositoryFactory.createArtifactRepository( "default",
+                                                                             repositoryDirectory.toURI().toURL().toString(),
+                                                                             defaultLayout, null, null );
+        }
+        catch ( MalformedURLException e )
+        {
+            throw new RepositoryConversionException( "Error convering legacy repository.", e );
+        }
+
+        ArtifactFilter filter =
+            includeSnapshots ? new AcceptAllArtifactFilter() : (ArtifactFilter) new SnapshotArtifactFilter();
+        List legacyArtifacts = artifactDiscoverer.discoverArtifacts( legacyRepository, null, filter );
+
+        ReportingDatabase reporter;
+        try
+        {
+            reporter = reportingStore.getReportsFromStore( repository, reportGroup );
+
+            repositoryConverter.convert( legacyArtifacts, repository, reporter );
+
+            reportingStore.storeReports( reporter, repository );
+        }
+        catch ( ReportingStoreException e )
+        {
+            throw new RepositoryConversionException( "Error convering legacy repository.", e );
+        }
+    }
+}
diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/conversion/LegacyRepositoryConverter.java b/archiva-core/src/main/java/org/apache/maven/archiva/conversion/LegacyRepositoryConverter.java
new file mode 100644 (file)
index 0000000..17f6864
--- /dev/null
@@ -0,0 +1,25 @@
+package org.apache.maven.archiva.conversion;
+
+import org.apache.maven.archiva.converter.RepositoryConversionException;
+import org.apache.maven.archiva.discoverer.DiscovererException;
+
+import java.io.File;
+
+/**
+ * @author Jason van Zyl
+ */
+public interface LegacyRepositoryConverter
+{
+    String ROLE = LegacyRepositoryConverter.class.getName();
+
+    /**
+     * Convert a legacy repository to a modern repository. This means a Maven 1.x repository
+     * using v3 POMs to a Maven 2.x repository using v4.0.0 POMs.
+     *
+     * @param legacyRepositoryDirectory
+     * @param repositoryDirectory
+     * @throws org.apache.maven.archiva.converter.RepositoryConversionException
+     */
+    void convertLegacyRepository( File legacyRepositoryDirectory, File repositoryDirectory, boolean includeSnapshots )
+        throws RepositoryConversionException, DiscovererException;
+}
index 27acf5067c3cf3e7943a5f1976bc28d84fae99f9..6c2fa03b888b190ed36733086dcc21d098ebdb42 100644 (file)
@@ -33,7 +33,7 @@ public class RepositoryManagerTest
 
         File repositoryDirectory = getTestFile( "target/maven-2.x-repository" );
 
-        RepositoryManager rm = (RepositoryManager) lookup( RepositoryManager.ROLE );
+        Archiva rm = (Archiva) lookup( Archiva.ROLE );
 
         rm.convertLegacyRepository( legacyRepositoryDirectory, repositoryDirectory, true );
     }