Package com.google.enterprise.connector.spi

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


  private Principal getAclPrincipal(Document doc, String prop, String name)
      throws RepositoryException {
    Principal aclPrincipal = null;
    PrincipalValue prValue;
    Property property = doc.findProperty(prop);
    while ((prValue = (PrincipalValue) property.nextValue()) != null) {
      if (prValue.getPrincipal().getName().equalsIgnoreCase(name)) {
        aclPrincipal = prValue.getPrincipal();
        break;
      }
    }
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

    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 {
              InputStream in = ((BinaryValue) value).getInputStream();
              byte[] buffer = new byte[32];
View Full Code Here

    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

  private void testAddNotPublicFileWithAcl(String expectedInheritFrom)
      throws RepositoryException {
    foo.setAcl(acl);
    Document doc = new FileDocument(foo, makeContext(true, false), root);
    validateNotPublic(doc);
    Property usersProperty = doc.findProperty(SpiConstants.PROPNAME_ACLUSERS);
    validateRepeatedProperty(users, usersProperty);
    Property groupsProperty = doc.findProperty(SpiConstants.PROPNAME_ACLGROUPS);
    validateRepeatedProperty(groups, groupsProperty);
    Property denyUsersProperty =
        doc.findProperty(SpiConstants.PROPNAME_ACLDENYUSERS);
    validateRepeatedProperty(denyUsers, denyUsersProperty);
    Property denyGroupsProperty =
        doc.findProperty(SpiConstants.PROPNAME_ACLDENYGROUPS);
    validateRepeatedProperty(denyGroups, denyGroupsProperty);

    Property aclInheritFrom =
        doc.findProperty(SpiConstants.PROPNAME_ACLINHERITFROM_DOCID);
    assertNotNull(aclInheritFrom);
    assertEquals(expectedInheritFrom, aclInheritFrom.nextValue().toString());
  }
View Full Code Here

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

  private void validateDirWithAcl(Document doc, Acl acl, String inheritFrom)
      throws RepositoryException {
    validateNotPublic(doc);

    Property usersProperty = doc.findProperty(SpiConstants.PROPNAME_ACLUSERS);
    validatePrincipals(acl.getUsers(), usersProperty);

    Property groupsProperty = doc.findProperty(SpiConstants.PROPNAME_ACLGROUPS);
    validatePrincipals(acl.getGroups(), groupsProperty);

    Property denyUsersProperty =
        doc.findProperty(SpiConstants.PROPNAME_ACLDENYUSERS);
    validatePrincipals(acl.getDenyUsers(), denyUsersProperty);

    Property denyGroupsProperty =
        doc.findProperty(SpiConstants.PROPNAME_ACLDENYGROUPS);
    validatePrincipals(acl.getDenyGroups(), denyGroupsProperty);

    Property aclDocumentTypeProperty =
        doc.findProperty(SpiConstants.PROPNAME_DOCUMENTTYPE);
    assertNotNull(aclDocumentTypeProperty);
    assertEquals(SpiConstants.DocumentType.ACL.toString(),
        aclDocumentTypeProperty.nextValue().toString());

    Property aclInheritanceTypeProperty =
        doc.findProperty(SpiConstants.PROPNAME_ACLINHERITANCETYPE);
    assertNotNull(aclInheritanceTypeProperty);
    assertEquals(SpiConstants.AclInheritanceType.CHILD_OVERRIDES.toString(),
        aclInheritanceTypeProperty.nextValue().toString());

    Property aclInheritFrom = doc.findProperty(
        SpiConstants.PROPNAME_ACLINHERITFROM_DOCID);
    assertNotNull(aclInheritFrom);
    assertEquals(inheritFrom, aclInheritFrom.nextValue().toString());
  }
View Full Code Here

    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

    ContentHolder holder = docBuilder.getContentHolder(rowMap,
        ImmutableList.of(primaryKeyColumn), "1");
    assertEmptyContent((InputStreamFactory) holder.getContent());

    JsonDocument blobDoc = getJsonDocument(docBuilder, rowMap);
    Property docContent = blobDoc.findProperty(SpiConstants.PROPNAME_CONTENT);
    // Document content should have null value.
    assertNull(docContent);
  }
View Full Code Here

    MockRepositoryPropertyList pl = new MockRepositoryPropertyList(jo);

    {
      MockRepositoryProperty testProp = pl.getProperty("xyzzy");
      MockJcrProperty testJCRProp = new MockJcrProperty(testProp);
      Property p = new JcrProperty(testJCRProp);
      Value v = p.nextValue();
      Assert.assertEquals("skeedle", v.toString());
    }

    {
      MockRepositoryProperty testProp = pl.getProperty("baz");
      MockJcrProperty testJCRProp = new MockJcrProperty(testProp);
      Property p = new JcrProperty(testJCRProp);
      Value v = p.nextValue();
      Assert.assertEquals("42", v.toString());
    }

    {
      MockRepositoryProperty testProp = pl.getProperty("abc");
      MockJcrProperty testJCRProp = new MockJcrProperty(testProp);
      Property p = new JcrProperty(testJCRProp);
      int counter = 0;
      Value v = null;
      while ((v = p.nextValue()) != null) {
        String res = v.toString();
        switch (counter) {
        case 0:
          Assert.assertEquals("2", res);
          break;
        case 1:
          Assert.assertEquals("3", res);
          break;
        case 2:
          Assert.assertEquals("5", res);
          break;
        case 3:
          Assert.assertEquals("7", res);
          break;
        case 4:
          Assert.assertEquals("11", res);
          break;
        }
        counter++;
      }
      Assert.assertEquals(5, counter);
    }

    {
      // TODO: date test
    }

    {
      MockRepositoryProperty testProp = pl.getProperty("ghi");
      MockJcrProperty testJCRProp = new MockJcrProperty(testProp);
      Property p = new JcrProperty(testJCRProp);
      Value v = p.nextValue();
      Assert.assertNull(v);
    }

  }
View Full Code Here

TOP

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

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.