}
public void test() throws MalformedURLException, IOException,
ServiceException {
// retrieve a playlist feed and do some batch operations on it
PlaylistFeed feed = service.getFeed(new URL(""), PlaylistFeed.class);
// retrieve the batch link from the feed
URL batchUrl = new URL(feed.getFeedBatchLink().getHref());
PlaylistFeed batchFeed = new PlaylistFeed();
// delete the third playlist entry
PlaylistEntry entryToDelete = feed.getEntries().get(2);
BatchUtils.setBatchId(entryToDelete, "B");
BatchUtils.setBatchOperationType(entryToDelete,
BatchOperationType.DELETE);
batchFeed.getEntries().add(entryToDelete);
// add a new video to the playlist
PlaylistEntry entryToAdd = new PlaylistEntry();
entryToAdd.setId("mTrp-GKG9Bo");
BatchUtils.setBatchId(entryToAdd, "A");
BatchUtils.setBatchOperationType(entryToAdd, BatchOperationType.INSERT);
batchFeed.getEntries().add(entryToAdd);
// move the second entry to the top of the playlist
PlaylistEntry entryToUpdate = feed.getEntries().get(1);
entryToUpdate.setPosition(0);
BatchUtils.setBatchId(entryToUpdate, "C");
BatchUtils.setBatchOperationType(entryToUpdate,
BatchOperationType.UPDATE);
batchFeed.getEntries().add(entryToUpdate);
// return the updated entry
PlaylistEntry entryToGet = feed.getEntries().get(0);
BatchUtils.setBatchId(entryToGet, "D");
BatchUtils.setBatchOperationType(entryToGet, BatchOperationType.QUERY);
batchFeed.getEntries().add(entryToGet);
PlaylistFeed batchResponse = service.batch(batchUrl, batchFeed);
for (PlaylistEntry entry : batchResponse.getEntries()) {
if (BatchUtils.isSuccess(entry)) {
System.out.println("Operation " + BatchUtils.getBatchId(entry)
+ " succeeded!");
String operation = BatchUtils.getBatchOperationType(entry)
.getName();