本文整理汇总了Java中com.google.api.ads.adwords.lib.utils.ReportException类的典型用法代码示例。如果您正苦于以下问题:Java ReportException类的具体用法?Java ReportException怎么用?Java ReportException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReportException类属于com.google.api.ads.adwords.lib.utils包,在下文中一共展示了ReportException类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import com.google.api.ads.adwords.lib.utils.ReportException; //导入依赖的package包/类
/**
* Downloads report from API (with retry logic) and transforms the result into a
* {@link ReportData} object.
*/
@Override
public ReportData call() throws AlertProcessingException {
ReportDownloaderInterface reportDownloader =
AdWordsServicesUtil.getUtility(session, ReportDownloaderInterface.class);
ReportDownloadResponse reportDownloadResponse = null;
try {
reportDownloadResponse =
reportDownloader.downloadReport(reportQuery.generateAWQL(), DownloadFormat.GZIPPED_CSV);
} catch (ReportException | ReportDownloadResponseException e) {
String msg = "Failed to download report account " + session.getClientCustomerId() + ".";
LOGGER.error(msg, e);
throw new AlertProcessingException(msg, e);
}
InputStream inputStream = reportDownloadResponse.getInputStream();
return handleReportStreamResult(inputStream);
}
示例2: logRequest
import com.google.api.ads.adwords.lib.utils.ReportException; //导入依赖的package包/类
/**
* Logs the specified request and response information.
*
* <p>Note that in order to avoid any temptation to consume the contents of the response, this
* does <em>not</em> take an {@link com.google.api.client.http.HttpResponse} object, but instead
* accepts the status code and message from the response.
*/
public void logRequest(
@Nullable HttpRequest request, int statusCode, @Nullable String statusMessage) {
boolean isSuccess = HttpStatusCodes.isSuccess(statusCode);
if (!loggerDelegate.isSummaryLoggable(isSuccess)
&& !loggerDelegate.isDetailsLoggable(isSuccess)) {
return;
}
// Populate the RequestInfo builder from the request.
RequestInfo requestInfo = buildRequestInfo(request);
// Populate the ResponseInfo builder from the response.
ResponseInfo responseInfo = buildResponseInfo(request, statusCode, statusMessage);
RemoteCallReturn.Builder remoteCallReturnBuilder =
new RemoteCallReturn.Builder().withRequestInfo(requestInfo).withResponseInfo(responseInfo);
if (!isSuccess) {
remoteCallReturnBuilder.withException(
new ReportException(String.format("%s: %s", statusCode, statusMessage)));
}
RemoteCallReturn remoteCallReturn = remoteCallReturnBuilder.build();
loggerDelegate.logRequestSummary(remoteCallReturn);
loggerDelegate.logRequestDetails(remoteCallReturn);
}
示例3: getReportInputStream
import com.google.api.ads.adwords.lib.utils.ReportException; //导入依赖的package包/类
/**
* Downloads the file from the API into an InputStream.
*
* @return the InputStream from the online report, null if httpStatus is not {@code HTTP_OK}.
*/
private InputStream getReportInputStream() {
ReportDownloaderInterface reportDownloader =
AdWordsServicesUtil.getUtility(session, ReportDownloaderInterface.class);
InputStream result = null;
try {
ReportDownloadResponse reportDownloadResponse =
reportDownloader.downloadReport(reportDefinition);
result = reportDownloadResponse.getInputStream();
} catch (ReportException | ReportDownloadResponseException e) {
logger.error(
"Failed to download report stream for {} with account {}.",
reportDefinition.getReportType(),
session.getClientCustomerId(),
e);
}
return result;
}
示例4: getReportDownloadResponse
import com.google.api.ads.adwords.lib.utils.ReportException; //导入依赖的package包/类
/**
* Gets the report download response from the API and retries on failure.
*/
@VisibleForTesting
ReportDownloadResponse getReportDownloadResponse() throws ReportProcessingException {
ReportDownloaderInterface reportDownloader =
AdWordsServicesUtil.getUtility(session, ReportDownloaderInterface.class);
ReportDownloadResponse result = null;
try {
result = reportDownloader.downloadReport(reportDefinition);
} catch (ReportException | ReportDownloadResponseException e) {
String msg =
"Failed to download report file for "
+ reportDefinition.getReportType()
+ " with account "
+ session.getClientCustomerId()
+ ".";
logger.error(msg, e);
throw new ReportProcessingException(msg, e);
}
return result;
}
示例5: downloadReport
import com.google.api.ads.adwords.lib.utils.ReportException; //导入依赖的package包/类
@Override
public ReportDownloadResponse downloadReport(ReportDefinition reportDefinition)
throws ReportException, ReportDownloadResponseException {
return adHocReportDownloadHelper.downloadReport(
new XmlReportDefinitionRequest(reportDefinition),
new DetailedReportDownloadResponseException.Builder());
}
示例6: downloadReport
import com.google.api.ads.adwords.lib.utils.ReportException; //导入依赖的package包/类
/**
* Invokes {@link ReportDownloader#downloadReport(ReportDefinition)} or
* {@link ReportDownloader#downloadReport(String, DownloadFormat)}, depending on whether this
* instance is configured to use AWQL.
*
* @param downloadFormat the DownloadFormat for the request
* @param rawResponse the response to return from the mocked ad hoc helper
*/
private ReportDownloadResponse downloadReport(DownloadFormat downloadFormat,
RawReportDownloadResponse rawResponse, String expectedErrorText) throws ReportException,
ReportDownloadResponseException {
if (rawResponse.getHttpStatus() == 200) {
// Response indicates success, so return a ReportDownloadResponse.
when(
adHocDownloadHelper.downloadReport(
Matchers.any(ReportRequest.class), Matchers.any(Builder.class)))
.thenReturn(new ReportDownloadResponse(rawResponse));
} else {
// Response indicates failure, so throw an exception.
when(
adHocDownloadHelper.downloadReport(
Matchers.any(ReportRequest.class), Matchers.any(Builder.class)))
.thenThrow(new Builder().build(rawResponse.getHttpStatus(), expectedErrorText));
}
if (isUseAwql) {
return reportDownloader.downloadReport(AWQL_REQUEST, downloadFormat);
} else {
ReportDefinition reportDefinition = new ReportDefinition();
reportDefinition.setSelector(new Selector());
reportDefinition
.getSelector()
.getFields()
.addAll(Arrays.asList("CampaignId", "CampaignName", "Impressions"));
reportDefinition.setDateRangeType(ReportDefinitionDateRangeType.LAST_7_DAYS);
reportDefinition.setReportName("Custom report");
reportDefinition.setReportType(ReportDefinitionReportType.CAMPAIGN_PERFORMANCE_REPORT);
return reportDownloader.downloadReport(reportDefinition);
}
}
示例7: downloadReport
import com.google.api.ads.adwords.lib.utils.ReportException; //导入依赖的package包/类
/**
* Downloads a report and returns a ReportDownloadResponse with the results.
*
* @param reportDefinition to download a report for.
* @return {@link ReportDownloadResponse} If the HTTP request completes successfully.
* @throws ReportException If we don't receive a response from the server.
* @throws ReportDownloadResponseException If the server indicates a problem with the request.
*/
public ReportDownloadResponse downloadReport(ReportDefinition reportDefinition)
throws ReportException, ReportDownloadResponseException;