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

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

本文整理了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

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

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

  1. @Override
  2. protected void leaving(Node node, int level) throws RepositoryException {
  3. if (node.hasProperty("hipposys:nodetype")) {
  4. if ("hipposys:request".equals(node.getProperty("hipposys:nodetype").getString())) {
  5. node.setProperty("hipposys:nodetype", "hippostdpubwf:request");
  6. } else if ("hippostd:publishable".equals(node.getProperty("hipposys:nodetype").getString())) {
  7. node.setProperty("hipposys:nodetype", "hippostdpubwf:document");
  8. }
  9. }
  10. }
  11. });

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

  1. private boolean permissionExists(Node aclNode, String path) throws RepositoryException {
  2. NodeIterator children = aclNode.getNodes();
  3. while (children.hasNext()) {
  4. Node child = children.nextNode();
  5. if (child.hasProperty("path") && child.getProperty("path").getString().equals(path)) {
  6. return true;
  7. }
  8. }
  9. return false;
  10. }
  11. }

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

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

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

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

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

  1. @SuppressWarnings("deprecation")
  2. public void testRestoreRemoved() throws RepositoryException {
  3. Node parent = versionableNode.getParent();
  4. String oldName = versionableNode.getName();
  5. Version v1 = versionableNode.checkin();
  6. versionableNode.remove();
  7. versionableNode = null;
  8. parent.getSession().save();
  9. parent.restore(v1, oldName, true);
  10. versionableNode = parent.getNode(oldName);
  11. String value = versionableNode.getProperty(propertyName1).getString();
  12. assertEquals("Restoring a node must set the correct property.", propertyValue2, value);
  13. }

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

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

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

  1. @Test
  2. public void testNodeWithCugInvalidPrincipals() throws Exception {
  3. doImport(getTargetPath(), XML_CHILD_WITH_CUG);
  4. Node cugNode = getTargetNode().getNode("child").getNode(CugConstants.REP_CUG_POLICY);
  5. Value[] principalNames = cugNode.getProperty(CugConstants.REP_PRINCIPAL_NAMES).getValues();
  6. assertPrincipalNames(ImmutableSet.of(EveryonePrincipal.NAME), principalNames);
  7. getImportSession().save();
  8. }
  9. }

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

  1. @Test
  2. public void testNodeFromStringAndStrings() throws Exception {
  3. // GIVEN
  4. String string1 = "/root/sub1.prop1=one";
  5. String string2 = "/root/sub1.prop2=two";
  6. // WHEN
  7. Node result = NodeTestUtil.createNode("root", "testWorkspace", string1, string2);
  8. // THEN
  9. assertEquals("root", result.getName());
  10. assertEquals("one", result.getNode("/sub1").getProperty("prop1").getString());
  11. assertEquals("two", result.getNode("/sub1").getProperty("prop2").getString());
  12. }

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

  1. public void removeProperty(String key) throws RepositoryException {
  2. Node parent = getParent(key);
  3. Property p = parent.getProperty(key);
  4. p.remove();
  5. treeManager.join(this, parent, p);
  6. if (autoSave) {
  7. parent.getSession().save();
  8. }
  9. }

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

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

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

  1. @Override
  2. protected void leaving(Node node, int level) throws RepositoryException {
  3. if (node.hasProperty("hipposys:value")
  4. && node.getProperty("hipposys:value").getString().equals("hippo:facetsubsearch")) {
  5. node.setProperty("hipposys:value", "hipposys:facetsubsearch");
  6. }
  7. }
  8. });

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

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

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

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

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

  1. @Override
  2. public boolean hasNodeData(String name) throws RepositoryException {
  3. if (this.node.hasProperty(name)) {
  4. return true;
  5. }
  6. if (this.node.hasNode(name) && this.node.getNode(name).getProperty("jcr:frozenPrimaryType").getValue().getString().equals(ItemType.NT_RESOURCE)) {
  7. return true;
  8. }
  9. return false;
  10. }

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

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

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

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

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

  1. public void testChildInSubTree() throws Exception {
  2. Node frozenN1 = frozen.getNode(nodeName1);
  3. Node frozenN2 = frozenN1.getNode(nodeName2);
  4. assertEquals(NT_VERSIONEDCHILD, frozenN2.getPrimaryNodeType().getName());
  5. Property childVh = frozenN2.getProperty(JCR_CHILD_VERSION_HISTORY);
  6. assertEquals(versionManager.getVersionHistory(testRoot + '/' + nodeName1 + '/' + nodeName2).getUUID(), childVh.getString());
  7. Node frozenN3 = frozenN1.getNode(nodeName3);
  8. assertEquals(NT_FROZENNODE, frozenN3.getPrimaryNodeType().getName());
  9. }
  10. }

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

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

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

  1. @Test
  2. public void testCreationOfFieldSubNode() throws RepositoryException, TaskExecutionException {
  3. // GIVEN
  4. // WHEN
  5. queryTask.execute(installContext);
  6. // THEN
  7. assertTrue(field.hasNode("field"));
  8. assertTrue(field.getNode("field").hasProperty("class"));
  9. assertEquals(LinkFieldDefinition.class.getName(), field.getNode("field").getProperty("class").getString());
  10. }

相关文章