1 package org.apache.maven.archiva.conversion;
3 import org.apache.maven.archiva.Archiva;
4 import org.apache.maven.archiva.reporting.ReportingStore;
5 import org.apache.maven.archiva.reporting.ReportGroup;
6 import org.apache.maven.archiva.reporting.ReportingDatabase;
7 import org.apache.maven.archiva.reporting.ReportingStoreException;
8 import org.apache.maven.archiva.converter.RepositoryConverter;
9 import org.apache.maven.archiva.converter.RepositoryConversionException;
10 import org.apache.maven.archiva.discoverer.ArtifactDiscoverer;
11 import org.apache.maven.archiva.discoverer.DiscovererException;
12 import org.apache.maven.archiva.discoverer.filter.AcceptAllArtifactFilter;
13 import org.apache.maven.archiva.discoverer.filter.SnapshotArtifactFilter;
14 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
15 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
16 import org.apache.maven.artifact.repository.ArtifactRepository;
17 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
20 import java.net.MalformedURLException;
21 import java.util.List;
24 * @author Jason van Zyl
26 * @todo turn this into a general conversion component and hide all this crap here.
28 public class DefaultLegacyRepositoryConverter
29 implements LegacyRepositoryConverter
32 * @plexus.requirement role-hint="legacy"
34 private ArtifactDiscoverer artifactDiscoverer;
37 * @plexus.requirement role-hint="legacy"
39 private ArtifactRepositoryLayout legacyLayout;
42 * @plexus.requirement role-hint="default"
44 private ArtifactRepositoryLayout defaultLayout;
49 private ArtifactRepositoryFactory artifactRepositoryFactory;
54 private RepositoryConverter repositoryConverter;
59 private ReportingStore reportingStore;
62 * @plexus.requirement role-hint="health"
64 private ReportGroup reportGroup;
66 public void convertLegacyRepository( File legacyRepositoryDirectory,
67 File repositoryDirectory,
68 List blacklistedPatterns,
69 boolean includeSnapshots )
70 throws RepositoryConversionException, DiscovererException
72 ArtifactRepository legacyRepository;
74 ArtifactRepository repository;
78 legacyRepository = artifactRepositoryFactory.createArtifactRepository( "legacy",
79 legacyRepositoryDirectory.toURI().toURL().toString(),
80 legacyLayout, null, null );
82 repository = artifactRepositoryFactory.createArtifactRepository( "default",
83 repositoryDirectory.toURI().toURL().toString(),
84 defaultLayout, null, null );
86 catch ( MalformedURLException e )
88 throw new RepositoryConversionException( "Error convering legacy repository.", e );
91 ArtifactFilter filter =
92 includeSnapshots ? new AcceptAllArtifactFilter() : (ArtifactFilter) new SnapshotArtifactFilter();
93 List legacyArtifacts = artifactDiscoverer.discoverArtifacts( legacyRepository, blacklistedPatterns, filter );
95 ReportingDatabase reporter;
98 reporter = reportingStore.getReportsFromStore( repository, reportGroup );
100 repositoryConverter.convert( legacyArtifacts, repository, reporter );
102 reportingStore.storeReports( reporter, repository );
104 catch ( ReportingStoreException e )
106 throw new RepositoryConversionException( "Error convering legacy repository.", e );