public List<WorksheetEntry> copyDocument( DocumentListEntry documentListEntry, String newDocumentTitle, DocumentListEntry destinationFolderEntry) throws IOException, ServiceException { documentListEntry.setTitle(new PlainTextConstruct(newDocumentTitle)); URL url = new URL("https://docs.google.com/feeds/default/private/full/"); DocumentListEntry newDoc = docsService.insert(url, documentListEntry); String destFolder = ((MediaContent) destinationFolderEntry.getContent()).getUri(); URL newUrl = new URL(destFolder); // Convert DocumentListEntry to SpreadsheetEntry DocumentListEntry newDocumentListEntry = docsService.insert(newUrl, newDoc); String spreadsheetURL = "https://spreadsheets.google.com/feeds/spreadsheets/" + newDocumentListEntry.getDocId(); SpreadsheetEntry spreadsheetEntry = spreadsheetService.getEntry(new URL(spreadsheetURL), SpreadsheetEntry.class); return spreadsheetEntry.getWorksheets(); }
public SpreadsheetEntry getSpreadsheetEntryFromDocumentListEntry(DocumentListEntry docListEntry) throws IOException, ServiceException { String spreadsheetURL = "https://spreadsheets.google.com/feeds/spreadsheets/" + docListEntry.getDocId(); return spreadsheetService.getEntry(new URL(spreadsheetURL), SpreadsheetEntry.class); }