private static List<Integer> getAllActivityGroupIds(DfpUser user)
throws RemoteException, ServiceException {
List<Integer> activityGroupIds = new ArrayList<Integer>();
// Get the ActivityGroupService.
ActivityGroupServiceInterface activityGroupService =
user.getService(DfpService.V201308.ACTIVITY_GROUP_SERVICE);
// Set defaults for page and filterStatement.
ActivityGroupPage page = new ActivityGroupPage();
Statement filterStatement = new Statement();
int offset = 0;
do {
// Create a statement to get all activity groups.
filterStatement.setQuery("LIMIT 500 OFFSET " + offset);
// Get activity groups by statement.
page = activityGroupService.getActivityGroupsByStatement(filterStatement);
if (page.getResults() != null) {
for (ActivityGroup activityGroup : page.getResults()) {
activityGroupIds.add(activityGroup.getId());
}