Runs the example.

@param adManagerServices the services factory.
@param session the session.
@throws ApiException if the API request failed with one or more service errors.
@throws RemoteException if the API request failed due to other errors.
778493
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    CreativeWrapperServiceInterface creativeWrapperService =
        adManagerServices.get(session, CreativeWrapperServiceInterface.class);

    // Create a statement to select creative wrappers.
    StatementBuilder statementBuilder =
        new StatementBuilder()
            .where("status = :status")
            .orderBy("id ASC")
            .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
            .withBindVariableValue("status", CreativeWrapperStatus.ACTIVE.toString());

    // Retrieve a small amount of creative wrappers at a time, paging through
    // until all creative wrappers have been retrieved.
    int totalResultSetSize = 0;
    do {
      CreativeWrapperPage page =
          creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        // Print out some information for each creative wrapper.
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (CreativeWrapper creativeWrapper : page.getResults()) {
          System.out.printf(
              "%d) Creative wrapper with ID %d and label ID %d was found.%n",
              i++, creativeWrapper.getId(), creativeWrapper.getLabelId());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }
649518
@SuppressWarnings("unchecked") /* See constructor comments. */
  public void setAuthorization(Object soapClient, AdsSession adsSession)
      throws AuthenticationException {
    final String authorizationHeader =
        authorizationHeaderProvider.getAuthorizationHeader(adsSession,
            soapClientHandler.getEndpointAddress(soapClient));
    soapClientHandler.putAllHttpHeaders(soapClient, new HashMap<String, String>() {
      {
        put("Authorization", authorizationHeader);
      }
    });
  }
356993
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the LabelService.
    LabelServiceInterface labelService =
        adManagerServices.get(session, LabelServiceInterface.class);

    // Create a competitive exclusion label.
    Label competitiveExclusionLabel = new Label();
    competitiveExclusionLabel.setName(
        "Car company label #" + new Random().nextInt(Integer.MAX_VALUE));
    competitiveExclusionLabel.setTypes(new LabelType[] {LabelType.COMPETITIVE_EXCLUSION});

    // Create an ad unit frequency cap label.
    Label adUnitFrequencyCapLabel = new Label();
    adUnitFrequencyCapLabel.setName(
        "Don't run too often label #" + new Random().nextInt(Integer.MAX_VALUE));
    adUnitFrequencyCapLabel.setTypes(new LabelType[] {LabelType.AD_UNIT_FREQUENCY_CAP});

    // Create the labels on the server.
    Label[] labels =
        labelService.createLabels(new Label[] {competitiveExclusionLabel, adUnitFrequencyCapLabel});

    for (Label createdLabel : labels) {
      System.out.printf("A label with ID %d and name '%s' was created.%n",
          createdLabel.getId(), createdLabel.getName());
    }
  }
1038961
public static void runExample(
      AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException {
    // Get the CampaignService.
    CampaignCriterionServiceInterface campaignCriterionService =
        adWordsServices.get(session, CampaignCriterionServiceInterface.class);

    int offset = 0;

    // Create selector.
    SelectorBuilder builder = new SelectorBuilder();
    Selector selector = builder
        .fields(
            CampaignCriterionField.CampaignId,
            CampaignCriterionField.Id,
            CampaignCriterionField.CriteriaType,
            CampaignCriterionField.PlatformName,
            CampaignCriterionField.LanguageName,
            CampaignCriterionField.LocationName,
            CampaignCriterionField.KeywordText)
        .in(CampaignCriterionField.CriteriaType, "KEYWORD", "LANGUAGE", "LOCATION", "PLATFORM")
        .offset(0)
        .limit(PAGE_SIZE)
        .build();

    CampaignCriterionPage page = null;
    do {
      page = campaignCriterionService.get(selector);

      if (page.getEntries() != null) {
        // Display campaigns.
        for (CampaignCriterion campaignCriterion : page.getEntries()) {
          System.out.printf("Campaign criterion with campaign ID %d, criterion ID %d, "
              + "and type '%s' was found.%n", campaignCriterion.getCampaignId(), campaignCriterion
              .getCriterion().getId(), campaignCriterion.getCriterion().getCriterionType());
        }
      } else {
        System.out.println("No campaign criteria were found.");
      }
      offset += PAGE_SIZE;
      selector = builder.increaseOffsetBy(PAGE_SIZE).build();
    } while (offset < page.getTotalNumEntries());
  }
134125
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    ActivityServiceInterface activityService =
        adManagerServices.get(session, ActivityServiceInterface.class);

    // Create a statement to select activities.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("status = :status")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("status", ActivityStatus.ACTIVE.toString());

    // Retrieve a small amount of activities at a time, paging through
    // until all activities have been retrieved.
    int totalResultSetSize = 0;
    do {
      ActivityPage page =
          activityService.getActivitiesByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        // Print out some information for each activity.
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (Activity activity : page.getResults()) {
          System.out.printf(
              "%d) Activity with ID %d, name '%s', and type '%s' was found.%n",
              i++,
              activity.getId(),
              activity.getName(),
              activity.getType()
          );
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }
482759
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the CdnConfigurationService.
    CdnConfigurationServiceInterface cdnConfigurationService =
        adManagerServices.get(session, CdnConfigurationServiceInterface.class);

    // Make CDN configuration objects.
    // Only LIVE_STREAM_SOURCE_CONTENT is currently supported by the API.
    // Basic example with no security policies.
    CdnConfiguration cdnConfigurationWithoutSecurityPolicy = new CdnConfiguration();

    SecurityPolicySettings noSecurityPolicy = new SecurityPolicySettings();
    noSecurityPolicy.setSecurityPolicyType(SecurityPolicyType.NONE);
    MediaLocationSettings mediaLocationSettings = new MediaLocationSettings();
    mediaLocationSettings.setUrlPrefix("example.google.com");
    mediaLocationSettings.setSecurityPolicy(noSecurityPolicy);

    SourceContentConfiguration sourceContentConfigWithNoSecurityPolicy =
        new SourceContentConfiguration();
    sourceContentConfigWithNoSecurityPolicy.setIngestSettings(mediaLocationSettings);
    sourceContentConfigWithNoSecurityPolicy.setDefaultDeliverySettings(mediaLocationSettings);

    cdnConfigurationWithoutSecurityPolicy.setName("ApiConfig1");
    cdnConfigurationWithoutSecurityPolicy.setCdnConfigurationType(
        CdnConfigurationType.LIVE_STREAM_SOURCE_CONTENT);
    cdnConfigurationWithoutSecurityPolicy.setSourceContentConfiguration(
        sourceContentConfigWithNoSecurityPolicy);

    // Complex example with security policies.
    CdnConfiguration cdnConfigurationWithSecurityPolicy = new CdnConfiguration();

    SecurityPolicySettings ingestSecurityPolicySettings = new SecurityPolicySettings();
    ingestSecurityPolicySettings.setSecurityPolicyType(SecurityPolicyType.AKAMAI);
    ingestSecurityPolicySettings.setDisableServerSideUrlSigning(false);
    ingestSecurityPolicySettings.setTokenAuthenticationKey("abc123");

    MediaLocationSettings ingestSettings = new MediaLocationSettings();
    ingestSettings.setUrlPrefix("example.google.com");
    ingestSettings.setSecurityPolicy(ingestSecurityPolicySettings);

    SecurityPolicySettings deliverySecurityPolicySettings = new SecurityPolicySettings();
    deliverySecurityPolicySettings.setSecurityPolicyType(SecurityPolicyType.AKAMAI);
    deliverySecurityPolicySettings.setDisableServerSideUrlSigning(false);
    deliverySecurityPolicySettings.setOriginForwardingType(OriginForwardingType.CONVENTIONAL);
    deliverySecurityPolicySettings.setOriginPathPrefix("/path/to/my/origin");

    MediaLocationSettings deliverySettings = new MediaLocationSettings();
    deliverySettings.setUrlPrefix("example.google.com");
    deliverySettings.setSecurityPolicy(deliverySecurityPolicySettings);

    SourceContentConfiguration sourceContentConfigurationWithSecurityPolicy =
        new SourceContentConfiguration();
    sourceContentConfigurationWithSecurityPolicy.setIngestSettings(ingestSettings);
    sourceContentConfigurationWithSecurityPolicy.setDefaultDeliverySettings(deliverySettings);

    cdnConfigurationWithSecurityPolicy.setName("ApiConfig2");
    cdnConfigurationWithSecurityPolicy.setCdnConfigurationType(
        CdnConfigurationType.LIVE_STREAM_SOURCE_CONTENT);
    cdnConfigurationWithSecurityPolicy.setSourceContentConfiguration(
        sourceContentConfigurationWithSecurityPolicy);

    // Create the cdnConfigurations on the server.
    CdnConfiguration[] cdnConfigurations =
        cdnConfigurationService.createCdnConfigurations(
            new CdnConfiguration[] {
              cdnConfigurationWithoutSecurityPolicy, cdnConfigurationWithSecurityPolicy
            });

    for (CdnConfiguration createdCdnConfiguration : cdnConfigurations) {
      System.out.printf(
          "A CDN configuration with ID %d and name '%s' was created.%n",
          createdCdnConfiguration.getId(), createdCdnConfiguration.getName());
    }
  }
844622
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    NativeStyleServiceInterface nativeStyleService =
        adManagerServices.get(session, NativeStyleServiceInterface.class);

    // Create a statement to select native styles.
    StatementBuilder statementBuilder =
        new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

    // Retrieve a small amount of native styles at a time, paging through
    // until all native styles have been retrieved.
    int totalResultSetSize = 0;
    do {
      NativeStylePage page =
          nativeStyleService.getNativeStylesByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        // Print out some information for each native style.
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (NativeStyle nativeStyle : page.getResults()) {
          System.out.printf(
              "%d) Native style with ID %d and name '%s' was found.%n",
              i++, nativeStyle.getId(), nativeStyle.getName());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }
592624
@Override
    public void addMBeanServers(Set<MBeanServerConnection> servers) {
        try {
            /*
			 * this.mbeanServer = AdminServiceFactory.getMBeanFactory().getMBeanServer();
			 */
            Class adminServiceClass = ClassUtil.classForName("com.ibm.websphere.management.AdminServiceFactory",getClass().getClassLoader());
            if (adminServiceClass != null) {
                Method getMBeanFactoryMethod = adminServiceClass.getMethod("getMBeanFactory", new Class[0]);
                Object mbeanFactory = getMBeanFactoryMethod.invoke(null);
                if (mbeanFactory != null) {
                    Method getMBeanServerMethod = mbeanFactory.getClass().getMethod("getMBeanServer", new Class[0]);
                    servers.add((MBeanServer) getMBeanServerMethod.invoke(mbeanFactory));
                }
            }
        }
        catch (InvocationTargetException ex) {
            // CNFE should be earlier
            throw new IllegalArgumentException(INTERNAL_ERROR_MSG,ex);
        } catch (IllegalAccessException ex) {
            throw new IllegalArgumentException(INTERNAL_ERROR_MSG,ex);
        } catch (NoSuchMethodException ex) {
            throw new IllegalArgumentException(INTERNAL_ERROR_MSG,ex);
        }
    }
625278
private static void createAdsWithCustomizations(AdWordsServicesInterface adWordsServices,
      AdWordsSession session, List<Long> adGroupIds, String feedName) throws RemoteException {
    // Get the AdGroupAdService.
    AdGroupAdServiceInterface adGroupAdService =
        adWordsServices.get(session, AdGroupAdServiceInterface.class);

    ExpandedTextAd textAd = new ExpandedTextAd();
    textAd.setHeadlinePart1(String.format("Luxury Cruise to {=%s.Name}", feedName));
    textAd.setHeadlinePart2(String.format("Only {=%s.Price}", feedName));
    textAd.setDescription(String.format("Offer ends in {=countdown(%s.Date)}!", feedName));
    textAd.setFinalUrls(new String[] {"http://www.example.com"});

    // We add the same ad to both ad groups. When they serve, they will show different values, since
    // they match different feed items.
    List<AdGroupAdOperation> adGroupAdOperations = new ArrayList<>();
    for (Long adGroupId : adGroupIds) {
      AdGroupAd adGroupAd = new AdGroupAd();
      adGroupAd.setAdGroupId(adGroupId);
      adGroupAd.setAd(textAd);

      AdGroupAdOperation adGroupAdOperation = new AdGroupAdOperation();
      adGroupAdOperation.setOperand(adGroupAd);
      adGroupAdOperation.setOperator(Operator.ADD);

      adGroupAdOperations.add(adGroupAdOperation);
    }

    AdGroupAdReturnValue adGroupAdReturnValue = adGroupAdService.mutate(
        adGroupAdOperations.toArray(new AdGroupAdOperation[adGroupAdOperations.size()]));

    for (AdGroupAd addedAd : adGroupAdReturnValue.getValue()) {
      System.out.printf("Created an ad with ID %d, type '%s' and status '%s'.%n",
          addedAd.getAd().getId(), addedAd.getAd().getAdType(), addedAd.getStatus());
    }
  }
476505
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the ExchangeRateService.
    ExchangeRateServiceInterface exchangeRateService =
        adManagerServices.get(session, ExchangeRateServiceInterface.class);

    // Create an exchange rate.
    ExchangeRate exchangeRate = new ExchangeRate();

    // Set the currency code.
    exchangeRate.setCurrencyCode("AUD");

    // Set the direction of the conversion (from the network currency).
    exchangeRate.setDirection(ExchangeRateDirection.FROM_NETWORK);

    // Set the conversion value as 1.5 (this value is multiplied by 10,000,000,000)
    exchangeRate.setExchangeRate(15000000000L);

    // Do not refresh exchange rate from Google data. Update manually only.
    exchangeRate.setRefreshRate(ExchangeRateRefreshRate.FIXED);

    // Create the exchange rate on the server.
    ExchangeRate[] exchangeRates =
        exchangeRateService.createExchangeRates(new ExchangeRate[] {exchangeRate});

    for (ExchangeRate createdExchangeRate : exchangeRates) {
      System.out.printf(
          "An exchange rate with ID %d, currency code '%s',"
              + " direction '%s', and exchange rate %.2f was created.%n",
          createdExchangeRate.getId(),
          createdExchangeRate.getCurrencyCode(),
          createdExchangeRate.getDirection().getValue(),
          (createdExchangeRate.getExchangeRate() / 10000000000f));
    }
  }
689167
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    LineItemServiceInterface lineItemService =
        adManagerServices.get(session, LineItemServiceInterface.class);

    // Create a statement to select line items.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("isMissingCreatives = :isMissingCreatives")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("isMissingCreatives", true);

    // Retrieve a small amount of line items at a time, paging through
    // until all line items have been retrieved.
    int totalResultSetSize = 0;
    do {
      LineItemPage page =
          lineItemService.getLineItemsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        // Print out some information for each line item.
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (LineItem lineItem : page.getResults()) {
          System.out.printf(
              "%d) Line item with ID %d and name '%s' was found.%n",
              i++,
              lineItem.getId(),
              lineItem.getName()
          );
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }
219891
private static Map<Long, ManagedCustomer> getAllManagedCustomers(
      AdWordsServicesInterface adWordsServices, ImmutableAdWordsSession session)
      throws RemoteException {
    // Get the ManagedCustomerService.
    ManagedCustomerServiceInterface managedCustomerService =
        adWordsServices.get(session, ManagedCustomerServiceInterface.class);

    SelectorBuilder selectorBuilder =
        new SelectorBuilder()
            .fields(ManagedCustomerField.CustomerId)
            .equals(ManagedCustomerField.CanManageClients, "false")
            .limit(PAGE_SIZE)
            .offset(0);

    ManagedCustomerPage managedCustomerPage;
    int offset = 0;
    Map<Long, ManagedCustomer> managedCustomers = Maps.newHashMap();
    do {
      selectorBuilder.offset(offset);
      managedCustomerPage = managedCustomerService.get(selectorBuilder.build());
      if (managedCustomerPage.getEntries() != null) {
        for (ManagedCustomer managedCustomer : managedCustomerPage.getEntries()) {
          managedCustomers.put(managedCustomer.getCustomerId(), managedCustomer);
        }
      }
      offset += PAGE_SIZE;
    } while (offset < managedCustomerPage.getTotalNumEntries());

    return managedCustomers;
  }
180426
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the TeamService.
    TeamServiceInterface teamService = adManagerServices.get(session, TeamServiceInterface.class);

    // Create a statement to select all teams.
    StatementBuilder statementBuilder =
        new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

    // Default for total result set size.
    int totalResultSetSize = 0;

    do {
      // Get teams by statement.
      TeamPage page = teamService.getTeamsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (Team team : page.getResults()) {
          System.out.printf(
              "%d) Team with ID %d and name '%s' was found.%n", i++, team.getId(), team.getName());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }
1253795
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session)
      throws RemoteException {
    // Get the CustomerNegativeCriterionService.
    CustomerNegativeCriterionServiceInterface customerNegativeCriterionService =
        adWordsServices.get(session, CustomerNegativeCriterionServiceInterface.class);

    List<Criterion> criteria = new ArrayList<>();

    // Exclude tragedy & conflict content.
    ContentLabel tragedyContentLabel = new ContentLabel();
    tragedyContentLabel.setContentLabelType(ContentLabelType.TRAGEDY);
    criteria.add(tragedyContentLabel);

    // Exclude a specific placement.
    Placement placement = new Placement();
    placement.setUrl("http://www.example.com");
    criteria.add(placement);

    // Additional criteria types are available for this service. See the types listed
    // under Criterion here:
    // https://developers.google.com/adwords/api/docs/reference/latest/CustomerNegativeCriterionService.Criterion

    // Create operations to add each of the criteria above.
    List<CustomerNegativeCriterionOperation> operations = new ArrayList<>();
    for (Criterion criterion : criteria) {
      CustomerNegativeCriterion negativeCriterion = new CustomerNegativeCriterion();
      negativeCriterion.setCriterion(criterion);
      CustomerNegativeCriterionOperation operation = new CustomerNegativeCriterionOperation();
      operation.setOperator(Operator.ADD);
      operation.setOperand(negativeCriterion);
      operations.add(operation);
    }

    // Send the request to add the criteria.
    CustomerNegativeCriterionReturnValue result =
        customerNegativeCriterionService.mutate(
            operations.toArray(new CustomerNegativeCriterionOperation[operations.size()]));

    // Display the results.
    for (CustomerNegativeCriterion negativeCriterion : result.getValue()) {
      System.out.printf(
          "Customer negative criterion with criterion ID %d and type '%s' was added.%n",
          negativeCriterion.getCriterion().getId(),
          negativeCriterion.getCriterion().getCriterionType());
    }
  }
210557
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    CreativeServiceInterface creativeService =
        adManagerServices.get(session, CreativeServiceInterface.class);

    // Create a statement to select creatives.
    StatementBuilder statementBuilder =
        new StatementBuilder()
            .where("creativeType = :creativeType")
            .orderBy("id ASC")
            .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
            .withBindVariableValue("creativeType", "ImageCreative");

    // Retrieve a small amount of creatives at a time, paging through
    // until all creatives have been retrieved.
    int totalResultSetSize = 0;
    do {
      CreativePage page = creativeService.getCreativesByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        // Print out some information for each creative.
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (Creative creative : page.getResults()) {
          System.out.printf(
              "%d) Creative with ID %d and name '%s' was found.%n",
              i++, creative.getId(), creative.getName());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }
189635
private static List<Long> getAllCustomTargetingKeyIds(
      AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    List<Long> customTargetingKeyIds = new ArrayList<>();

    // Get the CustomTargetingService.
    CustomTargetingServiceInterface customTargetingService =
        adManagerServices.get(session, CustomTargetingServiceInterface.class);

    // Create a statement to get all custom targeting keys.
    StatementBuilder statementBuilder =
        new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

    // Default for total result set size.
    int totalResultSetSize = 0;

    do {
      // Get custom targeting keys by statement.
      CustomTargetingKeyPage page =
          customTargetingService.getCustomTargetingKeysByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (CustomTargetingKey customTargetingKey : page.getResults()) {
          System.out.printf(
              "%d) Custom targeting key with ID %d, name '%s', and "
                  + "display name '%s' was found.%n",
              i++,
              customTargetingKey.getId(),
              customTargetingKey.getName(),
              customTargetingKey.getDisplayName());
          customTargetingKeyIds.add(customTargetingKey.getId());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    return customTargetingKeyIds;
  }
1330642
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the LineItemCreativeAssociationService.
    LineItemCreativeAssociationServiceInterface licaService =
        adManagerServices.get(session, LineItemCreativeAssociationServiceInterface.class);

    // Create a statement to get all LICAs.
    StatementBuilder statementBuilder = new StatementBuilder()
        .orderBy("lineItemId ASC, creativeId ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

    // Default for total result set size.
    int totalResultSetSize = 0;

    do {
      // Get LICAs by statement.
      LineItemCreativeAssociationPage page =
          licaService.getLineItemCreativeAssociationsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (LineItemCreativeAssociation lica : page.getResults()) {
          if (lica.getCreativeSetId() != null) {
            System.out.printf(
                "%d) LICA with line item ID %d and creative set ID %d was found.%n", i++,
                lica.getLineItemId(), lica.getCreativeSetId());
          } else {
            System.out.printf(
                "%d) LICA with line item ID %d and creative ID %d was found.%n", i++,
                lica.getLineItemId(), lica.getCreativeId());
          }
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }