throws Exception {
// Request the creative service from the service client factory.
CreativeRemote creativeService = dfaServices.get(session, CreativeRemote.class);
// Set up creative search criteria structure.
CreativeSearchCriteria creativeSearchCriteria = new CreativeSearchCriteria();
creativeSearchCriteria.setPageSize(100);
creativeSearchCriteria.setAdvertiserId(advertiserId);
// When paging, start counting page numbers from 1 rather than 0.
creativeSearchCriteria.setPageNumber(1);
CreativeRecordSet creatives;
int i = 1;
do {
// Get creatives for the selected criteria.
creatives = creativeService.getCreatives(creativeSearchCriteria);
for (CreativeBase result : creatives.getRecords()) {
System.out.printf("%s) Creative with name \"%s\" and ID \"%s\" was found.%n",
i++, result.getName(), result.getId());
}
creativeSearchCriteria.setPageNumber(creativeSearchCriteria.getPageNumber() + 1);
} while (creativeSearchCriteria.getPageNumber() <= creatives.getTotalNumberOfPages());
System.out.printf("Number of results found: %s%n",
creatives.getTotalNumberOfRecords());
}