Class ArtifactHandlerDecoratorSupport
- java.lang.Object
-
- com.atlassian.bamboo.build.artifact.ArtifactHandlerDecoratorSupport
-
- All Implemented Interfaces:
ArtifactHandler
,BambooPluginModule
- Direct Known Subclasses:
ArtifactHandlerPackagingDecorator
public abstract class ArtifactHandlerDecoratorSupport extends Object implements ArtifactHandler
Allows to decorate anArtifactHandler
by overwriting some of it's methods. By default all methods are forwarded to the underlyingArtifactHandler
returned bydelegate()
.
-
-
Field Summary
-
Fields inherited from interface com.atlassian.bamboo.build.artifact.ArtifactHandler
LAN_SPEED, LOCAL_SPEED, NEVER_ARCHIVE, WAN_SPEED
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ArtifactHandlerDecoratorSupport()
Constructor for use by subclasses.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
canHandleArtifact(ArtifactDefinitionContext artifact, Map<String,String> artifactHandlersConfiguration)
protected abstract @NotNull ArtifactHandler
delegate()
Returns the delegate instance that methods are forwarded to.@Nullable ArtifactLinkDataProvider
getArtifactLinkDataProvider(Artifact artifact, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
@Nullable ArtifactLinkDataProvider
getArtifactLinkDataProvider(ArtifactLink artifactLink, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
@NotNull Map<String,String>
getDefaultConfiguration()
long
getMaxUnarchivedFilesPerArtifact(@NotNull Map<String,String> artifactHandlersConfiguration)
Returns the maximum number of files that can exist per artifact which will not be compressed and combined into a single archive.@NotNull ArtifactHandlerModuleDescriptor
getModuleDescriptor()
int
getSpeed(@NotNull Map<String,String> artifactHandlersConfiguration)
Return approximate transfer speed of this artifact handler in bytes per second for the specified configuration.@NotNull Set<AgentType>
getSupportedAgents()
boolean
moveArtifactToGlobalStorage(@NotNull Artifact artifact, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Move artifact to a 'global storage'.@NotNull ArtifactHandlerPublishingResult
publish(@NotNull ResultKey resultKey, @NotNull ArtifactDefinitionContext artifact, @NotNull ArtifactPublishingConfig artifactPublishingConfig, @Nullable BuildLogger buildLogger)
void
removeAllArtifactsOfChain(@NotNull PlanKey planKey, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for all results of a single chain.void
removeArtifactFromStorage(@NotNull Artifact artifact, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for a single artifact.void
removeArtifactFromStorage(@NotNull PlanResultKey planResultKey, @NotNull ImmutableArtifactDefinitionBase artifact, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for a single artifact.void
removeArtifactFromStorage(@NotNull ResultKey resultKey, @NotNull ImmutableArtifactDefinitionBase artifact, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for a single artifact.void
removeArtifactsFromStorage(@NotNull PlanKey planKey, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for all results of a single chain or job.void
removeArtifactsFromStorage(@NotNull PlanResultKey planResultKey, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for a single plan result.@NotNull ArtifactRetrievalStatus
retrieve(@NotNull ResultKey clientKey, @NotNull Artifact artifact, @NotNull ArtifactSubscriptionContext artifactSubscription, @NotNull ArtifactRetrievalConfig artifactRetrievalConfig)
Retrieve arbitraryArtifact
.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.atlassian.bamboo.build.artifact.ArtifactHandler
publish
-
-
-
-
Method Detail
-
delegate
@NotNull protected abstract @NotNull ArtifactHandler delegate()
Returns the delegate instance that methods are forwarded to. Subclasses should override this method to supply the instance being decorated.
-
publish
@NotNull public @NotNull ArtifactHandlerPublishingResult publish(@NotNull @NotNull ResultKey resultKey, @NotNull @NotNull ArtifactDefinitionContext artifact, @NotNull @NotNull ArtifactPublishingConfig artifactPublishingConfig, @Nullable @Nullable BuildLogger buildLogger) throws Exception
- Specified by:
publish
in interfaceArtifactHandler
- Throws:
Exception
-
retrieve
@NotNull public @NotNull ArtifactRetrievalStatus retrieve(@NotNull @NotNull ResultKey clientKey, @NotNull @NotNull Artifact artifact, @NotNull @NotNull ArtifactSubscriptionContext artifactSubscription, @NotNull @NotNull ArtifactRetrievalConfig artifactRetrievalConfig) throws Exception
Description copied from interface:ArtifactHandler
Retrieve arbitraryArtifact
. Artifact is found by the information in artifact parameter.- Specified by:
retrieve
in interfaceArtifactHandler
- Parameters:
clientKey
- identifier of plan or deployment doing the downloadartifact
- artifact informationartifactSubscription
- download details (e.g. target path, copy pattern)artifactRetrievalConfig
- handler specific configuration- Throws:
Exception
-
getSupportedAgents
@NotNull public @NotNull Set<AgentType> getSupportedAgents()
- Specified by:
getSupportedAgents
in interfaceArtifactHandler
-
getModuleDescriptor
@NotNull public @NotNull ArtifactHandlerModuleDescriptor getModuleDescriptor()
- Specified by:
getModuleDescriptor
in interfaceArtifactHandler
-
canHandleArtifact
public boolean canHandleArtifact(ArtifactDefinitionContext artifact, Map<String,String> artifactHandlersConfiguration)
- Specified by:
canHandleArtifact
in interfaceArtifactHandler
-
getDefaultConfiguration
@NotNull public @NotNull Map<String,String> getDefaultConfiguration()
- Specified by:
getDefaultConfiguration
in interfaceArtifactHandler
-
getSpeed
public int getSpeed(@NotNull @NotNull Map<String,String> artifactHandlersConfiguration)
Description copied from interface:ArtifactHandler
Return approximate transfer speed of this artifact handler in bytes per second for the specified configuration. Result of this method might be taken into account when deciding which artifact handler to use if multiple handlers are enabled.- Specified by:
getSpeed
in interfaceArtifactHandler
- Parameters:
artifactHandlersConfiguration
- artifact handler configuration- Returns:
- approximate transfer speed in Bps, for example:
ArtifactHandler.LOCAL_SPEED
,ArtifactHandler.LAN_SPEED
,ArtifactHandler.WAN_SPEED
-
removeArtifactFromStorage
public void removeArtifactFromStorage(@NotNull @NotNull Artifact artifact, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
Removes artifact files for a single artifact.- Specified by:
removeArtifactFromStorage
in interfaceArtifactHandler
-
removeArtifactFromStorage
public void removeArtifactFromStorage(@NotNull @NotNull PlanResultKey planResultKey, @NotNull @NotNull ImmutableArtifactDefinitionBase artifact, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
Removes artifact files for a single artifact. Called when removingArtifactLink
Should not remove artifacts that were moved to global storage.- Specified by:
removeArtifactFromStorage
in interfaceArtifactHandler
-
removeArtifactFromStorage
public void removeArtifactFromStorage(@NotNull @NotNull ResultKey resultKey, @NotNull @NotNull ImmutableArtifactDefinitionBase artifact, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
Removes artifact files for a single artifact. Called when removingArtifactLink
Should not remove artifacts that were moved to global storage.- Specified by:
removeArtifactFromStorage
in interfaceArtifactHandler
-
removeArtifactsFromStorage
public void removeArtifactsFromStorage(@NotNull @NotNull PlanResultKey planResultKey, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
Removes artifact files for a single plan result. Called when removingResultsSummary
Should not remove artifacts that were moved to global storage.- Specified by:
removeArtifactsFromStorage
in interfaceArtifactHandler
-
removeArtifactsFromStorage
public void removeArtifactsFromStorage(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
Removes artifact files for all results of a single chain or job. Called when removingPlan
Calling it for chain removes only the shared artifacts. Should not remove artifacts that were moved to global storage.- Specified by:
removeArtifactsFromStorage
in interfaceArtifactHandler
-
removeAllArtifactsOfChain
public void removeAllArtifactsOfChain(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
Removes artifact files for all results of a single chain. Called when removingChain
Should not remove artifacts that were moved to global storage.- Specified by:
removeAllArtifactsOfChain
in interfaceArtifactHandler
-
moveArtifactToGlobalStorage
public boolean moveArtifactToGlobalStorage(@NotNull @NotNull Artifact artifact, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider) throws IOException
Description copied from interface:ArtifactHandler
Move artifact to a 'global storage'. Artifacts in 'global storage' should only be removed whenArtifactHandler.removeArtifactFromStorage(Artifact, ArtifactHandlerConfigProvider)
is called. It is not a requirement to physically move the files as long as the above contract is fulfilled.- Specified by:
moveArtifactToGlobalStorage
in interfaceArtifactHandler
- Returns:
- true if move successful
- Throws:
IOException
-
getArtifactLinkDataProvider
@Nullable public @Nullable ArtifactLinkDataProvider getArtifactLinkDataProvider(ArtifactLink artifactLink, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
- Specified by:
getArtifactLinkDataProvider
in interfaceArtifactHandler
-
getArtifactLinkDataProvider
@Nullable public @Nullable ArtifactLinkDataProvider getArtifactLinkDataProvider(Artifact artifact, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
- Specified by:
getArtifactLinkDataProvider
in interfaceArtifactHandler
-
getMaxUnarchivedFilesPerArtifact
public long getMaxUnarchivedFilesPerArtifact(@NotNull @NotNull Map<String,String> artifactHandlersConfiguration)
Description copied from interface:ArtifactHandler
Returns the maximum number of files that can exist per artifact which will not be compressed and combined into a single archive. If the threshold is exceeded, artifacts will be packaged into a single file before publishing.
ArtifactHandler
does not need to treat archived artifacts differently - from ArtifactHandler perspective the packaging is transparent. Artifact files will be compressed before invoking #publish method and decompressed after invoking #retrieve method.This method should return
ArtifactHandler.NEVER_ARCHIVE
if packaging of artifacts is disabled, to always send files unarchived.- Specified by:
getMaxUnarchivedFilesPerArtifact
in interfaceArtifactHandler
- Parameters:
artifactHandlersConfiguration
- artifact handler configuration- Returns:
- maximum number of files per artifact that should not be packaged into a single file
-
-