// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the CreativeService.
CreativeServiceInterface creativeService =
user.getService(DfpService.V201311.CREATIVE_SERVICE);
// Create a statement to get all image creatives.
Statement filterStatement =
new StatementBuilder("WHERE creativeType = :creativeType LIMIT 500")
.putValue("creativeType", ImageCreative.class.getSimpleName()).toStatement();
// Get creatives by statement.
CreativePage page = creativeService.getCreativesByStatement(filterStatement);
if (page.getResults() != null) {
Creative[] creatives = page.getResults();
// Update each local creative object by changing its destination URL.
for (Creative creative : creatives) {
if (creative instanceof ImageCreative) {
ImageCreative imageCreative = (ImageCreative) creative;
imageCreative.setDestinationUrl("http://news.google.com");
}
}
// Update the creatives on the server.
creatives = creativeService.updateCreatives(creatives);
if (creatives != null) {
for (Creative creative : creatives) {
if (creative instanceof ImageCreative) {
ImageCreative imageCreative = (ImageCreative) creative;