Package com.google.gdata.data.docs

Examples of com.google.gdata.data.docs.DocumentListEntry


      throws IOException, ServiceException, InterruptedException {
    String docIdToUpdate = args[1];
    String filePath = args[2];

    // retrieve latest entry
    DocumentListEntry currentEntry = docs.service.getEntry(
        new URL(DEFAULT_DOCLIST_FEED_URL  + "/" + docIdToUpdate),
        DocumentListEntry.class);

    MediaFileSource mediaFile = getMediaFileSource(filePath);
    ResumableGDataFileUploader uploader =
        new ResumableGDataFileUploader
            .Builder(docs.service, mediaFile, currentEntry)
            .title(mediaFile.getName())
            .requestType(
                ResumableGDataFileUploader.RequestType.UPDATE_MEDIA_ONLY)
            .build();

    uploader.start();

    // wait for upload to complete
    while (!uploader.isDone()) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException ie) {
        output.println("Media update interrupted at: "
            + String.format("%3.0f", uploader.getProgress() * 100) + "%");
        throw ie; // rethrow
      }
    }
    DocumentListEntry updatedEntry =
        uploader.getResponse(DocumentListEntry.class);

    output.println("Finished update");
  }
View Full Code Here


      for (ResumableGDataFileUploader uploader : trackedUploaders) {
        String fileId = ((FileUploadData) uploader.getData()).getFileName();
        switch(uploader.getUploadState()) {
          case COMPLETE:
            try {
              DocumentListEntry entry =
                  uploader.getResponse(DocumentListEntry.class);
              uploaded.put(fileId, entry);
            } catch (IOException e) {
              failed.put(fileId, "Upload completed, but unexpected error "
                  + "reading server response");
View Full Code Here

   * @throws DocumentListException
   */
  private void executeUpload(String[] args) throws IOException,
      ServiceException, DocumentListException, InterruptedException {
    if (args.length == 3) {
      DocumentListEntry entry = documentList.uploadFile(args[1], args[2]);
      printDocumentEntry(entry);
    } else {
      printMessage(COMMAND_HELP_UPLOAD);
    }
  }
View Full Code Here

      DocumentListException {
    if (title == null || type == null) {
      throw new DocumentListException("null title or type");
    }

    DocumentListEntry newEntry = null;
    if (type.equals("document")) {
      newEntry = new DocumentEntry();
    } else if (type.equals("presentation")) {
      newEntry = new PresentationEntry();
    } else if (type.equals("spreadsheet")) {
      newEntry = new SpreadsheetEntry();
    } else if (type.equals("folder")) {
      newEntry = new FolderEntry();
    }

    newEntry.setTitle(new PlainTextConstruct(title));
    return service.insert(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED), newEntry);
  }
View Full Code Here

      throws IOException, MalformedURLException, ServiceException, DocumentListException {
    if (resourceId == null || folderId == null) {
      throw new DocumentListException("null passed in for required parameters");
    }

    DocumentListEntry doc = new DocumentListEntry();
    doc.setId(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + resourceId).toString());

    URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + folderId + URL_FOLDERS);
    return service.insert(url, doc);
  }
View Full Code Here

  }
 
  public DocumentListEntry createNewDocument(String title, String content) throws ServiceException {
    try {
      URL feedUrl = new URL("https://docs.google.com/feeds/default/private/full/");
      DocumentListEntry newEntry = new DocumentEntry();
      newEntry.setTitle(new PlainTextConstruct(title));
      newEntry = client().insert(feedUrl, newEntry);
     
      newEntry.setMediaSource(new MediaByteArraySource(content.getBytes(), "text/html"));
      newEntry = newEntry.updateMedia(true);
      return newEntry;
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    } catch (IOException e) {
      throw new RuntimeException(e);
View Full Code Here

  public DocumentListEntry createNew(String title, String type) throws MalformedURLException, IOException, ServiceException, DocumentListException {
    if (title == null || type == null) {
      throw new DocumentListException("null title or type");
    }

    DocumentListEntry newEntry = null;
    if (type.equals("document")) {
      newEntry = new DocumentEntry();
    } else if (type.equals("presentation")) {
      newEntry = new PresentationEntry();
    } else if (type.equals("spreadsheet")) {
      newEntry = new SpreadsheetEntry();
    } else if (type.equals("folder")) {
      newEntry = new FolderEntry();
    }

    newEntry.setTitle(new PlainTextConstruct(title));
    return service.insert(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED), newEntry);
  }
View Full Code Here

   * @throws IOException Signals that an I/O exception has occurred.
   * @throws ServiceException the service exception
   * @throws DocumentListException the document list exception
   */
  public DocumentListEntry createNewSubFolder(String title, String folderResourceId) throws IOException, ServiceException, DocumentListException {
    DocumentListEntry newEntry = new FolderEntry();
    newEntry.setTitle(new PlainTextConstruct(title));
    URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + folderResourceId + URL_FOLDERS);
    return service.insert(url, newEntry);
  }
View Full Code Here

      DocumentListException {
    if (resourceId == null || folderId == null) {
      throw new DocumentListException("null passed in for required parameters");
    }

    DocumentListEntry doc = new DocumentListEntry();
    doc.setId(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + resourceId).toString());

    URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + folderId + URL_FOLDERS);
    return service.insert(url, doc);
  }
View Full Code Here

     
      int uploaded = uploadFolder(file, getRemoteFolderByPath(remoteFolder), counters);
      printLine("\nFiles uploaded: " + uploaded + " out of " + counters[1]);   
    } else {
      printLine("\n" + file.getAbsolutePath());
      DocumentListEntry remoteFolderEntry = getRemoteFolderByPath(remoteFolder);
      uploadFile(file, remoteFolderEntry, getDocsFromFolder(remoteFolderEntry));
      printLine("\nThe file has been uploaded");
    }   
  }
View Full Code Here

TOP

Related Classes of com.google.gdata.data.docs.DocumentListEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.