throws ServiceException, RemoteException {
// Create list to hold all ad units.
List<AdUnit> adUnits = new ArrayList<AdUnit>();
// Get InventoryService.
InventoryServiceInterface inventoryService =
user.getService(DfpService.V201308.INVENTORY_SERVICE);
// Sets defaults for page and filterStatement.
AdUnitPage page = new AdUnitPage();
Statement filterStatement = new Statement();
int offset = 0;
do {
// Create a statement to get all ad units.
filterStatement.setQuery("LIMIT 500 OFFSET " + offset);
// Get ad units by statement.
page = inventoryService.getAdUnitsByStatement(filterStatement);
if (page.getResults() != null) {
adUnits.addAll(Arrays.asList(page.getResults()));
}