// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the CustomTargetingService.
CustomTargetingServiceInterface customTargetingService =
user.getService(DfpService.V201311.CUSTOM_TARGETING_SERVICE);
// Create a statement to get all custom targeting keys.
Statement filterStatement = new Statement("LIMIT 500", null);
// Get custom targeting keys by statement.
CustomTargetingKeyPage page =
customTargetingService.getCustomTargetingKeysByStatement(filterStatement);
if (page.getResults() != null) {
CustomTargetingKey[] customTargetingKeys = page.getResults();
// Update each local custom targeting key object by changing its display
// name.
for (CustomTargetingKey customTargetingKey : customTargetingKeys) {
if (customTargetingKey.getDisplayName() == null) {
customTargetingKey.setDisplayName(customTargetingKey.getName());
}
customTargetingKey.setDisplayName(customTargetingKey.getDisplayName() + " (Deprecated)");
}
// Update the custom targeting keys on the server.
customTargetingKeys = customTargetingService.updateCustomTargetingKeys(customTargetingKeys);
if (customTargetingKeys != null) {
for (CustomTargetingKey customTargetingKey : customTargetingKeys) {
System.out.println("Custom targeting key with ID \""
+ customTargetingKey.getId() + "\", name \"" + customTargetingKey.getName()