Package com.google.enterprise.connector.spi

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


  public void testAddNotPublicFileWithLegacyAcl() throws RepositoryException {
    foo.setAcl(acl);
    DocumentContext context = makeContext(true, false);
    context.getPropertyManager().setSupportsInheritedAcls(false);

    Document doc = new FileDocument(foo, context, root);
    validateNotPublic(doc);
    Property usersProperty = doc.findProperty(SpiConstants.PROPNAME_ACLUSERS);
    validateRepeatedProperty(users, usersProperty);
    Property groupsProperty = doc.findProperty(SpiConstants.PROPNAME_ACLGROUPS);
    validateRepeatedProperty(groups, groupsProperty);

    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLDENYUSERS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLDENYGROUPS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLINHERITANCETYPE));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLINHERITFROM));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLINHERITFROM_DOCID));
  }
View Full Code Here


  public void testAddNotPublicFileWithIndeterminateAcl()
      throws RepositoryException {
    Collection<Principal> nothing = null;
    Acl acl = Acl.newAcl(nothing, nothing, nothing, nothing);
    foo.setAcl(acl);
    Document doc = new FileDocument(foo, makeContext(true, false), root);
    validateNotPublic(doc);
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLUSERS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLGROUPS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLDENYUSERS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLDENYGROUPS));
  }
View Full Code Here

  }

  public void testAddNotPublicFileWithPushAclsFalse()
      throws RepositoryException {
    foo.setAcl(acl);
    Document doc = new FileDocument(foo, makeContext(false, false), root);
    validateNotPublic(doc);
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLUSERS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLGROUPS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLDENYUSERS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLDENYGROUPS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLINHERITANCETYPE));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLINHERITFROM));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLINHERITFROM_DOCID));
  }
View Full Code Here

  }

  public void testAddNotPublicFileWithMarkAllDocumentsPublic()
      throws RepositoryException {
    foo.setAcl(acl);
    Document doc = new FileDocument(foo, makeContext(false, true), root);
    assertNotNull(doc.findProperty(SpiConstants.PROPNAME_ISPUBLIC));
    assertEquals(Boolean.TRUE.toString(),
        Value.getSingleValueString(doc, SpiConstants.PROPNAME_ISPUBLIC));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLUSERS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLGROUPS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLDENYUSERS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLDENYGROUPS));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLINHERITANCETYPE));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLINHERITFROM));
    assertNull(doc.findProperty(SpiConstants.PROPNAME_ACLINHERITFROM_DOCID));
  }
View Full Code Here

    assertNotNull(aclInheritFrom);
    assertEquals(inheritFrom, aclInheritFrom.nextValue().toString());
  }

  public void testToString() throws RepositoryException {
    Document doc = new FileDocument(foo, makeContext(false, true), root);
    assertTrue(doc.toString().contains(foo.getPath()));
  }
View Full Code Here

        FileIterator iter = new FileIterator(root, context,
            getIfModifiedSince(startTime), returnDirectories);

        if (returnDirectories) {
          try {         
            Document rootShareAclDoc = createRootShareAcl(root);
            if (rootShareAclDoc != null) {
              documentAcceptor.take(rootShareAclDoc);
            }
          } catch (RepositoryException e) {
            LOGGER.log(Level.WARNING,
View Full Code Here

                                    jsonObjectUtil.getJsonObject());
  }

  public void testGetDocument() throws Exception {
    DocumentHandle handle = new DBHandle(jsonDocument);
    Document doc = handle.getDocument();
    assertNotNull(doc);
    assertEquals(properties.keySet(), doc.getPropertyNames());

    for (Map.Entry<String, String>  entry : properties.entrySet()) {
      Property property = doc.findProperty(entry.getKey());
      assertNotNull(property);
      assertEquals(entry.getValue(), property.nextValue().toString());
    }
  }
View Full Code Here

   * handling is in JsonDocument at the moment, but we're
   * fundamentally testing the behavior of the document handle.
   */
  public void testDeserializedDate() throws RepositoryException {
    DocumentHandle handle = new DBHandle(jsonDocument);
    Document document = handle.getDocument();
    DocumentHandle deserialHandle = new DBHandle(handle.toString());
    Document deserialDocument = deserialHandle.getDocument();

    Value value = Value.getSingleValue(document,
        SpiConstants.PROPNAME_LASTMODIFIED);
    Value deserialValue = Value.getSingleValue(deserialDocument,
        SpiConstants.PROPNAME_LASTMODIFIED);
View Full Code Here

    DocumentSnapshot snapshot = getSnapshotUnderTest(configMap);

    DocumentHandle handle = snapshot.getUpdate(null);
    assertNotNull(handle);

    Document doc = handle.getDocument();
    assertNotNull(doc);
    Set<String> propertyNames = doc.getPropertyNames();

    String serialHandle = handle.toString();
    DocumentHandle deserialHandle =
        new DBHandleFactory().fromString(serialHandle);
    assertNotNull(deserialHandle);
    assertEquals("document ID",
        handle.getDocumentId(), deserialHandle.getDocumentId());
    assertJsonEquals("serialization not value preserving",
        serialHandle, deserialHandle.toString());

    Document recoveryDoc = deserialHandle.getDocument();
    assertNotNull(recoveryDoc);
    // This is the core assertion, that a document from a deserialized
    // handle has the same properties as the original handle from the
    // SnapshotRepository.
    assertEquals("document from deserialized handle",
        propertyNames, recoveryDoc.getPropertyNames());
    for (String propertyName : propertyNames) {
      assertPropertyEquals(propertyName, doc.findProperty(propertyName),
          recoveryDoc.findProperty(propertyName));
    }
  }
View Full Code Here

              + "\"google:displayurl\":\"http://www.sometesturl.com/test\""
              + ", \"google:lastmodified\":\"Tue, 15 Nov 1994 12:45:26 GMT\""
              + "}\r\n" + "";
      String date1 = "1970-01-01T00:00:10.000Z";
      String date2 = "Tue, 15 Nov 1994 12:45:26 GMT";
      Document document = makeDocumentFromJson(json1);

      validateProperty(document, SpiConstants.PROPNAME_LASTMODIFIED, date2);
      validateProperty(document, "jcr:lastModified", date1);
      validateProperty(document, SpiConstants.PROPNAME_CONTENT,
          "now is the time");
      validateProperty(document, SpiConstants.PROPNAME_DISPLAYURL,
          "http://www.sometesturl.com/test");

      int count = countProperties(document);
      assertEquals(5, count);
    }
    {
      String json1 =
          "{\"timestamp\":\"10\",\"docid\":\"doc1\","
              + "\"content\":\"now is the time\", "
              + "\"google:displayurl\":\"http://www.sometesturl.com/test\""
              + "}\r\n" + "";
      String date1 = "1970-01-01T00:00:10.000Z";
      Document document = makeDocumentFromJson(json1);
      validateProperty(document, SpiConstants.PROPNAME_LASTMODIFIED, date1);
      validateProperty(document, SpiConstants.PROPNAME_CONTENT,
          "now is the time");
      validateProperty(document, SpiConstants.PROPNAME_DISPLAYURL,
          "http://www.sometesturl.com/test");
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.