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.axis.v201405.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 |
|---|---|
void |
downloadReport(com.google.api.ads.dfp.axis.v201405.ExportFormat exportFormat,
OutputStream outputStream)
Downloads a Gzip or plain-text format report XML to output stream indicated
by
outputStream. |
void |
downloadReport(com.google.api.ads.dfp.axis.v201405.ExportFormat exportFormat,
String fileName)
Downloads a Gzip report to file located at
fileName. |
String |
getReport(com.google.api.ads.dfp.axis.v201405.ExportFormat exportFormat)
Gets the plain-text format report as a
String. |
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.axis.v201405.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 RemoteException,
InterruptedException
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 otherwiseRemoteException - if there was an error performing one of the SOAP
callsInterruptedException - if the thread was interruptedpublic void downloadReport(com.google.api.ads.dfp.axis.v201405.ExportFormat exportFormat,
String fileName)
throws IOException
fileName.exportFormat - the export format of the reportfileName - the file location to download the report toIOException - if there was an error performing any I/O action,
including any SOAP callsIllegalStateException - if the report is not ready to be downloadedpublic void downloadReport(com.google.api.ads.dfp.axis.v201405.ExportFormat exportFormat,
OutputStream outputStream)
throws IOException
outputStream.exportFormat - the export format of the reportoutputStream - the output stream to download the report toIOException - if there was an error performing any I/O action,
including any SOAP callsIllegalStateException - if the report is not ready to be downloadedpublic String getReport(com.google.api.ads.dfp.axis.v201405.ExportFormat exportFormat) throws IOException
String.exportFormat - the export format of the reportStringIOException - if there was an error performing any I/O action,
including any SOAP callsIllegalStateException - if the report is not ready to be downloadedCopyright © 2015. All Rights Reserved.