Class MirroringArtifactProvider
- java.lang.Object
-
- org.eclipse.tycho.repository.local.MirroringArtifactProvider
-
- All Implemented Interfaces:
org.eclipse.equinox.p2.query.IQueryable<org.eclipse.equinox.p2.metadata.IArtifactKey>
,IArtifactFileProvider
,IArtifactProvider
,IRawArtifactFileProvider
,IRawArtifactProvider
- Direct Known Subclasses:
PackedFormatMirroringArtifactProvider
public class MirroringArtifactProvider extends java.lang.Object implements IRawArtifactFileProvider
IRawArtifactFileProvider
which caches all accessed artifacts in the local Maven repository.Note that a MirroringArtifactProvider is not a transparent cache of the remote providers. The content provided by this instance differs from the remote providers' content in the following ways:
- This instance provides all content in the local Maven repository (previously cached or installed) in addition to the remote content. This allows lazy access to the remote repositories (bug 347477).
- This instance only provides the remote artifacts in certain formats, i.e. only the canonical format, or the canonical format and the packed format.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MirroringArtifactProvider.MirroringFailedException
-
Field Summary
Fields Modifier and Type Field Description protected LocalArtifactRepository
localArtifactRepository
protected MavenLogger
logger
protected org.eclipse.core.runtime.IProgressMonitor
monitor
protected IRawArtifactProvider
remoteProviders
protected MavenLogger
splittingLogger
-
Constructor Summary
Constructors Constructor Description MirroringArtifactProvider(LocalArtifactRepository localArtifactRepository, IRawArtifactProvider remoteProviders, MavenLogger logger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static org.eclipse.core.runtime.IStatus
artifactNotFoundStatus(org.eclipse.equinox.p2.metadata.IArtifactKey key)
boolean
contains(org.eclipse.equinox.p2.metadata.IArtifactKey key)
Returnstrue
if this is a provider for the given artifact.boolean
contains(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
Returnstrue
if this a provider for an artifact in the given formatprivate void
createCanonicalArtifactFromLocalPackedArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key)
static MirroringArtifactProvider
createInstance(LocalArtifactRepository localArtifactRepository, IRawArtifactProvider remoteProviders, boolean mirrorPacked, MavenLogger logger)
Creates a newMirroringArtifactProvider
instance.protected void
downloadArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key)
protected org.eclipse.core.runtime.IStatus
downloadCanonicalArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key)
protected org.eclipse.core.runtime.IStatus
downloadMostSpecificNeededFormatOfArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key)
private void
ensureArtifactIsPresentInCanonicalFormat(org.eclipse.equinox.p2.metadata.IArtifactKey key)
(package private) static org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor
findCanonicalDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] descriptors)
(package private) static org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor
findPackedDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] descriptors)
org.eclipse.core.runtime.IStatus
getArtifact(IArtifactSink sink, org.eclipse.core.runtime.IProgressMonitor monitor)
Writes the requested artifact to the givenIArtifactSink
.org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[]
getArtifactDescriptors(org.eclipse.equinox.p2.metadata.IArtifactKey key)
Return the raw artifact formats in which the given artifact can be provided.java.io.File
getArtifactFile(org.eclipse.equinox.p2.metadata.IArtifactKey key)
Returns the file system location of the given artifact.java.io.File
getArtifactFile(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
Returns the file system location of the given artifact in the given format.org.eclipse.core.runtime.IStatus
getRawArtifact(IRawArtifactSink sink, org.eclipse.core.runtime.IProgressMonitor monitor)
Writes the requested artifact in the specified raw format to the givenIRawArtifactSink
.private boolean
makeLocallyAvailable(org.eclipse.equinox.p2.metadata.IArtifactKey key)
Downloads the artifact from remote if it isn't available locally yet.protected boolean
makeOneFormatLocallyAvailable(org.eclipse.equinox.p2.metadata.IArtifactKey key)
(package private) org.eclipse.core.runtime.IProgressMonitor
monitorForDownload()
Returns anIProgressMonitor
which translates p2's status updates into a reasonable log output.private static org.eclipse.core.runtime.IProgressMonitor
nonNull(org.eclipse.core.runtime.IProgressMonitor monitor)
org.eclipse.equinox.p2.query.IQueryResult<org.eclipse.equinox.p2.metadata.IArtifactKey>
query(org.eclipse.equinox.p2.query.IQuery<org.eclipse.equinox.p2.metadata.IArtifactKey> query, org.eclipse.core.runtime.IProgressMonitor monitor)
-
-
-
Field Detail
-
logger
protected final MavenLogger logger
-
splittingLogger
protected final MavenLogger splittingLogger
-
remoteProviders
protected final IRawArtifactProvider remoteProviders
-
localArtifactRepository
protected final LocalArtifactRepository localArtifactRepository
-
monitor
protected final org.eclipse.core.runtime.IProgressMonitor monitor
-
-
Constructor Detail
-
MirroringArtifactProvider
MirroringArtifactProvider(LocalArtifactRepository localArtifactRepository, IRawArtifactProvider remoteProviders, MavenLogger logger)
-
-
Method Detail
-
createInstance
public static MirroringArtifactProvider createInstance(LocalArtifactRepository localArtifactRepository, IRawArtifactProvider remoteProviders, boolean mirrorPacked, MavenLogger logger)
Creates a newMirroringArtifactProvider
instance.- Parameters:
localArtifactRepository
- The local Maven repositoryremoteProviders
- The provider that will be queried by this instance when it is asked for an artifact which is not (yet) available in the local Maven repository. Typically this provider is backed by remote p2 repositories.mirrorPacked
- Iftrue
, the returned instance will also mirror the packed format of all artifacts it is asked for.logger
- a logger for progress output
-
contains
public final boolean contains(org.eclipse.equinox.p2.metadata.IArtifactKey key)
Description copied from interface:IArtifactProvider
Returnstrue
if this is a provider for the given artifact.- Specified by:
contains
in interfaceIArtifactProvider
- Parameters:
key
- An artifact key- Returns:
true
if this instance can provide the artifact for the given key
-
query
public final org.eclipse.equinox.p2.query.IQueryResult<org.eclipse.equinox.p2.metadata.IArtifactKey> query(org.eclipse.equinox.p2.query.IQuery<org.eclipse.equinox.p2.metadata.IArtifactKey> query, org.eclipse.core.runtime.IProgressMonitor monitor)
- Specified by:
query
in interfaceorg.eclipse.equinox.p2.query.IQueryable<org.eclipse.equinox.p2.metadata.IArtifactKey>
-
getArtifactFile
public final java.io.File getArtifactFile(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws MirroringArtifactProvider.MirroringFailedException
Description copied from interface:IArtifactFileProvider
Returns the file system location of the given artifact.- Specified by:
getArtifactFile
in interfaceIArtifactFileProvider
- Parameters:
key
- An artifact key- Returns:
- The location of the specified artifact, or
null
the given artifact does not exist. - Throws:
MirroringArtifactProvider.MirroringFailedException
-
getArtifactFile
public final java.io.File getArtifactFile(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor) throws MirroringArtifactProvider.MirroringFailedException
Description copied from interface:IRawArtifactFileProvider
Returns the file system location of the given artifact in the given format.- Specified by:
getArtifactFile
in interfaceIRawArtifactFileProvider
- Parameters:
descriptor
- The key and format of an artifact- Returns:
- The location of the specified raw artifact, or
null
the that artifact does not exist in the given format. - Throws:
MirroringArtifactProvider.MirroringFailedException
-
getArtifact
public final org.eclipse.core.runtime.IStatus getArtifact(IArtifactSink sink, org.eclipse.core.runtime.IProgressMonitor monitor) throws ArtifactSinkException, MirroringArtifactProvider.MirroringFailedException
Description copied from interface:IArtifactProvider
Writes the requested artifact to the givenIArtifactSink
.The implementation is free to pick the most suitable internal storage format to serve the request, e.g. it may extract the artifact from a pack200-compressed format. If an error is detected while streaming the artifact (e.g. an MD5 checksum error), the implementation may re-attempt the read from all other available sources. In case there were multiple read attempts, a multi-status with the results of all attempts is returned.
- Specified by:
getArtifact
in interfaceIArtifactProvider
- Parameters:
sink
- A sink for a specific artifact. When this method returns, the sink will either be closed (withIArtifactSink.commitWrite()
orIArtifactSink.abortWrite()
, depending on the status), or not have received any content.monitor
- A progress monitor, ornull
- Returns:
- A non-fatal status (warning or better) if the read operation was successful.
- Throws:
ArtifactSinkException
- if that exception is thrown by the givenIArtifactSink
MirroringArtifactProvider.MirroringFailedException
- See Also:
IArtifactSink.getArtifactToBeWritten()
-
getRawArtifact
public final org.eclipse.core.runtime.IStatus getRawArtifact(IRawArtifactSink sink, org.eclipse.core.runtime.IProgressMonitor monitor) throws ArtifactSinkException, MirroringArtifactProvider.MirroringFailedException
Description copied from interface:IRawArtifactProvider
Writes the requested artifact in the specified raw format to the givenIRawArtifactSink
.If an error is detected while streaming the artifact (e.g. an MD5 checksum error) and there are other sources available (e.g. in a composite provider), the implementation may re-attempt the read from these other sources. In case there were multiple read attempts, a multi-status with the results of all attempts is returned.
- Specified by:
getRawArtifact
in interfaceIRawArtifactProvider
- Parameters:
sink
- A sink for a specific artifact in a specific format. When this method returns, the sink will either be closed (withIArtifactSink.commitWrite()
orIArtifactSink.abortWrite()
, depending on the status), or not have received any content.monitor
- A progress monitor, ornull
- Returns:
- A non-fatal status (warning or better) if the read operation was successful.
- Throws:
ArtifactSinkException
- if that exception is thrown by the givenIArtifactSink
MirroringArtifactProvider.MirroringFailedException
- See Also:
IArtifactSink.getArtifactToBeWritten()
,IRawArtifactSink.getArtifactFormatToBeWritten()
-
getArtifactDescriptors
public final org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] getArtifactDescriptors(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws MirroringArtifactProvider.MirroringFailedException
Description copied from interface:IRawArtifactProvider
Return the raw artifact formats in which the given artifact can be provided.- Specified by:
getArtifactDescriptors
in interfaceIRawArtifactProvider
- Parameters:
key
- An artifact key- Returns:
- The descriptors associated with the given key
- Throws:
MirroringArtifactProvider.MirroringFailedException
-
contains
public final boolean contains(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor) throws MirroringArtifactProvider.MirroringFailedException
Description copied from interface:IRawArtifactProvider
Returnstrue
if this a provider for an artifact in the given format- Specified by:
contains
in interfaceIRawArtifactProvider
- Parameters:
descriptor
- An artifact descriptor- Returns:
true
if this instance can provide the artifact as raw artifact in the described format- Throws:
MirroringArtifactProvider.MirroringFailedException
-
makeLocallyAvailable
private boolean makeLocallyAvailable(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws MirroringArtifactProvider.MirroringFailedException
Downloads the artifact from remote if it isn't available locally yet.- Returns:
false
if the artifact is neither already cached locally nor available remotely.- Throws:
MirroringArtifactProvider.MirroringFailedException
- if a fatal error occurred while downloading the artifact.
-
makeOneFormatLocallyAvailable
protected boolean makeOneFormatLocallyAvailable(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws MirroringArtifactProvider.MirroringFailedException, org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException
- Throws:
MirroringArtifactProvider.MirroringFailedException
org.eclipse.equinox.p2.core.ProvisionException
ArtifactSinkException
-
downloadArtifact
protected final void downloadArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws MirroringArtifactProvider.MirroringFailedException, org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException
- Throws:
MirroringArtifactProvider.MirroringFailedException
org.eclipse.equinox.p2.core.ProvisionException
ArtifactSinkException
-
downloadMostSpecificNeededFormatOfArtifact
protected org.eclipse.core.runtime.IStatus downloadMostSpecificNeededFormatOfArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException
- Throws:
org.eclipse.equinox.p2.core.ProvisionException
ArtifactSinkException
-
downloadCanonicalArtifact
protected final org.eclipse.core.runtime.IStatus downloadCanonicalArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException
- Throws:
org.eclipse.equinox.p2.core.ProvisionException
ArtifactSinkException
-
ensureArtifactIsPresentInCanonicalFormat
private void ensureArtifactIsPresentInCanonicalFormat(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException
- Throws:
org.eclipse.equinox.p2.core.ProvisionException
ArtifactSinkException
-
createCanonicalArtifactFromLocalPackedArtifact
private void createCanonicalArtifactFromLocalPackedArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException
- Throws:
org.eclipse.equinox.p2.core.ProvisionException
ArtifactSinkException
-
findPackedDescriptor
static org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor findPackedDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] descriptors)
-
findCanonicalDescriptor
static org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor findCanonicalDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] descriptors)
-
artifactNotFoundStatus
private static org.eclipse.core.runtime.IStatus artifactNotFoundStatus(org.eclipse.equinox.p2.metadata.IArtifactKey key)
-
monitorForDownload
final org.eclipse.core.runtime.IProgressMonitor monitorForDownload()
Returns anIProgressMonitor
which translates p2's status updates into a reasonable log output.
-
nonNull
private static org.eclipse.core.runtime.IProgressMonitor nonNull(org.eclipse.core.runtime.IProgressMonitor monitor)
-
-