本文整理了Java中javax.jcr.Property.getString()
方法的一些代码示例,展示了Property.getString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property.getString()
方法的具体详情如下:
包路径:javax.jcr.Property
类名称:Property
方法名:getString
[英]Returns a String
representation of the value of this property. A shortcut for Property.getValue().getString()
.
[中]返回此属性值的String
表示形式。Property.getValue().getString()
的快捷方式。
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public String getNodeTypeName() throws RepositoryException {
if (this.node.hasProperty(ItemType.JCR_FROZEN_PRIMARY_TYPE)) {
return this.node.getProperty(ItemType.JCR_FROZEN_PRIMARY_TYPE).getString();
}
return this.node.getProperty(ItemType.JCR_PRIMARY_TYPE).getString();
}
代码示例来源: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: apache/jackrabbit-oak
Node defineStandardPropertyIndex(Session session) throws Exception {
Node index = new OakIndexUtils.PropertyIndex().property(INDEXED_PROPERTY).create(session);
if (index == null) {
throw new RuntimeException(
"Error while creating the index definition. index node is null.");
}
if (!PropertyIndexEditorProvider.TYPE.equals(index.getProperty(
IndexConstants.TYPE_PROPERTY_NAME).getString())) {
throw new RuntimeException("The type of the index does not match the expected");
}
session.save();
return index;
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testSetCreation() throws RepositoryException {
// GIVEN
final String userName = "Junit";
// WHEN
NodeTypes.Created.set(first, userName, Calendar.getInstance());
// THEN
assertTrue("Created should just have been set", (Calendar.getInstance().getTimeInMillis() - first.getProperty(NodeTypes.Created.CREATED).getDate().getTimeInMillis()) < 1000);
assertEquals(first.getProperty(NodeTypes.Created.CREATED).getString(), first.getProperty(NodeTypes.LastModified.LAST_MODIFIED).getString());
assertEquals(userName, first.getProperty(NodeTypes.Created.CREATED_BY).getString());
assertEquals(userName, first.getProperty(NodeTypes.LastModified.LAST_MODIFIED_BY).getString());
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testCreatingAnExistingNodeDataDoesNotFail() throws Exception {
Node content = getTestNode();
Property nodeData = content.setProperty("nd1", "other");
assertEquals("other", nodeData.getString());
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testChangePassword() throws RepositoryException, NotExecutableException {
try {
String hash = getNode(user, superuser).getProperty(UserConstants.REP_PASSWORD).getString();
user.changePassword("changed");
superuser.save();
assertFalse(hash.equals(getNode(user, superuser).getProperty(UserConstants.REP_PASSWORD).getString()));
} catch (Exception e) {
// success
}
}
代码示例来源:origin: org.chromattic/chromattic.core
public void testRemoveWithInvalidArg() throws Exception {
cNode.setProperty("foo", "foo_value");
Map<String, Object> props = c.getProperties();
props.remove("foo");
assertEquals("foo_value", cNode.getProperty("foo").getString());
}
代码示例来源:origin: apache/jackrabbit
/**
* Test the persistence of a property modified with a String parameter and
* saved from the Session Requires a single-value String (PROP_VALUE_2)
*/
public void testStringSession() throws RepositoryException {
property1.setValue(PROP_VALUE_2);
superuser.save();
assertEquals("String node property not saved", PROP_VALUE_2, property1.getString());
}
代码示例来源: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
@Test
public void testDoNotUpdateLastModifiedWhenUpdateLastAccess() throws Exception {
// GIVEN
Node testUser = session.getNode("/admin/test");
String lastModify = testUser.getProperty("mgnl:lastModified").getString();
// WHEN
um.updateLastAccessTimestamp(um.newUserInstance(testUser));
// THEN
assertNotEquals(StringUtils.EMPTY, testUser.getProperty("lastaccess").getString());
assertEquals(lastModify, testUser.getProperty("mgnl:lastModified").getString());
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testSettingAnExistingNodeData() throws Exception {
Node content = getTestNode();
// this should not fail
Value value = createValue("test");
Property nodeData = content.setProperty("nd1", value);
assertEquals("test", nodeData.getString());
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testChangePasswordWithOldPassword() throws RepositoryException, NotExecutableException {
try {
String hash = getNode(user, superuser).getProperty(UserConstants.REP_PASSWORD).getString();
user.changePassword("changed", testPw);
superuser.save();
assertFalse(hash.equals(getNode(user, superuser).getProperty(UserConstants.REP_PASSWORD).getString()));
} finally {
user.changePassword(testPw);
superuser.save();
}
}
代码示例来源: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: 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: apache/jackrabbit
public void testRemovedProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
Property p = testRootNode.setProperty(propertyName1, testValue);
testRootNode.save();
p.remove();
testRootNode.refresh(false);
// Property p must be reverted to 'existing' -> getString must succeed.
p.getString();
// similarly accessing the property again must succeed.
testRootNode.getProperty(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
@Test
public void testNodeFromStringAndObjectArray() throws Exception {
// GIVEN
Object[][] data = new String[][]{{"a", "a-value"}};
// WHEN
Node result = NodeTestUtil.createNode("root", data);
// THEN
assertEquals("root", result.getName());
assertEquals("a-value", result.getProperty("a").getString());
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void doNotOverride() throws Exception {
// GIVEN
sessionConfig.getRootNode().addNode("someSrcNode").setProperty("someProperty", "somePropertyValue");
sessionConfig.getRootNode().addNode("someDestNode").setProperty("someProperty", "someOldValue");
Task task = new CopyPropertyTask("name", RepositoryConstants.CONFIG, "/someSrcNode", "/someDestNode", "someProperty", false);
// WHEN
task.execute(installContext);
// THEN
assertTrue(sessionConfig.propertyExists("/someSrcNode/someProperty"));
assertEquals("someOldValue", sessionConfig.getProperty("/someDestNode/someProperty").getString());
}
代码示例来源: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: apache/jackrabbit
public void testRestoreRemovedJcr2() throws RepositoryException {
String path = versionableNode.getPath();
Version v1 = versionManager.checkin(path);
versionableNode.remove();
versionableNode = null;
superuser.save();
versionManager.restore(path, v1, true);
versionableNode = superuser.getNode(path);
String value = versionableNode.getProperty(propertyName1).getString();
assertEquals("Restoring a node must set the correct property.", propertyValue2, value);
}
内容来源于网络,如有侵权,请联系作者删除!