Package com.google.enterprise.connector.spi

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


   * Return true if the obect's content should be supplied for indexing.
   */
  private boolean canIndex(boolean logging) throws RepositoryException {
    // Don't send content that is too big or too small.
    long contentSize = object.getContentSize();
    TraversalContext traversalContext = traversalManager.getTraversalContext();

    // Don't send content whose mimetype is not supported.
    IFormat format = object.getFormat();
    String mimetype = format.getMIMEType();
    if (traversalContext != null) {
      int supportLevel = traversalContext.mimeTypeSupportLevel(mimetype);
      if (supportLevel < 0) {
        if (logging) {
          logger.fine("excluded content format: " + format.getName());
        }
        throw new SkippedDocumentException("Excluded by content type: "
                                           + mimetype);
      }
      if (supportLevel == 0) {
        if (logging) {
          logger.fine("unindexable content format: " + format.getName());
        }
        return false;
      }
      if (contentSize > traversalContext.maxDocumentSize()) {
        if (logging) {
          logger.fine("content is too large: " + contentSize);
        }
        return false;
      }
View Full Code Here


    FileSystemTypeRegistry fileSystemTypeRegistry = new FileSystemTypeRegistry(
        Collections.singletonList(new JavaFileSystemType()));
    FileSystemPropertyManager propertyManager =
        new TestFileSystemPropertyManager();
    PathParser pathParser = new PathParser(fileSystemTypeRegistry);
    TraversalContext traversalContext = new FakeTraversalContext();
    MimeTypeDetector.setTraversalContext(traversalContext);
    MimeTypeDetector mimeTypeDetector = new MimeTypeDetector();

    DocumentContext context = new DocumentContext(
        null, null, null, mimeTypeDetector, propertyManager,
View Full Code Here

  @Override
  public void setUp() throws Exception {
    FileSystemTypeRegistry fileSystemTypeRegistry = new FileSystemTypeRegistry(
        Collections.singletonList(new JavaFileSystemType()));
    TraversalContext traversalContext = new SimpleTraversalContext();
    MimeTypeDetector.setTraversalContext(traversalContext);
    MimeTypeDetector mimeTypeDetector = new MimeTypeDetector();
    PathParser pathParser = new PathParser(fileSystemTypeRegistry);
    FileSystemPropertyManager propertyManager =
        new TestFileSystemPropertyManager(false);
View Full Code Here

    }
  }

  public void testGetContentUnsupportedMimeType() throws Exception {
    MockReadonlyFile archive = root.addFile("test.jpg", TEST_DATA);
    TraversalContext traversalContext = new FakeTraversalContext() {
        @Override
        public int mimeTypeSupportLevel(String mimeType) {
          return 0;
        }
      };
View Full Code Here

  }

  private DBSnapshotRepository getObjectUnderTest(
      Map<String, String> configMap) {
    // Connector manager does this in production.
    TraversalContext tc = new SimpleTraversalContext();
    MimeTypeDetector.setTraversalContext(tc);

    DBContext dbContext = getDbContext(configMap);

    TraversalContextManager traversalContextManager =
View Full Code Here

  /**
   * @return the {@link TraversalContext}
   */
  public TraversalContext getTraversalContext() {
    TraversalContext result = traversalContext.get();
    Preconditions.checkState((result != null),
                             "setTraversalContext has not been called.");
    return result;
  }
View Full Code Here

public class SpringBasedProductionTraversalContextTest extends TestCase {
  public final void testSpringBased() {
    ApplicationContext applicationContext;
    applicationContext = new FileSystemXmlApplicationContext(
        "testdata/traversalContextData/applicationContext.xml");
    TraversalContext traversalContext = (TraversalContext) applicationContext
        .getBean("TraversalContext");
    assertNotNull(traversalContext);
    assertEquals(2500000, traversalContext.maxDocumentSize());
    assertTrue(traversalContext.mimeTypeSupportLevel("text/plain") <= 0);
    assertTrue(traversalContext.mimeTypeSupportLevel("text/notplain")
                      <= 0);
    assertEquals(1, traversalContext.mimeTypeSupportLevel("ibblefrix"));
    assertEquals("ibblefrix", traversalContext.preferredMimeType(
                 Collections.singleton("ibblefrix")));
  }
View Full Code Here

    Context.getInstance().setStandaloneContext(
        Context.DEFAULT_JUNIT_CONTEXT_LOCATION,
        Context.DEFAULT_JUNIT_COMMON_DIR_PATH);
    Context.getInstance().setFeeding(false);
    Context.getInstance().start();
    TraversalContext traversalContext = Context.getInstance()
        .getTraversalContext();
    assertNotNull(traversalContext);
    Context.getInstance().shutdown(true);
    Context.refresh();
  }
View Full Code Here

  }

  /** If target is TraversalContextAware, set its traversalContext. */
  private void setTraversalContext(Object target) {
    if (target != null && target instanceof TraversalContextAware) {
      TraversalContext traversalContext =
          Context.getInstance().getTraversalContext();
      try {
        ((TraversalContextAware) target).setTraversalContext(traversalContext);
      } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Unable to set TraversalContext", e);
View Full Code Here

  @Override
  public void setUp() throws IOException {
    queue = new MockChangeQueue(BATCH_COUNT * BATCH_SIZE + EXTRA);
    monitorManager = new FakeDocumentSnapshotRepositoryMonitorManager(queue, this,
        new DeleteDocumentHandleFactory(), new MockDocumentHandleFactory());
    TraversalContext traversalContext = new FakeTraversalContext();
    TraversalContextManager tcm = new TraversalContextManager();
    tcm.setTraversalContext(traversalContext);
    tm = new DiffingConnectorTraversalManager(monitorManager, tcm);
    tm.setTraversalContext(new FakeTraversalContext());
    tm.setBatchHint(BATCH_SIZE);
View Full Code Here

TOP

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

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.