public CellEntry addCellEntry(CellEntry cellEntry, SpreadsheetUrl cellfeedUrl) throws IOException { AtomContent content = AtomContent.forEntry(DICTIONARY, cellEntry); HttpRequest request = requestFactory.buildPostRequest(cellfeedUrl, content); request.getHeaders().setIfNoneMatch(((CellEntry) cellEntry).etag); return request.execute().parseAs(cellEntry.getClass()); }
public WorksheetEntry addWorksheet(WorksheetEntry worksheetEntry, SpreadsheetUrl worksheetfeedUrl) throws IOException { AtomContent content = AtomContent.forEntry(DICTIONARY, worksheetEntry); HttpRequest request = requestFactory.buildPostRequest(worksheetfeedUrl, content); // request.getHeaders().setIfNoneMatch(worksheetEntry.etag); return request.execute().parseAs(worksheetEntry.getClass()); }
public CellEntry executeInsert(CellEntry entry, boolean matchTag) throws IOException { AtomContent content = AtomContent.forEntry(DICTIONARY, entry); HttpRequest request = requestFactory.buildPutRequest(new SpreadsheetUrl(entry.getEditLink()), content); if (matchTag) { // this will only insert if there has been no modification. request.getHeaders().setIfMatch(((CellEntry) entry).etag); } else { // this will only insert if there has been a modification request.getHeaders().setIfNoneMatch(((CellEntry) entry).etag); } return request.execute().parseAs(entry.getClass()); }
public CellFeed batchUpdate(CellFeed feed) throws IOException { List<CellEntry> updatedCells = Lists.newArrayList(); for (CellEntry ce : feed.cells) { if (ce.batchId != null) { updatedCells.add(ce); } } feed.cells = updatedCells; SpreadsheetUrl url = new SpreadsheetUrl(feed.getBatchLink()); // AtomFeedContent content = new AtomFeedContent(); AtomContent content = AtomContent.forFeed(DICTIONARY, feed); // content.namespaceDictionary = DICTIONARY; // content.feed = feed; HttpRequest request = requestFactory.buildPostRequest(url, content); request.getHeaders().setIfNoneMatch("whatever"); return request.execute().parseAs(CellFeed.class); }