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

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

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

Node.hasProperty介绍

[英]Indicates whether a property exists at relPath Returns true if a property accessible through the current Session exists at relPath and false otherwise.
[中]指示在relPath处是否存在属性,如果在relPath处存在可通过当前Session访问的属性,则返回true,否则返回false

代码示例

代码示例来源: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: 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/magnolia-core

  1. /**
  2. * Updates existing property or creates a new one if it doesn't exist already.
  3. */
  4. public static void updateOrCreate(Node node, String string, GregorianCalendar gregorianCalendar) throws RepositoryException {
  5. if (node.hasProperty(string)) {
  6. node.getProperty(string).setValue(gregorianCalendar);
  7. } else {
  8. node.setProperty(string, gregorianCalendar);
  9. }
  10. }

代码示例来源:origin: org.openl.rules/org.openl.rules.repository.jcr

  1. protected void updateVersion(Node node) throws RepositoryException {
  2. if (node.hasProperty(ArtefactProperties.PROP_VERSION)) {
  3. long l = ((MAX_MM_INT & 0x7FFF) << 16) | (MAX_MM_INT & 0x7FFF);
  4. node.setProperty(ArtefactProperties.PROP_VERSION, l);
  5. }
  6. node.setProperty(ArtefactProperties.PROP_REVISION, version.getRevision());
  7. }

代码示例来源:origin: info.magnolia/magnolia-module-standard-templating-kit

  1. protected void setDefaultHideInNavValueIfNotExisting() {
  2. try {
  3. if (!content.hasProperty(HIDE_IN_NAV_PROPERTY_NAME)) {
  4. content.setProperty(HIDE_IN_NAV_PROPERTY_NAME, HIDE_IN_NAV_DEFAULT_VALUE);
  5. content.getSession().save();
  6. }
  7. } catch (RepositoryException e) {
  8. log.error("Unable to create property 'hideInNav' with value '{}' on node {}", new Object[]{HIDE_IN_NAV_DEFAULT_VALUE, JcrUtils.toString(content)});
  9. log.error(e.getMessage(), e);
  10. }
  11. }

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

  1. @Override
  2. public void visit(Node node) throws RepositoryException {
  3. if (node.hasProperty(CategorizationTemplatingFunctions.PROPERTY_NAME_CATEGORIES)) {
  4. node.getProperty(CategorizationTemplatingFunctions.PROPERTY_NAME_CATEGORIES).remove();
  5. node.getSession().save();
  6. }
  7. }
  8. });

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

  1. protected void setUp() throws Exception {
  2. super.setUp();
  3. testNode = testRootNode.addNode(nodeName1, testNodeType);
  4. testRootNode.getSession().save();
  5. // special case for repositories that do allow binary property
  6. // values, but only on jcr:content/jcr:data
  7. if (propertyName1.equals("jcr:data") && testNode.hasNode("jcr:content")
  8. && testNode.getNode("jcr:content").isNodeType("nt:resource") && ! testNode.hasProperty("jcr:data")) {
  9. testNode = testNode.getNode("jcr:content");
  10. }
  11. }

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

  1. public void testNewProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
  2. Property p = testRootNode.setProperty(propertyName1, testValue);
  3. testRootNode.refresh(false);
  4. try {
  5. p.getString();
  6. fail("Refresh 'false' must invalidate a new child property");
  7. } catch (InvalidItemStateException e) {
  8. // ok
  9. }
  10. assertFalse("Refresh 'false' must remove a new child property", testRootNode.hasProperty(propertyName1));
  11. }

代码示例来源: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: info.magnolia/magnolia-core

  1. /**
  2. * Returns the latest activated version name or null if the version name isn't set.
  3. */
  4. public static String getLastActivatedVersion(Node node) throws RepositoryException {
  5. return node.hasProperty(LAST_ACTIVATED_VERSION) ? node.getProperty(LAST_ACTIVATED_VERSION).getString() : null;
  6. }

代码示例来源:origin: org.onehippo.cms7.essentials/hippo-essentials-clone-component

  1. private void setProperty(final Node newNode, final Node cloneNode, final String propertyName) throws RepositoryException {
  2. if (cloneNode.hasProperty(propertyName)) {
  3. final Property property = cloneNode.getProperty(propertyName);
  4. newNode.setProperty(propertyName, property.getValue());
  5. }
  6. }

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

  1. /**
  2. * Corrects wrong template category.
  3. */
  4. private void setCorrectFeatureCategory(Node templateNode) throws RepositoryException {
  5. if(getPersistentMapService().getCustomMap(PersistentMapConstant.TEMPLATE_CONTAINING_WRONG_CAT).containsKey(templateNode.getName()) && templateNode.hasProperty("category")){
  6. templateNode.setProperty("category", "feature");
  7. }
  8. }

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

  1. public Property addProperty(String key, Value value) throws RepositoryException {
  2. Node parent = getOrCreateParent(key);
  3. if (parent.hasProperty(key)) {
  4. throw new ItemExistsException(key);
  5. }
  6. Property p = parent.setProperty(key, value);
  7. treeManager.split(this, parent, p);
  8. if (autoSave) {
  9. p.getSession().save();
  10. }
  11. return p;
  12. }

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

  1. @Test
  2. public void testMoveAndRemovePropertyAtSource2() throws Exception {
  3. setupMovePermissions();
  4. allow(childNPath, privilegesFromName(PrivilegeConstants.REP_REMOVE_PROPERTIES));
  5. testSession.move(nodePath3, siblingDestPath);
  6. Node n = testSession.getNode(childNPath);
  7. assertTrue(n.hasProperty(propertyName1));
  8. n.getProperty(propertyName1).remove();
  9. testSession.save();
  10. }

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

  1. public void testJcrVersionHistoryProperty() throws Exception {
  2. Node n = testRootNode.addNode(nodeName1, testNodeType);
  3. n.addMixin(JcrConstants.MIX_VERSIONABLE);
  4. superuser.save();
  5. assertTrue(n.hasProperty(JcrConstants.JCR_VERSIONHISTORY));
  6. }

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

  1. public void testRemovedNewProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
  2. Property p = testRootNode.setProperty(propertyName1, testValue);
  3. p.remove();
  4. testRootNode.refresh(false);
  5. try {
  6. p.getString();
  7. fail("Refresh 'false' must not bring a removed new child property back to life.");
  8. } catch (InvalidItemStateException e) {
  9. // ok
  10. }
  11. assertFalse("Refresh 'false' must not bring a removed new child property back to life.", testRootNode.hasProperty(propertyName1));
  12. }

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

  1. @Override
  2. protected void setTransformerClass(Node controlNode) throws RepositoryException {
  3. if (controlNode.hasProperty("saveHandler")) {
  4. String saveHandler = controlNode.getProperty("saveHandler").getString();
  5. if (!saveHandler.equals("info.magnolia.module.categorization.controls.CategorizationSaveHandler")) {
  6. controlNode.setProperty("transformerClass", MultiValueSubChildrenNodeTransformer.class.getName());
  7. }
  8. }
  9. }
  10. }

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

  1. /**
  2. * Returns the comment set when then node was last versioned or null if no comment has been set.
  3. */
  4. public static String getComment(Node node) throws RepositoryException {
  5. return node.hasProperty(COMMENT) ? node.getProperty(COMMENT).getString() : null;
  6. }

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

  1. private static void updateCleanerToProcessor(final Node node, final String processorType) throws RepositoryException {
  2. if (node.hasProperty(HTMLCLEANER_ID)) {
  3. node.getProperty(HTMLCLEANER_ID).remove();
  4. }
  5. node.setProperty(HTMLPROCESSOR_ID, processorType);
  6. }

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

  1. @Override
  2. protected Node doExec(Node context, ErrorHandler errorHandler) throws RepositoryException {
  3. if (context.hasProperty(name)) {
  4. throw new ItemExistsException(String.format("Property %s already exists at %s", name, context.getPath()));
  5. }
  6. final Value value = PropertyUtil.createValue(newValue, context.getSession().getValueFactory());
  7. context.setProperty(name, value);
  8. return context;
  9. }
  10. };

相关文章