Class ArtifactRepositoryBaseImpl<ArtifactDescriptorT extends org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor>
- java.lang.Object
-
- org.eclipse.core.runtime.PlatformObject
-
- org.eclipse.equinox.p2.repository.spi.AbstractRepository<org.eclipse.equinox.p2.metadata.IArtifactKey>
-
- org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository
-
- org.eclipse.tycho.repository.p2base.artifact.repository.AbstractArtifactRepository2
-
- org.eclipse.tycho.repository.p2base.artifact.repository.ArtifactRepositoryBaseImpl<ArtifactDescriptorT>
-
- All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable,org.eclipse.equinox.p2.query.IQueryable<org.eclipse.equinox.p2.metadata.IArtifactKey>,org.eclipse.equinox.p2.repository.artifact.IArtifactRepository,org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository,org.eclipse.equinox.p2.repository.IRepository<org.eclipse.equinox.p2.metadata.IArtifactKey>,IArtifactFileProvider,IArtifactProvider,IRawArtifactFileProvider,IRawArtifactProvider
- Direct Known Subclasses:
LocalArtifactRepository,ModuleArtifactRepository,TargetPlatformBundlePublisher.PublishedBundlesArtifactRepository
public abstract class ArtifactRepositoryBaseImpl<ArtifactDescriptorT extends org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor> extends AbstractArtifactRepository2 implements org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository, IRawArtifactFileProvider
Base implementation of a mutable, file system based p2 artifact repository. This class manages changes to the index. Sub-classes need to- provide the storage location of artifacts – see
getArtifactFile(IArtifactDescriptor), and - provide the internal artifact descriptor instances – see
getInternalDescriptorForAdding(IArtifactDescriptor),getComparableDescriptor(IArtifactDescriptor)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classArtifactRepositoryBaseImpl.AddingArtifactSinkprivate classArtifactRepositoryBaseImpl.RawAddingArtifactSink
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<ArtifactDescriptorT>descriptorsprotected java.util.Map<org.eclipse.equinox.p2.metadata.IArtifactKey,java.util.Set<ArtifactDescriptorT>>descriptorsMapprivate static org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[]EMPTY_DESCRIPTOR_ARRAYprivate ArtifactTransferPolicytransferPolicy
-
Constructor Summary
Constructors Modifier Constructor Description protectedArtifactRepositoryBaseImpl(org.eclipse.equinox.p2.core.IProvisioningAgent agent, java.net.URI location, ArtifactTransferPolicy transferPolicy)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private voidcloseProcessingSteps(java.io.OutputStream destinationWithProcessing)private static voidcloseSinkAccordingToStatus(IArtifactSink sink, org.eclipse.core.runtime.IStatus status)booleancontains(org.eclipse.equinox.p2.metadata.IArtifactKey key)Returnstrueif this is a provider for the given artifact.booleancontains(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)Returnstrueif this a provider for an artifact in the given formatorg.eclipse.equinox.p2.query.IQueryable<org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor>descriptorQueryable()(package private) static org.eclipse.core.runtime.IStatuserrorStatus(java.lang.String message, java.lang.Throwable cause)(package private) static org.eclipse.core.runtime.IStatuserrorStatus(java.lang.String message, java.lang.Throwable cause, int code)org.eclipse.core.runtime.IStatusgetArtifact(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor, java.io.OutputStream destination, org.eclipse.core.runtime.IProgressMonitor monitor)Deprecated.Obsolete.org.eclipse.core.runtime.IStatusgetArtifact(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.FilegetArtifactFile(org.eclipse.equinox.p2.metadata.IArtifactKey key)Returns the file system location of the given artifact.java.io.FilegetArtifactFile(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)Returns the file system location of the given artifact in the given format.protected abstract org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptorgetComparableDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)Returns anIArtifactDescriptorinstance which is comparable to the artifact descriptors stored in the index (i.e.protected abstract ArtifactDescriptorTgetInternalDescriptorForAdding(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)Returns an artifact descriptor of the internal descriptor typeArtifactDescriptorTwhich may be added to the index.private org.eclipse.core.runtime.IStatusgetProcessedRawArtifact(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor, java.io.OutputStream destination, org.eclipse.core.runtime.IProgressMonitor monitor)org.eclipse.core.runtime.IStatusgetRawArtifact(IRawArtifactSink sink, org.eclipse.core.runtime.IProgressMonitor monitor)Writes the requested artifact in the specified raw format to the givenIRawArtifactSink.private java.util.Set<ArtifactDescriptorT>initDescriptorsMapEntry(org.eclipse.equinox.p2.metadata.IArtifactKey key)protected voidinternalAddDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)protected voidinternalAddInternalDescriptor(ArtifactDescriptorT internalDescriptor)protected abstract java.io.FileinternalGetArtifactStorageLocation(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)Returns the file system location where the given artifact is or would be stored.protected ArtifactRepositoryBaseImpl.AddingArtifactSinkinternalNewAddingArtifactSink(ArtifactDescriptorT canonicalDescriptorToBeAdded)protected voidinternalRemoveAllDescriptors()protected voidinternalRemoveDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)protected voidinternalRemoveDescriptors(org.eclipse.equinox.p2.metadata.IArtifactKey key)protected voidinternalRemoveDescriptors(org.eclipse.equinox.p2.metadata.IArtifactKey[] keys)protected voidinternalRemoveDescriptors(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] descriptors)protected voidinternalStore(org.eclipse.core.runtime.IProgressMonitor monitor)Persists the index of this repository.IArtifactSinknewAddingArtifactSink(org.eclipse.equinox.p2.metadata.IArtifactKey key)Returns a newIArtifactSinkinstance that adds the received artifact to this repository onIArtifactSink.commitWrite().IRawArtifactSinknewAddingRawArtifactSink(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor newDescriptor)Returns a newIRawArtifactSinkinstance that adds the received artifact to this repository onIArtifactSink.commitWrite().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)private org.eclipse.core.runtime.IStatusreadRawArtifact(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor, java.io.OutputStream destination)-
Methods inherited from class org.eclipse.tycho.repository.p2base.artifact.repository.AbstractArtifactRepository2
addDescriptor, addDescriptor, addDescriptors, addDescriptors, getArtifacts, getOutputStream, getRawArtifact, isFatal, removeAll, removeAll, removeDescriptor, removeDescriptor, removeDescriptor, removeDescriptor, removeDescriptors, removeDescriptors, removeDescriptors, removeDescriptors, setStatusOnStreamIfPossible
-
Methods inherited from class org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository
createArtifactDescriptor, createArtifactKey, equals, executeBatch, hashCode
-
Methods inherited from class org.eclipse.equinox.p2.repository.spi.AbstractRepository
assertModifiable, getDescription, getLocation, getName, getProperties, getProperty, getProvider, getProvisioningAgent, getType, getVersion, isModifiable, setDescription, setLocation, setName, setProperties, setProperty, setProperty, setProvider, setType, setVersion
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.equinox.p2.repository.artifact.IArtifactRepository
addDescriptor, addDescriptor, addDescriptors, addDescriptors, createArtifactDescriptor, createArtifactKey, executeBatch, getArtifacts, getOutputStream, getRawArtifact, removeAll, removeAll, removeDescriptor, removeDescriptor, removeDescriptor, removeDescriptor, removeDescriptors, removeDescriptors, removeDescriptors, removeDescriptors
-
-
-
-
Field Detail
-
EMPTY_DESCRIPTOR_ARRAY
private static final org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] EMPTY_DESCRIPTOR_ARRAY
-
descriptors
protected java.util.Set<ArtifactDescriptorT extends org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor> descriptors
-
descriptorsMap
protected java.util.Map<org.eclipse.equinox.p2.metadata.IArtifactKey,java.util.Set<ArtifactDescriptorT extends org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor>> descriptorsMap
-
transferPolicy
private ArtifactTransferPolicy transferPolicy
-
-
Constructor Detail
-
ArtifactRepositoryBaseImpl
protected ArtifactRepositoryBaseImpl(org.eclipse.equinox.p2.core.IProvisioningAgent agent, java.net.URI location, ArtifactTransferPolicy transferPolicy)
-
-
Method Detail
-
getComparableDescriptor
protected abstract org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor getComparableDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
Returns anIArtifactDescriptorinstance which is comparable to the artifact descriptors stored in the index (i.e. thedescriptorsmember). A valid implementation is to convert the argument to the internal descriptor typeArtifactDescriptorT, but this is not a requirement. This method should be implemented in a way so that callingdescriptors.contains(getComparableDescriptor(foreignDescriptor))with a descriptor from a foreign artifact repository returnstrueif and only if copying that foreign artifact to this repository withAbstractArtifactRepository2.getOutputStream(IArtifactDescriptor)would not add a new artifact to this repository.This method may be called by any API method with an
IArtifactDescriptorargument.- Parameters:
descriptor- AnIArtifactDescriptorfrom any artifact repository.
-
contains
public final boolean contains(org.eclipse.equinox.p2.metadata.IArtifactKey key)
Description copied from interface:IArtifactProviderReturnstrueif this is a provider for the given artifact.- Specified by:
containsin interfaceIArtifactProvider- Specified by:
containsin interfaceorg.eclipse.equinox.p2.repository.artifact.IArtifactRepository- Specified by:
containsin classorg.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository- Parameters:
key- An artifact key- Returns:
trueif this instance can provide the artifact for the given key
-
contains
public final boolean contains(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
Description copied from interface:IRawArtifactProviderReturnstrueif this a provider for an artifact in the given format- Specified by:
containsin interfaceorg.eclipse.equinox.p2.repository.artifact.IArtifactRepository- Specified by:
containsin interfaceIRawArtifactProvider- Specified by:
containsin classorg.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository- Parameters:
descriptor- An artifact descriptor- Returns:
trueif this instance can provide the artifact as raw artifact in the described format
-
getArtifactDescriptors
public final org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] getArtifactDescriptors(org.eclipse.equinox.p2.metadata.IArtifactKey key)
Description copied from interface:IRawArtifactProviderReturn the raw artifact formats in which the given artifact can be provided.- Specified by:
getArtifactDescriptorsin interfaceorg.eclipse.equinox.p2.repository.artifact.IArtifactRepository- Specified by:
getArtifactDescriptorsin interfaceIRawArtifactProvider- Specified by:
getArtifactDescriptorsin classorg.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository- Parameters:
key- An artifact key- Returns:
- The descriptors associated with 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:
queryin interfaceorg.eclipse.equinox.p2.query.IQueryable<ArtifactDescriptorT extends org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor>
-
descriptorQueryable
public final org.eclipse.equinox.p2.query.IQueryable<org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor> descriptorQueryable()
- Specified by:
descriptorQueryablein interfaceorg.eclipse.equinox.p2.repository.artifact.IArtifactRepository
-
getInternalDescriptorForAdding
protected abstract ArtifactDescriptorT getInternalDescriptorForAdding(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor) throws java.lang.IllegalArgumentException
Returns an artifact descriptor of the internal descriptor typeArtifactDescriptorTwhich may be added to the index. Implementations may require that the descriptor argument is a descriptor instance created by this repository – seeAbstractArtifactRepository.createArtifactDescriptor(IArtifactKey).This method is called by methods that add entries to the index, i.e. from
newAddingArtifactSink(IArtifactKey).- Parameters:
descriptor- AnIArtifactDescriptorinstance- Throws:
java.lang.IllegalArgumentException- if the provided descriptor cannot be added
-
internalAddDescriptor
protected final void internalAddDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
- Specified by:
internalAddDescriptorin classAbstractArtifactRepository2
-
internalAddInternalDescriptor
protected final void internalAddInternalDescriptor(ArtifactDescriptorT internalDescriptor)
-
initDescriptorsMapEntry
private java.util.Set<ArtifactDescriptorT> initDescriptorsMapEntry(org.eclipse.equinox.p2.metadata.IArtifactKey key)
-
internalRemoveDescriptor
protected final void internalRemoveDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
- Specified by:
internalRemoveDescriptorin classAbstractArtifactRepository2
-
internalRemoveDescriptors
protected final void internalRemoveDescriptors(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] descriptors)
- Specified by:
internalRemoveDescriptorsin classAbstractArtifactRepository2
-
internalRemoveDescriptors
protected final void internalRemoveDescriptors(org.eclipse.equinox.p2.metadata.IArtifactKey key)
- Specified by:
internalRemoveDescriptorsin classAbstractArtifactRepository2
-
internalRemoveDescriptors
protected final void internalRemoveDescriptors(org.eclipse.equinox.p2.metadata.IArtifactKey[] keys)
- Specified by:
internalRemoveDescriptorsin classAbstractArtifactRepository2
-
internalRemoveAllDescriptors
protected final void internalRemoveAllDescriptors()
- Specified by:
internalRemoveAllDescriptorsin classAbstractArtifactRepository2
-
internalStore
protected void internalStore(org.eclipse.core.runtime.IProgressMonitor monitor)
Persists the index of this repository.This method is called after every (bulk) change to the index.
- Specified by:
internalStorein classAbstractArtifactRepository2
-
internalGetArtifactStorageLocation
protected abstract java.io.File internalGetArtifactStorageLocation(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
Returns the file system location where the given artifact is or would be stored. UnlikegetArtifactFile(IArtifactDescriptor), this method does not check if the given artifact exists in the repository and never returnsnull.This method may be called by any API method for reading or writing artifacts.
-
getArtifactFile
public final java.io.File getArtifactFile(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
Description copied from interface:IRawArtifactFileProviderReturns the file system location of the given artifact in the given format.- Specified by:
getArtifactFilein interfaceorg.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository- Specified by:
getArtifactFilein interfaceIRawArtifactFileProvider- Parameters:
descriptor- The key and format of an artifact- Returns:
- The location of the specified raw artifact, or
nullthe that artifact does not exist in the given format.
-
getArtifactFile
public final java.io.File getArtifactFile(org.eclipse.equinox.p2.metadata.IArtifactKey key)
Description copied from interface:IArtifactFileProviderReturns the file system location of the given artifact.- Specified by:
getArtifactFilein interfaceIArtifactFileProvider- Specified by:
getArtifactFilein interfaceorg.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository- Parameters:
key- An artifact key- Returns:
- The location of the specified artifact, or
nullthe given artifact does not exist.
-
getArtifact
@Deprecated public final org.eclipse.core.runtime.IStatus getArtifact(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor, java.io.OutputStream destination, org.eclipse.core.runtime.IProgressMonitor monitor)Deprecated.Obsolete. UsegetArtifact(IArtifactSink, IProgressMonitor)instead.- Specified by:
getArtifactin interfaceorg.eclipse.equinox.p2.repository.artifact.IArtifactRepository- Overrides:
getArtifactin classAbstractArtifactRepository2
-
getArtifact
public final org.eclipse.core.runtime.IStatus getArtifact(IArtifactSink sink, org.eclipse.core.runtime.IProgressMonitor monitor) throws ArtifactSinkException
Description copied from interface:IArtifactProviderWrites 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:
getArtifactin 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- See Also:
IArtifactSink.getArtifactToBeWritten()
-
getProcessedRawArtifact
private org.eclipse.core.runtime.IStatus getProcessedRawArtifact(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor, java.io.OutputStream destination, org.eclipse.core.runtime.IProgressMonitor monitor)
-
closeProcessingSteps
private void closeProcessingSteps(java.io.OutputStream destinationWithProcessing) throws java.io.IOException- Throws:
java.io.IOException
-
getRawArtifact
public final org.eclipse.core.runtime.IStatus getRawArtifact(IRawArtifactSink sink, org.eclipse.core.runtime.IProgressMonitor monitor) throws ArtifactSinkException
Description copied from interface:IRawArtifactProviderWrites 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:
getRawArtifactin 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- See Also:
IArtifactSink.getArtifactToBeWritten(),IRawArtifactSink.getArtifactFormatToBeWritten()
-
readRawArtifact
private org.eclipse.core.runtime.IStatus readRawArtifact(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor, java.io.OutputStream destination)
-
closeSinkAccordingToStatus
private static void closeSinkAccordingToStatus(IArtifactSink sink, org.eclipse.core.runtime.IStatus status) throws ArtifactSinkException
- Throws:
ArtifactSinkException
-
newAddingArtifactSink
public final IArtifactSink newAddingArtifactSink(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws org.eclipse.equinox.p2.core.ProvisionException
Description copied from class:AbstractArtifactRepository2Returns a newIArtifactSinkinstance that adds the received artifact to this repository onIArtifactSink.commitWrite().- Specified by:
newAddingArtifactSinkin classAbstractArtifactRepository2- Parameters:
key- The artifact key to be added to this repository- Throws:
org.eclipse.equinox.p2.core.ProvisionException- if the artifact is already stored in the repository (in canonical format)
-
internalNewAddingArtifactSink
protected final ArtifactRepositoryBaseImpl.AddingArtifactSink internalNewAddingArtifactSink(ArtifactDescriptorT canonicalDescriptorToBeAdded) throws org.eclipse.equinox.p2.core.ProvisionException
- Throws:
org.eclipse.equinox.p2.core.ProvisionException
-
newAddingRawArtifactSink
public final IRawArtifactSink newAddingRawArtifactSink(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor newDescriptor) throws org.eclipse.equinox.p2.core.ProvisionException
Description copied from class:AbstractArtifactRepository2Returns a newIRawArtifactSinkinstance that adds the received artifact to this repository onIArtifactSink.commitWrite().- Specified by:
newAddingRawArtifactSinkin classAbstractArtifactRepository2- Parameters:
newDescriptor- The artifact descriptor to the added to this repository- Throws:
org.eclipse.equinox.p2.core.ProvisionException- if the artifact is already stored in the repository in the given format.
-
errorStatus
static org.eclipse.core.runtime.IStatus errorStatus(java.lang.String message, java.lang.Throwable cause)
-
errorStatus
static org.eclipse.core.runtime.IStatus errorStatus(java.lang.String message, java.lang.Throwable cause, int code)
-
-