public DocumentListEntry createFolder(String folderName, String roleString, List<String> emails) throws IOException, ServiceException { logger.info("\n\nFolder Exists? " + folderName); boolean folderFound = false; URL feedUri = new URL("https://docs.google.com/feeds/default/private/full/-/folder"); DocumentListFeed feed = docsService.getFeed(feedUri, DocumentListFeed.class); DocumentListEntry folderEntry = new DocumentListEntry(); for (DocumentListEntry entry : feed.getEntries()) { if (folderName.equalsIgnoreCase(entry.getTitle().getPlainText())) { folderFound = true; folderEntry = entry; break; } } if (!folderFound) { logger.info("\n\nCreating folder " + folderName); DocumentListEntry newEntry = new FolderEntry(); newEntry.setTitle(new PlainTextConstruct(folderName)); URL feedUrl = new URL("https://docs.google.com/feeds/default/private/full/"); folderEntry = docsService.insert(feedUrl, newEntry); shareResource(roleString, emails, folderEntry); } return folderEntry; }
public String getFolderURI(String _folderName) throws IOException, ServiceException { URL feedUri = new URL("https://docs.google.com/feeds/default/private/full/-/folder"); DocumentListFeed feed = docsService.getFeed(feedUri, DocumentListFeed.class); DocumentListEntry folderEntry = new DocumentListEntry(); for (DocumentListEntry entry : feed.getEntries()) { if (_folderName.equalsIgnoreCase(entry.getTitle().getPlainText())) { folderEntry = entry; break; } } String folderURIString = null; if (folderEntry.getContent() != null) { folderURIString = getDocumentFeedUri(folderEntry); } return folderURIString; }