Package com.google.enterprise.connector.spi

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


    // First, get an ordinary traversal manager, start it,
    // and see what the first doc is that it returns.
    // Verify that this date is before our sanctioned startDate
    Session sess = conn.login();
    TraversalManager tm = sess.getTraversalManager();
    Document doc = getFirstResult(tm);
    assertNotNull("First doc is null.", doc);
    String dateStr = doc.findProperty("ModifyDate").nextValue().toString();
    try {
      Date docDate = parseDate(dateStr);

      assertTrue("First doc is newer than startDate.",
          docDate.before(startDate));
    }
    catch (ParseException e) {
      fail("Unable to parse document modified date: " + dateStr);
    }

    // Now, get another traversal manager, with a connector
    // with an appropriate start date(SD).  Traverse the
    // repository and ensure that nothing older than the
    // start date is returned.
    LivelinkConnector connSD =
        LivelinkConnectorFactory.getConnector("connector.");
    connSD.setStartDate(startDateString);
    Session sessSD = connSD.login();
    TraversalManager tmSD = sessSD.getTraversalManager();

    // Look for any results that are too old
    LivelinkDocumentList results =
        (LivelinkDocumentList) tmSD.startTraversal();
    while (results != null) {
      assertNoResultsOlderThan(results, startDate);
      String checkpoint = results.checkpoint();
      results = (LivelinkDocumentList) tmSD.resumeTraversal(checkpoint);
    }
  }
View Full Code Here


  }

  public void testDuplicates() throws RepositoryException {
    Session sess = conn.login();

    TraversalManager mgr = sess.getTraversalManager();

    HashSet<String> nodes = new HashSet<String>();
    LivelinkDocumentList docList = (LivelinkDocumentList) mgr.startTraversal();
    while (docList != null) {
      assertNoDuplicates(docList, nodes);
      String checkpoint = docList.checkpoint();
      docList = (LivelinkDocumentList) mgr.resumeTraversal(checkpoint);
    }
  }
View Full Code Here

      con.setPassword(TestConfiguration.d1password);

      con.setDataSource(dbType, TestConfiguration.dbs.get(dbType));
      Session s = con.login();
      AuthenticationManager am = s.getAuthenticationManager();
      TraversalManager tm = s.getTraversalManager();
      tm.startTraversal();
     
      // four threads which will be crawling the database simultaneously
      List<TestThread> threads = new ArrayList<TestThread>();
      for (int i = 0; i < 4; ++i) {
        TestThread t = new TestThread(TestConfiguration.d1hostname,
View Full Code Here

  }

  @Override
  public void run() {
    try {
      TraversalManager tm = con.login().getTraversalManager();
      tm.startTraversal();
      for (int i = 1; i < runs; ++i) {
        tm.startTraversal();
      }
    } catch (RepositoryException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

  public void tearDown() throws Exception {
  }

  @Test
  public void testResumeTraversal() throws RepositoryException {
    TraversalManager trav = session.getTraversalManager();
    trav.setBatchHint(500);
    DocumentList docList = trav.startTraversal();
    assertNotNull(docList);
    docList = trav.resumeTraversal("");
    assertNotNull(docList);
  }
View Full Code Here

  public void testSimple() throws Exception {
    MockRepositoryEventList mrel = new MockRepositoryEventList(
        "MockRepositoryEventLog1.txt");
    MockRepository r = new MockRepository(mrel);
    QueryManager qm = new MockJcrQueryManager(r.getStore());
    TraversalManager qtm = new JcrTraversalManager(qm);
    MockPusher pusher = new MockPusher(System.out);
    DocumentList documentList = qtm.startTraversal();
    int counter = 0;
    Document document = null;
    while ((document = documentList.nextDocument()) != null) {
      pusher.take(document);
      counter++;
View Full Code Here

  /**
   * Registers the supplied {@link Connector} with this {@link Instantiator}.
   */
  public void addConnector(String connectorName, Connector connector) {
    TraversalManager traversalManager;
    try {
      Session session = connector.login();
      traversalManager = session.getTraversalManager();
    } catch (Exception e) {
      // won't happen
View Full Code Here

    if (batchSize.getHint() == 0) {
      return false;
    }

    try {
      TraversalManager traversalManager = getTraversalManager();
      if (traversalManager == null) {
        return false;
      }
      currentBatchKey = new Object();
      BatchCoordinator batchCoordinator = new BatchCoordinator(this);
View Full Code Here

  private void updateConnectorTest(SpringInstantiator instantiator,
      String name, String language, boolean update, Configuration config)
      throws JSONException, InstantiatorException, ConnectorExistsException,
             ConnectorNotFoundException, ConnectorTypeNotFoundException {
    TraversalManager oldTraversersalManager = null;
    if (update) {
      oldTraversersalManager =
          instantiator.getConnectorCoordinator(name).getTraversalManager();
    }
    Locale locale = I18NUtil.getLocaleFromStandardLocaleString(language);
    instantiator.setConnectorConfiguration(name, config, locale, update);

    // Make sure that this connector now exists.
    assertTrue(connectorExists(name));

    // Make sure that this connector has the correct type associated.
    assertEquals(config.getTypeName(), instantiator.getConnectorTypeName(name));

    AuthorizationManager authz = instantiator.getAuthorizationManager(name);
    assertNotNull(authz);

    AuthenticationManager authn = instantiator.getAuthenticationManager(name);
    assertNotNull(authn);

    TraversalManager traversalManager =
        instantiator.getConnectorCoordinator(name).getTraversalManager();
    assertNotNull(traversalManager);

    // If this is an update, make sure that we get a different traverser.
    // Regression test for Issues 35, 63.
View Full Code Here

    volatile Exception myException;
    @Override
    public void run() {
      try {
        // Get the Traverser for our connector instance.
        TraversalManager oldTraversalManager =
            instantiator.getConnectorCoordinator("connector1")
                .getTraversalManager();
        TraversalManager newTraversalManager =
            instantiator.getConnectorCoordinator("connector1")
                .getTraversalManager();
        if (oldTraversalManager != newTraversalManager) {
          throw new Exception("oldTraverser = " + oldTraversalManager
              + " must match newTraverser = " + newTraversalManager);
View Full Code Here

TOP

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

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.