org.apache.jackrabbit.oak.api.Tree.getProperty()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中org.apache.jackrabbit.oak.api.Tree.getProperty()方法的一些代码示例,展示了Tree.getProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tree.getProperty()方法的具体详情如下:
包路径:org.apache.jackrabbit.oak.api.Tree
类名称:Tree
方法名:getProperty

Tree.getProperty介绍

[英]Get a property state
[中]获取一个属性状态

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

private String getValue(String oakName, Type<String> type) {
  PropertyState property = definition.getProperty(checkNotNull(oakName));
  if (property != null) {
    return property.getValue(type);
  } else {
    return null;
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testGetProperty() {
  Tree a = root.getTree("/a");
  for (String propName : hiddenProps) {
    assertNull(a.getProperty(propName));
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testContentRepresentation() throws Exception {
  Tree tree = root.getTree(user.getPath());
  PropertyState property = tree.getProperty(UserConstants.REP_IMPERSONATORS);
  assertNotNull(property);
  assertEquals(ImmutableList.of(impersonator.getPrincipal().getName()), property.getValue(Type.STRINGS));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
  public void testMixedImpersonators() throws Exception {
    assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, "impersonator1", testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true)));
    importer.processReferences();

    PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS);
    assertNotNull(impersonators);
    assertEquals(ImmutableSet.of("impersonator1", testUser.getPrincipal().getName()), ImmutableSet.copyOf(impersonators.getValue(Type.STRINGS)));
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testGetProperty() {
  Tree a = root.getTree("/a");
  assertNull(a.getProperty(TreeConstants.OAK_CHILD_ORDER));
}

代码示例来源:origin: apache/jackrabbit-oak

/**
 * Returns the boolean value of the named property.
 *
 * @param name property name
 * @return property value, or {@code false} if the property does not exist
 */
protected boolean getBoolean(@NotNull String name) {
  PropertyState property = definition.getProperty(checkNotNull(name));
  return property != null && property.getValue(Type.BOOLEAN);
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void getProperty() {
  Tree tree = root.getTree("/");
  PropertyState propertyState = tree.getProperty("any");
  assertNull(propertyState);
  propertyState = tree.getProperty("a");
  assertNotNull(propertyState);
  assertFalse(propertyState.isArray());
  assertEquals(LONG, propertyState.getType());
  assertEquals(1, (long) propertyState.getValue(LONG));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testGetInstanceFromTreeCustomPriv() {
  PrivilegeBits next = PrivilegeBits.NEXT_AFTER_BUILT_INS;
  Tree tmp = Mockito.mock(Tree.class);
  when(tmp.getName()).thenReturn("tmpPrivilege");
  when(tmp.getProperty(REP_BITS)).thenReturn(next.asPropertyState(REP_BITS));
  assertEquals(next, PrivilegeBits.getInstance(tmp));
}

代码示例来源:origin: apache/jackrabbit-oak

@Nullable
public static Iterable<String> getStrings(@NotNull Tree tree, @NotNull String propertyName) {
  PropertyState property = tree.getProperty(propertyName);
  if (property == null) {
    return null;
  } else {
    return property.getValue(STRINGS);
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testJcrCreatedBy() throws Exception {
  Tree tree = TreeUtil.addChild(root.getTree("/"), "test", JcrConstants.NT_FOLDER, root.getTree(NodeTypeConstants.NODE_TYPES_PATH), "userId");
  PropertyState ps = tree.getProperty(NodeTypeConstants.JCR_CREATEDBY);
  assertNotNull(ps);
  assertEquals("userId", ps.getValue(Type.STRING));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testCanReadPropertyAceNode2() throws Exception {
  Tree aceTree = root.getTree(REPO_POLICY_PATH).getChildren().iterator().next();
  PropertyState principalProp = aceTree.getProperty(REP_PRINCIPAL_NAME);
  TreePermission tp = getTreePermission(noAccessSession, aceTree.getPath());
  assertFalse(tp.canRead(principalProp));
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@CheckForNull
public static Iterable<String> getStrings(@Nonnull Tree tree, @Nonnull String propertyName) {
  PropertyState property = tree.getProperty(propertyName);
  if (property == null) {
    return null;
  } else {
    return property.getValue(STRINGS);
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testJcrCreatedByNullUserId() throws Exception {
  Tree tree = TreeUtil.addChild(root.getTree("/"), "test", JcrConstants.NT_FOLDER, root.getTree(NodeTypeConstants.NODE_TYPES_PATH), null);
  PropertyState ps = tree.getProperty(NodeTypeConstants.JCR_CREATEDBY);
  assertNotNull(ps);
  assertEquals("", ps.getValue(Type.STRING));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testCanReadPropertyAceNode() throws Exception {
  Tree aceTree = root.getTree(REPO_POLICY_PATH).getChildren().iterator().next();
  PropertyState principalProp = aceTree.getProperty(REP_PRINCIPAL_NAME);
  TreePermission tp = getTreePermission(accessSession, aceTree.getPath());
  assertTrue(tp.canRead(principalProp));
}

代码示例来源:origin: apache/jackrabbit-oak

@NotNull
private Set<String> getImpersonatorNames(@NotNull Tree userTree) {
  Set<String> princNames = new HashSet<>();
  PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS);
  if (impersonators != null) {
    for (String v : impersonators.getValue(STRINGS)) {
      princNames.add(v);
    }
  }
  return princNames;
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testAddMemberToNonExistingMember() throws Exception {
  groupTree.setProperty(REP_MEMBERS, ImmutableList.of(unknownContentId), Type.STRINGS);
  assertTrue(importer.handlePropInfo(groupTree, createPropInfo(REP_MEMBERS, knownMemberContentId), mockPropertyDefinition(NT_REP_GROUP, true)));
  importer.processReferences();
  PropertyState members = groupTree.getProperty(REP_MEMBERS);
  assertNotNull(members);
  assertEquals(ImmutableSet.of(unknownContentId, knownMemberContentId), ImmutableSet.copyOf(members.getValue(Type.STRINGS)));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testHandleAuthorizableIdMvPropertyDef() throws Exception {
  init();
  Tree userTree = createUserTree();
  assertFalse(importer.handlePropInfo(userTree, createPropInfo(REP_AUTHORIZABLE_ID, TEST_USER_ID), mockPropertyDefinition(NT_REP_AUTHORIZABLE, true)));
  assertNull(userTree.getProperty(REP_AUTHORIZABLE_ID));
}

代码示例来源:origin: apache/jackrabbit-oak

private Iterable<String> getNSData(String name) {
  PropertyState property = nsdata.getProperty(name);
  if (property != null && property.getType() == STRINGS) {
    return property.getValue(STRINGS);
  } else {
    return emptyList();
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testReplaceExistingProperty() throws Exception {
  userTree.setProperty(REP_IMPERSONATORS, ImmutableList.of("impersonator1"), Type.STRINGS);
  assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true)));
  importer.processReferences();
  PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS);
  assertNotNull(impersonators);
  assertEquals(ImmutableList.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testHandleImpersonatorsSinglePropertyDef() throws Exception {
  init();
  Tree userTree = createUserTree();
  assertFalse(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, "impersonator1"), mockPropertyDefinition(NT_REP_USER, false)));
  assertNull(userTree.getProperty(REP_IMPERSONATORS));
}

相关文章