Class CompositeURLContentRetriever
- java.lang.Object
-
- jetbrains.buildServer.artifacts.impl.CompositeURLContentRetriever
-
- All Implemented Interfaces:
URLContentRetriever
public class CompositeURLContentRetriever extends Object implements URLContentRetriever
Composite URL retriever delegating execution to all instances one-by-one until any returns value. All exceptions are cached and processed after all instances finish their jobs - if execution was successful (at least one returned correct value) - exceptions are logged but not thrown. If all instances failed - last exception is thrown (all are logged). In normal situation last instance should be default one (HttpTransport).
-
-
Constructor Summary
Constructors Constructor Description CompositeURLContentRetriever(List<URLContentRetriever> urlContentRetrievers, DownloadedArtifacts downloadedArtifacts)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
downloadCacheTo(String url, File target)
String
downloadUrlTo(String url, File target)
Download artifact to given location.String
getDigest(String url)
Retrieve content's digest.Collection<URLContentRetriever>
getUrlContentRetrievers()
void
interrupt()
Interrupt operation.String
toString()
-
-
-
Constructor Detail
-
CompositeURLContentRetriever
public CompositeURLContentRetriever(@NotNull List<URLContentRetriever> urlContentRetrievers, @NotNull DownloadedArtifacts downloadedArtifacts)
-
-
Method Detail
-
downloadCacheTo
@Nullable public String downloadCacheTo(@NotNull String url, @NotNull File target) throws IOException
- Specified by:
downloadCacheTo
in interfaceURLContentRetriever
- Throws:
IOException
-
downloadUrlTo
@Nullable public String downloadUrlTo(@NotNull String url, @NotNull File target) throws IOException
Description copied from interface:URLContentRetriever
Download artifact to given location. Implementation is expected to write file only if the content was fetched successfully- Specified by:
downloadUrlTo
in interfaceURLContentRetriever
- Parameters:
url
- source url to get artifact fromtarget
- target file location- Returns:
- digest of downloaded context, or null if the content can not be retrieved by this transport
- Throws:
IOException
- if operation failed, can also throwRecoverableIOException
if operation can be repeated
-
getDigest
@Nullable public String getDigest(@NotNull String url) throws IOException
Description copied from interface:URLContentRetriever
Retrieve content's digest. The digest will be compared with locally stored value to see if content has changed and must be downloaded again.
Implementation is expected not to download whole content to get the digest.- Specified by:
getDigest
in interfaceURLContentRetriever
- Parameters:
url
- source url of the artifact to retrieve digest for- Returns:
- the digest or null, if the digest can not be retrieved by this transport
- Throws:
IOException
- if operation failed
-
interrupt
public void interrupt()
Description copied from interface:URLContentRetriever
Interrupt operation. Interrupts current transfer operation as early as possible. Will be called from external thread, so implementation should be thread-safe. Main thread is expected to throwResolvingInterruptedException
when interrupt is received- Specified by:
interrupt
in interfaceURLContentRetriever
-
getUrlContentRetrievers
@NotNull public Collection<URLContentRetriever> getUrlContentRetrievers()
-
-