当前位置: 首页>>代码示例>>Java>>正文


Java ReportException类代码示例

本文整理汇总了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);
}
 
开发者ID:googleads,项目名称:adwords-alerting,代码行数:23,代码来源:CallableAwqlReportDownloader.java

示例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);
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:32,代码来源:ReportServiceLogger.java

示例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;
}
 
开发者ID:googleads,项目名称:aw-reporting,代码行数:25,代码来源:StreamingRunnableProcessor.java

示例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;
}
 
开发者ID:googleads,项目名称:aw-reporting,代码行数:25,代码来源:CallableReportDownloader.java

示例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());
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:8,代码来源:ReportDownloader.java

示例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);
  }
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:41,代码来源:ReportDownloaderTest.java

示例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;
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:11,代码来源:ReportDownloaderInterface.java


注:本文中的com.google.api.ads.adwords.lib.utils.ReportException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。