Package com.google.gdata.data.docs

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


    @Test
    public void shouldGetResourceFromDocsService() throws IOException, ServiceException {
        DocsService service = mock(DocsService.class);
        DocumentListFeed feed = mock(DocumentListFeed.class);
        DocumentListEntry entry = mock(DocumentListEntry.class);
        MediaSource mediaSource = mock(MediaSource.class);
        InputStream inputStream = mock(InputStream.class);
        final MediaContent content = mock(MediaContent.class);
        final DocumentQuery query = mock(DocumentQuery.class);
        when(service.getFeed(query, DocumentListFeed.class)).thenReturn(feed);
        when(service.getMedia(content)).thenReturn(mediaSource);
        when(feed.getEntries()).thenReturn(asList(entry));
        when(entry.getContent()).thenReturn(content);
        when(content.getUri()).thenReturn("http://docs.google.com");
        when(mediaSource.getInputStream()).thenReturn(inputStream);

        LoadOdtFromGoogle storyLoader = new LoadOdtFromGoogle("user", "password", "https://docs.google.com/feeds/default/private/full/", service){
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

    //check that previous upload test has run
    if (uploadedExcelDocumentID!=null){
      fail("Document Upload Test should be the first to run");
    }

    DocumentListEntry entry = demo.uploadFile(SAMPLE_EXCEL_TO_UPLOAD_PATH, SAMPLE_EXCEL_TO_UPLOAD_NAME);
    assertNotNull("Google Docs should return an ID for the entry ",entry);
    demo.printDocumentEntry(entry);
    assertNotNull("Google Docs should return a resourceID as part of the entry",entry.getResourceId());


    //Save the resource ID for later
    uploadedExcelDocumentID = entry.getResourceId();
    log.info("setting uploadedExcelDocumentID to:"+uploadedExcelDocumentID);


  }
View Full Code Here

    //check that previous upload test has run
    if (uploadedKbDocumentID!=null){
      fail("Document Upload Test should be the first to run");
    }

    DocumentListEntry entry = demo.uploadFile(SAMPLE_KB_TO_UPLOAD_PATH, SAMPLE_KB_TO_UPLOAD_NAME);
    assertNotNull("Google Docs should return an ID for the entry ",entry);
    demo.printDocumentEntry(entry);
    assertNotNull("Google Docs should return a resourceID as part of the entry",entry.getResourceId());

    uploadedKbDocumentID = entry.getResourceId();
    log.info("setting uploadedKbDocumentID to:"+uploadedKbDocumentID);

  }
View Full Code Here

   * @param documentId the document Id
   * @throws DocumentServiceException
   */
  @Override
  public DocumentServiceEntry getDocument(String documentId) throws DocumentServiceException {
    DocumentListEntry entry = getDocumentEntry(documentId);
    return getDocumentReference(entry);
  }
View Full Code Here

   * @param sinceEtag the etag value from which the document's etag value should differ
   * @return the document entry
   * @throws DocumentServiceException
   */
  private DocumentListEntry getDocumentEntry(String documentId, String sinceEtag) throws DocumentServiceException {
  DocumentListEntry entry = getDocumentEntry(documentId);
  if (sinceEtag != null) {
    for (int i=0; i<2; i++) {
    if (sinceEtag.equals(entry.getEtag())) {
        entry = getDocumentEntry(documentId);
    } else {
        break;
    }
    }
View Full Code Here

   * @param newTitle the new document title
   * @throws DocumentServiceException
   */
  @Override
  public DocumentServiceEntry renameDocument(String documentId, String newTitle) throws DocumentServiceException {
    DocumentListEntry entry = getDocumentEntry(documentId);
    try {
      entry.setTitle(new PlainTextConstruct(newTitle));
      entry.update();
      return getDocument(documentId);
    } catch (Exception e) {
      e.printStackTrace();
      throw new DocumentServiceException(e.getMessage());
    }
View Full Code Here

    DocsService svc = getDocsService();
    svc.getRequestFactory().setHeader("If-Match", etag);
    try {
    MediaByteArraySource source = new MediaByteArraySource(contents.getBytes("UTF8"), "text/plain");
    String editMediaUri = DOCS_SCOPE + "default/media/document%3A" + documentId;
    DocumentListEntry entry = svc.updateMedia(new URL(editMediaUri), DocumentListEntry.class, source);
    entry = getDocumentEntry(documentId, etag);
    return getDocumentReference(entry);
    } catch (Exception e) {
      e.printStackTrace();
      throw new DocumentServiceException(e.getMessage());
View Full Code Here

   * @param starred whether the document is starred
   * @throws DocumentServiceException
   */
  @Override
  public boolean setDocumentStarred(String documentId, boolean starred) throws DocumentServiceException {
    DocumentListEntry entry = getDocumentEntry(documentId);
    try {
      entry.setStarred(starred);
      entry.update();
    } catch (Exception e) {
      e.printStackTrace();
      throw new DocumentServiceException(e.getMessage());
    }
    return true;
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.