mirror of https://github.com/apache/archiva.git
Upgrading bidirlayout usage to RepoContent usage to eliminate bugs around missing content from bad layout routines.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@585583 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e02dcf50cf
commit
b571fcf307
|
@ -32,16 +32,15 @@ import org.apache.maven.archiva.database.ObjectNotFoundException;
|
||||||
import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint;
|
import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint;
|
||||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||||
import org.apache.maven.archiva.model.RepositoryProblem;
|
import org.apache.maven.archiva.model.RepositoryProblem;
|
||||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
|
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
import org.apache.maven.archiva.repository.RepositoryException;
|
||||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
||||||
import org.codehaus.plexus.registry.Registry;
|
import org.codehaus.plexus.registry.Registry;
|
||||||
import org.codehaus.plexus.registry.RegistryListener;
|
import org.codehaus.plexus.registry.RegistryListener;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,9 +84,9 @@ public class DuplicateArtifactsConsumer
|
||||||
/**
|
/**
|
||||||
* @plexus.requirement
|
* @plexus.requirement
|
||||||
*/
|
*/
|
||||||
private BidirectionalRepositoryLayoutFactory layoutFactory;
|
private RepositoryContentFactory repositoryFactory;
|
||||||
|
|
||||||
private List includes = new ArrayList();
|
private List<String> includes = new ArrayList<String>();
|
||||||
|
|
||||||
public String getId()
|
public String getId()
|
||||||
{
|
{
|
||||||
|
@ -114,7 +113,7 @@ public class DuplicateArtifactsConsumer
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getIncludedTypes()
|
public List<String> getIncludedTypes()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +123,7 @@ public class DuplicateArtifactsConsumer
|
||||||
{
|
{
|
||||||
String checksumSha1 = artifact.getModel().getChecksumSHA1();
|
String checksumSha1 = artifact.getModel().getChecksumSHA1();
|
||||||
|
|
||||||
List results = null;
|
List<ArchivaArtifact> results = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
results = dao.getArtifactDAO().queryArtifacts( new ArtifactsByChecksumConstraint(
|
results = dao.getArtifactDAO().queryArtifacts( new ArtifactsByChecksumConstraint(
|
||||||
|
@ -150,11 +149,8 @@ public class DuplicateArtifactsConsumer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator it = results.iterator();
|
for ( ArchivaArtifact dupArtifact : results )
|
||||||
while ( it.hasNext() )
|
|
||||||
{
|
{
|
||||||
ArchivaArtifact dupArtifact = (ArchivaArtifact) it.next();
|
|
||||||
|
|
||||||
if ( dupArtifact.equals( artifact ) )
|
if ( dupArtifact.equals( artifact ) )
|
||||||
{
|
{
|
||||||
// Skip reference to itself.
|
// Skip reference to itself.
|
||||||
|
@ -190,10 +186,11 @@ public class DuplicateArtifactsConsumer
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BidirectionalRepositoryLayout layout = layoutFactory.getLayout( artifact );
|
String repoId = artifact.getModel().getRepositoryId();
|
||||||
return layout.toPath( artifact );
|
ManagedRepositoryContent repo = repositoryFactory.getManagedRepositoryContent( repoId );
|
||||||
|
return repo.toPath( artifact );
|
||||||
}
|
}
|
||||||
catch ( LayoutException e )
|
catch ( RepositoryException e )
|
||||||
{
|
{
|
||||||
getLogger().warn( "Unable to calculate path for artifact: " + artifact );
|
getLogger().warn( "Unable to calculate path for artifact: " + artifact );
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -32,9 +32,9 @@ import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||||
import org.apache.maven.archiva.model.RepositoryProblem;
|
import org.apache.maven.archiva.model.RepositoryProblem;
|
||||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
|
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
import org.apache.maven.archiva.repository.RepositoryException;
|
||||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
||||||
import org.codehaus.plexus.registry.Registry;
|
import org.codehaus.plexus.registry.Registry;
|
||||||
|
@ -93,11 +93,11 @@ public class LocationArtifactsConsumer
|
||||||
/**
|
/**
|
||||||
* @plexus.requirement
|
* @plexus.requirement
|
||||||
*/
|
*/
|
||||||
private BidirectionalRepositoryLayoutFactory layoutFactory;
|
private RepositoryContentFactory repositoryFactory;
|
||||||
|
|
||||||
private Map repositoryMap = new HashMap();
|
private Map repositoryMap = new HashMap();
|
||||||
|
|
||||||
private List includes = new ArrayList();
|
private List<String> includes = new ArrayList<String>();
|
||||||
|
|
||||||
public String getId()
|
public String getId()
|
||||||
{
|
{
|
||||||
|
@ -219,14 +219,14 @@ public class LocationArtifactsConsumer
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List findJarEntryPattern( JarFile jar, String pattern )
|
private List<JarEntry> findJarEntryPattern( JarFile jar, String pattern )
|
||||||
{
|
{
|
||||||
List hits = new ArrayList();
|
List<JarEntry> hits = new ArrayList<JarEntry>();
|
||||||
|
|
||||||
Enumeration entries = jar.entries();
|
Enumeration<JarEntry> entries = jar.entries();
|
||||||
while ( entries.hasMoreElements() )
|
while ( entries.hasMoreElements() )
|
||||||
{
|
{
|
||||||
JarEntry entry = (JarEntry) entries.nextElement();
|
JarEntry entry = entries.nextElement();
|
||||||
if ( SelectorUtils.match( pattern, entry.getName() ) )
|
if ( SelectorUtils.match( pattern, entry.getName() ) )
|
||||||
{
|
{
|
||||||
hits.add( entry );
|
hits.add( entry );
|
||||||
|
@ -294,13 +294,14 @@ public class LocationArtifactsConsumer
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BidirectionalRepositoryLayout layout = layoutFactory.getLayout( artifact );
|
String repoId = artifact.getModel().getRepositoryId();
|
||||||
return layout.toPath( artifact );
|
ManagedRepositoryContent repo = repositoryFactory.getManagedRepositoryContent( repoId );
|
||||||
|
return repo.toPath( artifact );
|
||||||
}
|
}
|
||||||
catch ( LayoutException e )
|
catch ( RepositoryException e )
|
||||||
{
|
{
|
||||||
getLogger().warn( "Unable to calculate path for artifact: " + artifact );
|
getLogger().warn( "Unable to calculate path for artifact: " + artifact );
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue