本文整理了Java中javax.jcr.Node.hasProperty()
方法的一些代码示例,展示了Node.hasProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.hasProperty()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称: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
/**
* 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: 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/magnolia-core
/**
* Updates existing property or creates a new one if it doesn't exist already.
*/
public static void updateOrCreate(Node node, String string, GregorianCalendar gregorianCalendar) throws RepositoryException {
if (node.hasProperty(string)) {
node.getProperty(string).setValue(gregorianCalendar);
} else {
node.setProperty(string, gregorianCalendar);
}
}
代码示例来源:origin: org.openl.rules/org.openl.rules.repository.jcr
protected void updateVersion(Node node) throws RepositoryException {
if (node.hasProperty(ArtefactProperties.PROP_VERSION)) {
long l = ((MAX_MM_INT & 0x7FFF) << 16) | (MAX_MM_INT & 0x7FFF);
node.setProperty(ArtefactProperties.PROP_VERSION, l);
}
node.setProperty(ArtefactProperties.PROP_REVISION, version.getRevision());
}
代码示例来源:origin: info.magnolia/magnolia-module-standard-templating-kit
protected void setDefaultHideInNavValueIfNotExisting() {
try {
if (!content.hasProperty(HIDE_IN_NAV_PROPERTY_NAME)) {
content.setProperty(HIDE_IN_NAV_PROPERTY_NAME, HIDE_IN_NAV_DEFAULT_VALUE);
content.getSession().save();
}
} catch (RepositoryException e) {
log.error("Unable to create property 'hideInNav' with value '{}' on node {}", new Object[]{HIDE_IN_NAV_DEFAULT_VALUE, JcrUtils.toString(content)});
log.error(e.getMessage(), e);
}
}
代码示例来源:origin: info.magnolia.categorization/magnolia-categorization
@Override
public void visit(Node node) throws RepositoryException {
if (node.hasProperty(CategorizationTemplatingFunctions.PROPERTY_NAME_CATEGORIES)) {
node.getProperty(CategorizationTemplatingFunctions.PROPERTY_NAME_CATEGORIES).remove();
node.getSession().save();
}
}
});
代码示例来源:origin: apache/jackrabbit
protected void setUp() throws Exception {
super.setUp();
testNode = testRootNode.addNode(nodeName1, testNodeType);
testRootNode.getSession().save();
// special case for repositories that do allow binary property
// values, but only on jcr:content/jcr:data
if (propertyName1.equals("jcr:data") && testNode.hasNode("jcr:content")
&& testNode.getNode("jcr:content").isNodeType("nt:resource") && ! testNode.hasProperty("jcr:data")) {
testNode = testNode.getNode("jcr:content");
}
}
代码示例来源:origin: apache/jackrabbit
public void testNewProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
Property p = testRootNode.setProperty(propertyName1, testValue);
testRootNode.refresh(false);
try {
p.getString();
fail("Refresh 'false' must invalidate a new child property");
} catch (InvalidItemStateException e) {
// ok
}
assertFalse("Refresh 'false' must remove a new child property", testRootNode.hasProperty(propertyName1));
}
代码示例来源: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: info.magnolia/magnolia-core
/**
* Returns the latest activated version name or null if the version name isn't set.
*/
public static String getLastActivatedVersion(Node node) throws RepositoryException {
return node.hasProperty(LAST_ACTIVATED_VERSION) ? node.getProperty(LAST_ACTIVATED_VERSION).getString() : null;
}
代码示例来源:origin: org.onehippo.cms7.essentials/hippo-essentials-clone-component
private void setProperty(final Node newNode, final Node cloneNode, final String propertyName) throws RepositoryException {
if (cloneNode.hasProperty(propertyName)) {
final Property property = cloneNode.getProperty(propertyName);
newNode.setProperty(propertyName, property.getValue());
}
}
代码示例来源:origin: info.magnolia/magnolia-4-5-migration
/**
* Corrects wrong template category.
*/
private void setCorrectFeatureCategory(Node templateNode) throws RepositoryException {
if(getPersistentMapService().getCustomMap(PersistentMapConstant.TEMPLATE_CONTAINING_WRONG_CAT).containsKey(templateNode.getName()) && templateNode.hasProperty("category")){
templateNode.setProperty("category", "feature");
}
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr-commons
public Property addProperty(String key, Value value) throws RepositoryException {
Node parent = getOrCreateParent(key);
if (parent.hasProperty(key)) {
throw new ItemExistsException(key);
}
Property p = parent.setProperty(key, value);
treeManager.split(this, parent, p);
if (autoSave) {
p.getSession().save();
}
return p;
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testMoveAndRemovePropertyAtSource2() throws Exception {
setupMovePermissions();
allow(childNPath, privilegesFromName(PrivilegeConstants.REP_REMOVE_PROPERTIES));
testSession.move(nodePath3, siblingDestPath);
Node n = testSession.getNode(childNPath);
assertTrue(n.hasProperty(propertyName1));
n.getProperty(propertyName1).remove();
testSession.save();
}
代码示例来源:origin: apache/jackrabbit-oak
public void testJcrVersionHistoryProperty() throws Exception {
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(JcrConstants.MIX_VERSIONABLE);
superuser.save();
assertTrue(n.hasProperty(JcrConstants.JCR_VERSIONHISTORY));
}
代码示例来源:origin: apache/jackrabbit
public void testRemovedNewProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
Property p = testRootNode.setProperty(propertyName1, testValue);
p.remove();
testRootNode.refresh(false);
try {
p.getString();
fail("Refresh 'false' must not bring a removed new child property back to life.");
} catch (InvalidItemStateException e) {
// ok
}
assertFalse("Refresh 'false' must not bring a removed new child property back to life.", testRootNode.hasProperty(propertyName1));
}
代码示例来源:origin: info.magnolia.categorization/magnolia-categorization
@Override
protected void setTransformerClass(Node controlNode) throws RepositoryException {
if (controlNode.hasProperty("saveHandler")) {
String saveHandler = controlNode.getProperty("saveHandler").getString();
if (!saveHandler.equals("info.magnolia.module.categorization.controls.CategorizationSaveHandler")) {
controlNode.setProperty("transformerClass", MultiValueSubChildrenNodeTransformer.class.getName());
}
}
}
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Returns the comment set when then node was last versioned or null if no comment has been set.
*/
public static String getComment(Node node) throws RepositoryException {
return node.hasProperty(COMMENT) ? node.getProperty(COMMENT).getString() : null;
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
private static void updateCleanerToProcessor(final Node node, final String processorType) throws RepositoryException {
if (node.hasProperty(HTMLCLEANER_ID)) {
node.getProperty(HTMLCLEANER_ID).remove();
}
node.setProperty(HTMLPROCESSOR_ID, processorType);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
protected Node doExec(Node context, ErrorHandler errorHandler) throws RepositoryException {
if (context.hasProperty(name)) {
throw new ItemExistsException(String.format("Property %s already exists at %s", name, context.getPath()));
}
final Value value = PropertyUtil.createValue(newValue, context.getSession().getValueFactory());
context.setProperty(name, value);
return context;
}
};
内容来源于网络,如有侵权,请联系作者删除!