Package com.google.enterprise.connector.spi

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


  // TODO: Extract the common logic out into a shared utility method.
  @Override
  public InputStream getContent(String docid) throws RepositoryException {
    try {
      int objid = getObjectId(docid);
      Document doc = getMetaData(docid);

      // TODO: There are subtle differences between how content
      // is handled here and how it is handled in the TraversalManager.
      // For instance, skipping content based upon MimeType or document size
      // is not done here because we don't have access to a TraversalContext.
View Full Code Here


      return null;
  }

  private void processResultSet(LivelinkDocumentList docList)
      throws RepositoryException {
    Document doc = null;
    while ((doc = docList.nextDocument()) != null) {
      System.out.println();
      for (String name : doc.getPropertyNames()) {
        Value value = doc.findProperty(name).nextValue();
        String printableValue;
        if (value instanceof BinaryValue) {
          try {
            InputStream in = ((BinaryValue) value).getInputStream();
            byte[] buffer = new byte[32];
View Full Code Here

    // 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));
View Full Code Here

   * Process a resultset and check for any results older than the
   * given date.
   */
  private void assertNoResultsOlderThan(LivelinkDocumentList docList,
      Date date) throws RepositoryException {
    Document doc = null;
    while ((doc = docList.nextDocument()) != null) {
      String docId = doc.findProperty("ID").nextValue().toString();
      String dateStr =
          doc.findProperty("ModifyDate").nextValue().toString();

      // Check that the modify date is new enough
      try {
        Date docDate = parseDate(dateStr);
        assertFalse("Document is older than " +
            defaultDateFormat.format(date) +
            ". (Id="+ docId + "; Name=\"" +
            doc.findProperty("Name").nextValue().toString() +
            "\"; Mod Date=" + defaultDateFormat.format(docDate) + ")",
            docDate.before(date));
        boolean verbose = false;
        if ( verbose ) {
          System.out.println("Examining:(Id="+ docId +
              "; Name=\"" +
              doc.findProperty("Name").nextValue().toString() +
              "\"; Mod Date=" + defaultDateFormat.format(docDate) +
              ")");
        }
      }
      catch (ParseException e) {
View Full Code Here

    }
  }

  private void assertNoDuplicates(LivelinkDocumentList docList,
      Set<String> nodes) throws RepositoryException {
    Document doc = null;
    while ((doc = docList.nextDocument()) != null) {
      Property prop = doc.findProperty(SpiConstants.PROPNAME_DOCID);
      String value = prop.nextValue().toString();
      assertTrue(value, nodes.add(value));
    }
  }
View Full Code Here

    if (docList == null) {
      System.out.println("No results.");
      return;
    }

    Document doc;
    while ((doc = docList.nextDocument()) != null) {
      System.out.println();
      for (String name : doc.getPropertyNames()) {
        Property prop = doc.findProperty(name);
        Value value;
        while ((value = prop.nextValue()) != null) {
          String printableValue;
          if (value instanceof BinaryValue) {
            try {
View Full Code Here

  public void testStartTraversal() throws RepositoryException {
    TraversalManager trav = session.getTraversalManager();
    trav.setBatchHint(500);
    DocumentList docList = trav.startTraversal();
    assertNotNull(docList);
    Document doc = docList.nextDocument();
    assertNotNull(doc);
    while (doc != null) {
      Property propDocId = doc.findProperty(SpiConstants.PROPNAME_DOCID);
      assertNotNull(propDocId);
      assertTrue(propDocId.nextValue().toString().contains("social"));
      doc = docList.nextDocument();
    }
  }
View Full Code Here

    retriever.setTraversalContext(TRAVERSAL_CONTEXT);
  }

  public void testGetMetaDataNonExistentPath() throws Exception {
    try {
      Document document = retriever.getMetaData("/nonexistent/test.txt");
      fail("Expected UnknownFileSystemException, but got none.");
    } catch (UnknownFileSystemException expected) {
      // Expected exception.
    }
  }
View Full Code Here

    }
  }

  public void testGetMetaDataNonExistentFile() throws Exception {
    try {
      Document document = retriever.getMetaData("/root/nonexistent.txt");
      fail("Expected RepositoryDocumentException, but got none.");
    } catch (RepositoryDocumentException expected) {
      // Expected exception.
    }
  }
View Full Code Here

  }

  public void testGetMetaDataUnreadableFile() throws Exception {
    testFile.setCanRead(false);
    try {
      Document document = retriever.getMetaData(testFileName);
      fail("Expected RepositoryDocumentException, but got none.");
    } catch (RepositoryDocumentException expected) {
      // Expected exception.
    }
  }
View Full Code Here

TOP

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

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.