public class ReportDownloader extends Object
ReportServiceInterface.
There are two main functions of this class:
OutputStream
ReportUtils also provides the method
whenReportReady(ReportCallback) to wait for a scheduled report to
finish processing before taking an action on the report through the supplied
ReportCallback.
| Modifier and Type | Field and Description |
|---|---|
static Charset |
REPORT_CHARSET |
static int |
SLEEP_TIMER
The time to sleep before each request to the service.
|
| Constructor and Description |
|---|
ReportDownloader(com.google.api.ads.dfp.jaxws.v201705.ReportServiceInterface reportService,
long reportJobId)
Constructs a
ReportDownloader object for a
ReportServiceInterface and a report job id that the the class works
on. |
| Modifier and Type | Method and Description |
|---|---|
URL |
getDownloadUrl(com.google.api.ads.dfp.jaxws.v201705.ReportDownloadOptions options)
Gets the download URL for a GZip or plain-text format report.
|
com.google.common.io.CharSource |
getReportAsCharSource(com.google.api.ads.dfp.jaxws.v201705.ReportDownloadOptions options)
Returns a CharSource of report contents with
ReportDownloadOptions. |
boolean |
waitForReportReady()
Blocks and waits for a report to be ready.
|
Thread |
whenReportReady(ReportCallback callback)
Waits for the report to be ready and then calls:
ReportCallback.onSuccess() for a successful scheduling
ReportCallback.onFailure() for a failed scheduling due to a
ReportJobStatus.FAILED
ReportCallback.onInterruption() if the wait thread is
interrupted
ReportCallback.onException(Exception) if there was an exception
while waiting for the report to finish
|
public static final Charset REPORT_CHARSET
public static final int SLEEP_TIMER
public ReportDownloader(com.google.api.ads.dfp.jaxws.v201705.ReportServiceInterface reportService,
long reportJobId)
ReportDownloader object for a
ReportServiceInterface and a report job id that the the class works
on.reportService - the ReportService stub to make calls toreportJobId - the report job IDpublic Thread whenReportReady(ReportCallback callback)
ReportCallback.onSuccess() for a successful schedulingReportCallback.onFailure() for a failed scheduling due to a
ReportJobStatus.FAILEDReportCallback.onInterruption() if the wait thread is
interruptedReportCallback.onException(Exception) if there was an exception
while waiting for the report to finishcallback - the ReportCallback to call when the job has
finished, successfully or otherwiseThread.interrupt() can be called on the returned thread to
interrupt it.IllegalArgumentException - if callback == nullpublic boolean waitForReportReady()
throws InterruptedException,
com.google.api.ads.dfp.jaxws.v201705.ApiException_Exception
ReportJobStatus
is received that is not ReportJobStatus#Pending or ReportJobStatus#InProgress, the report is considered finished, and the
method is returned with a true if the report was successful, or an
false if not.true if the report was successful, false otherwisecom.google.api.ads.dfp.jaxws.v201705.ApiException_Exception - if there was an error performing one of the SOAP
callsInterruptedException - if the thread was interruptedpublic URL getDownloadUrl(com.google.api.ads.dfp.jaxws.v201705.ReportDownloadOptions options) throws com.google.api.ads.dfp.jaxws.v201705.ApiException_Exception, MalformedURLException
URL url = new URL(reportDownloader.getDownloadUrl(options));
Resources.asByteSource(url).copyTo(Files.asByteSink(file));
options - the options to download the report withcom.google.api.ads.dfp.jaxws.v201705.ApiException_Exception - if there was an error performing any jaxws callMalformedURLException - if there is an error forming the download URLIllegalStateException - if the report is not ready to be downloadedpublic com.google.common.io.CharSource getReportAsCharSource(com.google.api.ads.dfp.jaxws.v201705.ReportDownloadOptions options)
throws IOException,
com.google.api.ads.dfp.jaxws.v201705.ApiException_Exception
ReportDownloadOptions. The ExportFormat
must be string-based, such as
ExportFormat.CSV_DUMP.options - the options to download the report withIOException - if there was an error performing any I/O action, including any SOAP callscom.google.api.ads.dfp.jaxws.v201705.ApiException_Exception - if there was any problem making the SOAP
callIllegalStateException - if the report is not ready to be downloadedIllegalArgumentException - if the ExportFormat is not a string-based formatCopyright © 2018. All Rights Reserved.