long dfaSiteId, long campaignId, int pricingType, long sizeId) throws Exception {
// Request the placement service from the service client factory.
PlacementRemote placementService = dfaServices.get(session, PlacementRemote.class);
// Create the placement.
Placement placement = new Placement();
placement.setId(0);
placement.setName(placementName);
placement.setCampaignId(campaignId);
placement.setDfaSiteId(dfaSiteId);
placement.setSizeId(sizeId);
// The type ID for regular agency paid placements is 3. See
// GetPlacementTypes.java
placement.setPlacementType(3);
// Set the pricing schedule for the placement.
PricingSchedule pricingSchedule = new PricingSchedule();
Calendar startDate = Calendar.getInstance();
Calendar endDate = Calendar.getInstance();
endDate.add(Calendar.MONTH, 1);
pricingSchedule.setStartDate(startDate);
pricingSchedule.setEndDate(endDate);
pricingSchedule.setPricingType(pricingType);
placement.setPricingSchedule(pricingSchedule);
// Set the placement tag settings.
TagSettings tagSettings = new TagSettings();
PlacementTagOption[] placementTagOptions = placementService.getRegularPlacementTagOptions();
int[] tagTypes = new int[placementTagOptions.length];
for (int i = 0; i < placementTagOptions.length; i++) {
tagTypes[i] = (int) placementTagOptions[i].getId();
}
tagSettings.setTagTypes(tagTypes);
placement.setTagSettings(tagSettings);
// Save the placement.
PlacementSaveResult placementSaveResult = placementService.savePlacement(placement);
// Display the new placement ID.