javax.jcr.Node.getProperty()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(144)

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

Node.getProperty介绍

[英]Returns the property at relPath relative to this node. The same reacquisition semantics apply as with #getNode(String).
[中]返回relPath处相对于this节点的属性。与#getNode(String)相同的重新获取语义也适用。

代码示例

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * Returns the name of the user that last activated the node or null if no activating user has been stored on the node.
 */
public static String getLastActivatedBy(Node node) throws RepositoryException {
  return node.hasProperty(LAST_ACTIVATED_BY) ? node.getProperty(LAST_ACTIVATED_BY).getString() : null;
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-deprecated-updater-module

@Override
  protected void leaving(Node node, int level) throws RepositoryException {
    if (node.hasProperty("hipposys:nodetype")) {
      if ("hipposys:request".equals(node.getProperty("hipposys:nodetype").getString())) {
        node.setProperty("hipposys:nodetype", "hippostdpubwf:request");
      } else if ("hippostd:publishable".equals(node.getProperty("hipposys:nodetype").getString())) {
        node.setProperty("hipposys:nodetype", "hippostdpubwf:document");
      }
    }
  } 
});

代码示例来源:origin: info.magnolia/magnolia-core

private boolean permissionExists(Node aclNode, String path) throws RepositoryException {
    NodeIterator children = aclNode.getNodes();
    while (children.hasNext()) {
      Node child = children.nextNode();
      if (child.hasProperty("path") && child.getProperty("path").getString().equals(path)) {
        return true;
      }
    }
    return false;
  }
}

代码示例来源:origin: org.onehippo.cms7.essentials.sdk/implementation

public static String getDefaultPosition(final Node editorTemplate) throws RepositoryException {
  final Node root = editorTemplate.getNode("root");
  if (root.hasProperty("wicket.extensions")) {
    final Value[] extensions = root.getProperty("wicket.extensions").getValues();
    return root.getProperty(extensions[0].getString()).getString() + ".item";
  }
  return "${cluster.id}.field";
}

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * @return the lastModification or null it it was not set in JCR.
 * @deprecated since 5.0 use {@link info.magnolia.jcr.util.NodeTypes.LastModified#getLastModified(javax.jcr.Node)}.
 */
public static Calendar getLastModification(Node node) throws PathNotFoundException, RepositoryException, ValueFormatException {
  Node meta = node.getNode(MetaData.DEFAULT_META_NODE);
  String lastMod = RepositoryConstants.NAMESPACE_PREFIX + ":" + MetaData.LAST_MODIFIED;
  return (meta.hasProperty(lastMod)) ? meta.getProperty(lastMod).getDate() : null;
}

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

@SuppressWarnings("deprecation")
public void testRestoreRemoved() throws RepositoryException {
  Node parent = versionableNode.getParent();
  String oldName = versionableNode.getName();
  Version v1 = versionableNode.checkin();
  versionableNode.remove();
  versionableNode = null;
  parent.getSession().save();
  parent.restore(v1, oldName, true);
  versionableNode = parent.getNode(oldName);
  String value = versionableNode.getProperty(propertyName1).getString();
  assertEquals("Restoring a node must set the correct property.", propertyValue2, value);
}

代码示例来源:origin: info.magnolia/magnolia-core

@Test
public void setPropertyStringStringInt() throws RepositoryException {
  // GIVEN
  Node node = MgnlContext.getJCRSession("website").getRootNode().addNode("test", MgnlNodeType.NT_CONTENT);
  assertTrue(NodeUtil.isWrappedWith(node, MgnlAuditLoggingContentDecoratorNodeWrapper.class));
  // WHEN
  node.setProperty("test", "true", PropertyType.BOOLEAN);
  // THEN
  assertEquals(PropertyType.BOOLEAN, node.getProperty("test").getType());
}

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

@Test
  public void testNodeWithCugInvalidPrincipals() throws Exception {
    doImport(getTargetPath(), XML_CHILD_WITH_CUG);

    Node cugNode = getTargetNode().getNode("child").getNode(CugConstants.REP_CUG_POLICY);
    Value[] principalNames = cugNode.getProperty(CugConstants.REP_PRINCIPAL_NAMES).getValues();
    assertPrincipalNames(ImmutableSet.of(EveryonePrincipal.NAME), principalNames);

    getImportSession().save();
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

@Test
public void testNodeFromStringAndStrings() throws Exception {
  // GIVEN
  String string1 = "/root/sub1.prop1=one";
  String string2 = "/root/sub1.prop2=two";
  // WHEN
  Node result = NodeTestUtil.createNode("root", "testWorkspace", string1, string2);
  // THEN
  assertEquals("root", result.getName());
  assertEquals("one", result.getNode("/sub1").getProperty("prop1").getString());
  assertEquals("two", result.getNode("/sub1").getProperty("prop2").getString());
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr-commons

public void removeProperty(String key) throws RepositoryException {
  Node parent = getParent(key);
  Property p = parent.getProperty(key);
  p.remove();
  treeManager.join(this, parent, p);
  if (autoSave) {
    parent.getSession().save();
  }
}

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

public void testGetTypeOfPredecessors() throws RepositoryException {
  Node node = testRootNode.addNode(nodeName1, testNodeType);
  node.addMixin(mixVersionable);
  superuser.save();
  VersionManager vMgr = superuser.getWorkspace().getVersionManager();
  vMgr.checkin(node.getPath());
  assertEquals(PropertyType.nameFromValue(PropertyType.REFERENCE),
      PropertyType.nameFromValue(node.getProperty(jcrPredecessors).getType()));
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-deprecated-updater-module

@Override
  protected void leaving(Node node, int level) throws RepositoryException {
    if (node.hasProperty("hipposys:value")
        && node.getProperty("hipposys:value").getString().equals("hippo:facetsubsearch")) {
      node.setProperty("hipposys:value", "hipposys:facetsubsearch");
    }
  }
});

代码示例来源:origin: org.onehippo.cms7.essentials/hippo-essentials-plugin-api-implementation

public static String getDefaultPosition(final Node editorTemplate) throws RepositoryException {
  final Node root = editorTemplate.getNode("root");
  if (root.hasProperty("wicket.extensions")) {
    final Value[] extensions = root.getProperty("wicket.extensions").getValues();
    return root.getProperty(extensions[0].getString()).getString() + ".item";
  }
  return "${cluster.id}.field";
}

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * Returns the name of the user that created a node.
 */
public static String getCreatedBy(Node node) throws RepositoryException {
  return node.hasProperty(CREATED_BY) ? node.getProperty(CREATED_BY).getString() : null;
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
public boolean hasNodeData(String name) throws RepositoryException {
  if (this.node.hasProperty(name)) {
    return true;
  }
  if (this.node.hasNode(name) && this.node.getNode(name).getProperty("jcr:frozenPrimaryType").getValue().getString().equals(ItemType.NT_RESOURCE)) {
    return true;
  }
  return false;
}

代码示例来源:origin: info.magnolia/magnolia-core

@Test
public void setPropertyStringValueArrayInt() throws RepositoryException {
  // GIVEN
  Node node = MgnlContext.getJCRSession("website").getRootNode().addNode("test", MgnlNodeType.NT_CONTENT);
  assertTrue(NodeUtil.isWrappedWith(node, MgnlAuditLoggingContentDecoratorNodeWrapper.class));
  Value[] values = {ValueFactoryImpl.getInstance().createValue("true")};
  // WHEN
  node.setProperty("test", values, PropertyType.BOOLEAN);
  // THEN
  assertEquals(PropertyType.BOOLEAN, node.getProperty("test").getType());
}

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

@Test
public void testCugInvalidPrincipals() throws Exception {
  Node targetNode = getTargetNode();
  targetNode.addMixin(CugConstants.MIX_REP_CUG_MIXIN);
  doImport(getTargetPath(), XML_CUG_POLICY);
  Node cugNode = targetNode.getNode(CugConstants.REP_CUG_POLICY);
  Value[] principalNames = cugNode.getProperty(CugConstants.REP_PRINCIPAL_NAMES).getValues();
  assertPrincipalNames(ImmutableSet.of(EveryonePrincipal.NAME), principalNames);
  getImportSession().save();
}

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

public void testChildInSubTree() throws Exception {
    Node frozenN1 = frozen.getNode(nodeName1);

    Node frozenN2 = frozenN1.getNode(nodeName2);
    assertEquals(NT_VERSIONEDCHILD, frozenN2.getPrimaryNodeType().getName());
    Property childVh = frozenN2.getProperty(JCR_CHILD_VERSION_HISTORY);
    assertEquals(versionManager.getVersionHistory(testRoot + '/' + nodeName1 + '/' + nodeName2).getUUID(), childVh.getString());

    Node frozenN3 = frozenN1.getNode(nodeName3);
    assertEquals(NT_FROZENNODE, frozenN3.getPrimaryNodeType().getName());
  }
}

代码示例来源:origin: info.magnolia/magnolia-4-5-migration

/**
 * Replace a Property value.
 */
public static void updatePropertyIfExist(Node node, String propertyName, String oldValue, String newValue) throws RepositoryException {
  if(node.hasProperty(propertyName) && oldValue.equals(node.getProperty(propertyName).getString())){
    node.setProperty(propertyName, newValue);
   }
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void testCreationOfFieldSubNode() throws RepositoryException, TaskExecutionException {
  // GIVEN
  // WHEN
  queryTask.execute(installContext);
  // THEN
  assertTrue(field.hasNode("field"));
  assertTrue(field.getNode("field").hasProperty("class"));
  assertEquals(LinkFieldDefinition.class.getName(), field.getNode("field").getProperty("class").getString());
}

相关文章

微信公众号

最新文章

更多