Package com.google.enterprise.connector.spi

Examples of com.google.enterprise.connector.spi.DocumentList

Boundary cases are important for {@link #checkpoint()}: The typical pattern for consuming an object that implements this interface is as follows (disregarding exception handling):
 DocumentList docList = ... Document doc; while (doc = docList.nextDocument()) { handleDoc(doc); if (whatever reason) break; } String check = doclist.checkpoint(); 
Note: because of the restriction that the next call to {@link #nextDocument()} invalidates the previous Document, and thereare similar restrictions in the {@link Document} interface, it is possibleto provide a single stateful object that implements {@link DocumentList}, {@link Document} and {@link Property}, by returning {@code this}(or {@code null}) to all calls to {@link #nextDocument()} and{@link Document#findProperty(String)}. However, if preferred, the implementor may also use separate objects for each of those interfaces. @since 1.0

                                       objectId - 1);

        // Now push that one document.
        TraversalManager mgr = sess.getTraversalManager();
        mgr.setBatchHint(1);
        DocumentList rs = mgr.resumeTraversal(checkpoint.toString() + ',');
        pushResultSet(rs);
    }
View Full Code Here


    };
   
    try {
      GdConnector gdc = new GdConnector();
      gdc.setService(alwaysNotModifiedService);
      DocumentList resultSet = gdc.startTraversal();
      assertNull(resultSet.nextDocument());
    } catch (RepositoryException re) {
      fail(re.toString());
    }
  }
View Full Code Here

    };
   
    try {
      GdConnector gdc = new GdConnector();
      gdc.setService(alwaysOneEntryService);
      DocumentList resultSet = gdc.startTraversal();
      Document docA = resultSet.nextDocument();
      Document docB = resultSet.nextDocument();
      assertNotNull(docA);
      assertEquals("\u9762",
          getFirstStringValue(docA, SpiConstants.PROPNAME_DOCID));
      assertNull(docB);
    } catch (RepositoryException re) {
View Full Code Here

  throws RepositoryException {
    LinkedList items = new LinkedList();
    items.add(makeDocument("a while ago"));
    items.add(makeDocument("just the other day"));
   
    DocumentList docList = new GdDocumentList(items, "right now");
    Document ignoredDocument = null;
   
    ignoredDocument = docList.nextDocument();
    assertEquals("a while ago", docList.checkpoint());
    ignoredDocument = docList.nextDocument();
    assertEquals("just the other day", docList.checkpoint());
    ignoredDocument = docList.nextDocument();
    assertEquals("right now", docList.checkpoint());
  }
View Full Code Here

    LinkedList items = new LinkedList();
    items.add(docA);
    items.add(docB);
    items.add(docC);
   
    DocumentList docList = new GdDocumentList(items, "right now");
   
    assertSame(docA, docList.nextDocument());
    assertSame(docB, docList.nextDocument());
    assertSame(docC, docList.nextDocument());
    assertNull(null, docList.nextDocument());
  }
View Full Code Here

  public void testStartTraversal() throws RepositoryException {
    expect(traverser.getDocumentList(isA(Checkpoint.class)))
        .andReturn(emptyList);
    replay(traverser);

    DocumentList docList = traversalMgr.startTraversal();
    assertEquals(emptyList, docList);
    verify(traverser);
  }
View Full Code Here

    expect(traverser.getDocumentList(isA(Checkpoint.class)))
        .andReturn(emptyList);
    replay(traverser);

    // The checkpoint must be a valid JSON string.
    DocumentList docList = traversalMgr.resumeTraversal("{}");
    assertEquals(emptyList, docList);
    verify(traverser);
  }
View Full Code Here

    Traverser traverser = getObjectUnderTest();
    traverser.setBatchHint(100);
    // Under live test and the test account, the deletion events weren't
    // returned from FileNet.
    boolean tested = false;
    DocumentList docList = traverser.getDocumentList(new Checkpoint());
    Document doc;
    while ((doc = docList.nextDocument()) != null) {
      assertTrue(checkpointContains(docList.checkpoint(),
          doc.findProperty(SpiConstants.PROPNAME_LASTMODIFIED),
          JsonField.LAST_MODIFIED_TIME));
      tested = true;
    }
    assertTrue(tested);
View Full Code Here

   * Testing chronological traversal
   */
  public void testLiveNextDocument() throws Exception {
    Traverser traverser = getObjectUnderTest();
    boolean isTested = false;
    DocumentList docList = traverser.getDocumentList(new Checkpoint());
    assertNotNull("Document list is null", docList);
    Document doc = docList.nextDocument();
    while (doc != null && doc instanceof FileDocument) {
      Property lastModifiedProp =
          doc.findProperty(SpiConstants.PROPNAME_LASTMODIFIED);
      Value lastModifiedValue = lastModifiedProp.nextValue();
      Calendar cal = Value.iso8601ToCalendar(lastModifiedValue.toString());

      Document nextDoc = docList.nextDocument();
      if (nextDoc != null && nextDoc instanceof FileDocument) {
        Property nextDocLastModifiedProp =
            nextDoc.findProperty(SpiConstants.PROPNAME_LASTMODIFIED);
        Value nextDocLastModifiedValue = nextDocLastModifiedProp.nextValue();
        Calendar nextCal =
View Full Code Here

  private void testSorting(int[] expectedOrder, String[][] entries,
      DatabaseType dbType) throws Exception {
    MockObjectStore os = new MockObjectStore("objectstore", dbType,
        generateObjectMap(entries, false, true));
    DocumentList docList =
        getObjectUnderTest(os, getDocuments(os.getObjects()),
            getCustomDeletion(os.getObjects()),
            getDeletionEvents(os.getObjects()));

    // Test the order
    for (int index : expectedOrder) {
      Document doc = docList.nextDocument();
      Property fid = doc.findProperty(SpiConstants.PROPNAME_DOCID);
      assertEquals("[" + dbType + "] Incorrect id sorting order",
          "{" + entries[index][0] + "}", fid.nextValue().toString());
    }
  }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.spi.DocumentList

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.