當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。