示例#1
0
  static void printCriterionIds(
      ArrayOfNullableOflong criterionIds, ArrayOfBatchError partialErrors) {
    if (criterionIds == null) {
      return;
    }

    int count = criterionIds.getLongs().size();

    for (int i = 0; i < count; i++) {
      if (criterionIds.getLongs().get(i) != null) {
        outputStatusMessage(
            String.format(
                "Successfully added criterion with ID, %d\n\n", criterionIds.getLongs().get(i)));
      } else {
        outputStatusMessage(String.format("Failed to add criterion at index, %d\n\n", i));

        BatchError error = partialErrors.getBatchErrors().get(i);

        outputStatusMessage(String.format("\tIndex: %d\n", error.getIndex()));
        outputStatusMessage(String.format("\tCode: %d\n", error.getCode()));
        outputStatusMessage(String.format("\tErrorCode: %s\n", error.getErrorCode()));
        outputStatusMessage(String.format("\tMessage: %s\n", error.getMessage()));
      }
    }
  }
示例#2
0
  static void printAdIdentifiers(ArrayOfNullableOflong adIds, ArrayOfBatchError partialErrors) {
    if (adIds == null) {
      return;
    }

    int count = adIds.getLongs().size();

    for (int i = 0; i < count; i++) {
      if (adIds.getLongs().get(i) != null) {
        // A shopping campaign should contain only product ads.

        outputStatusMessage(
            String.format(
                "Successfully added a product ad with ID, %d\n\n", adIds.getLongs().get(i)));
      } else {
        outputStatusMessage(String.format("Failed to add product ad at index, %d\n\n", i));

        BatchError error = partialErrors.getBatchErrors().get(i);

        outputStatusMessage(String.format("\tIndex: %d\n", error.getIndex()));
        outputStatusMessage(String.format("\tCode: %d\n", error.getCode()));
        outputStatusMessage(String.format("\tErrorCode: %s\n", error.getErrorCode()));
        outputStatusMessage(String.format("\tMessage: %s\n", error.getMessage()));

        // If the error is an editorial error, get more details.

        if (error.getType() == "EditorialError"
            && error.getErrorCode() == "CampaignServiceEditorialValidationError") {
          outputStatusMessage(
              String.format(
                  "\tDisapprovedText: %s\n", ((EditorialError) error).getDisapprovedText()));
          outputStatusMessage(
              String.format("\tLocation: %s\n", ((EditorialError) error).getLocation()));
          outputStatusMessage(
              String.format(
                  "\tPublisherCountry: %s\n", ((EditorialError) error).getPublisherCountry()));
          outputStatusMessage(
              String.format("\tReasonCode: %s\n", ((EditorialError) error).getReasonCode()));
        }
      }
    }
  }