本文整理了Java中javax.jcr.Session.propertyExists()
方法的一些代码示例,展示了Session.propertyExists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.propertyExists()
方法的具体详情如下:
包路径:javax.jcr.Session
类名称:Session
方法名:propertyExists
[英]Returns true
if a property exists at absPath
and this Session
has read access to it; otherwise returns false
.
[中]如果absPath
上存在某个属性,并且该Session
具有对该属性的读取权限,则返回true
;否则返回false
。
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public boolean propertyExists(String absPath) throws RepositoryException {
return getWrappedSession().propertyExists(absPath);
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
@Override
default boolean propertyExists(final String absPath) throws RepositoryException {
return unwrapSession().propertyExists(absPath);
}
代码示例来源:origin: io.wcm/io.wcm.testing.jcr-mock
@Override
public boolean hasProperty(final String relPath) throws RepositoryException {
String path = makeAbsolutePath(relPath);
return getSession().propertyExists(path);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testPropertyExists() throws Exception {
assertTrue(sessionWrapper.propertyExists("/included/excludeChannels"));
assertFalse(sessionWrapper.propertyExists("/excluded/excludeChannels"));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testDoNotOverride() throws Exception {
// GIVEN
sessionConfig.getRootNode().addNode("someSrcNode").setProperty("someProperty", "somePropertyValue");
sessionConfig.getRootNode().addNode("someDestNode").setProperty("someProperty", "someOldValue");
Task task = new MovePropertyTask("name", RepositoryConstants.CONFIG, "/someSrcNode/someProperty", "/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
@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
@Test
public void testOverride() throws Exception {
// GIVEN
sessionConfig.getRootNode().addNode("someSrcNode").setProperty("someProperty", "somePropertyValue");
sessionConfig.getRootNode().addNode("someDestNode").setProperty("someProperty", "someOldValue");
Task task = new MovePropertyTask("name", RepositoryConstants.CONFIG, "/someSrcNode/someProperty", "/someDestNode/someProperty", true);
// WHEN
task.execute(installContext);
// THEN
assertFalse(sessionConfig.propertyExists("/someSrcNode/someProperty"));
assertTrue(sessionConfig.propertyExists("/someDestNode/someProperty"));
assertEquals("somePropertyValue", sessionConfig.getProperty("/someDestNode/someProperty").getString());
assertEquals("Move property 'config:/someSrcNode/someProperty' to 'config:/someDestNode/someProperty'.", task.getDescription());
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testExecute() throws RepositoryException, TaskExecutionException {
// GIVEN
ModuleFilesExtraction task = new ModuleFilesExtraction();
// WHEN
task.execute(ctx);
// THEN
assertTrue(new File("docroot/moduleName/avatar.jpg").exists());
assertTrue(session.propertyExists("/server/install/mgnl-files/docroot/moduleName/avatar.jpg/md5"));
assertEquals("f4b00bf28d5e67083a9721f8fbae6278", session.getProperty("/server/install/mgnl-files/docroot/moduleName/avatar.jpg/md5").getString());
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testExecute() throws RepositoryException, TaskExecutionException {
// GIVEN
NodeUtil.createPath(websiteSession.getRootNode(), "/someNode", NodeTypes.ContentNode.NAME).setProperty("oldName", "someValue");
Task task = new RenamePropertyTask("name", RepositoryConstants.WEBSITE, "/someNode", "oldName", "newName", false);
// WHEN
task.execute(ctx);
// THEN
assertFalse("Property should have been renamed", websiteSession.propertyExists("/someNode/oldName"));
assertTrue("Property should have been renamed", websiteSession.propertyExists("/someNode/newName"));
assertEquals("Rename property 'website:/someNode/oldName' to 'newName'.", task.getDescription());
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testPropertyExists() throws Exception {
assertTrue(superuser.propertyExists(p.getPath()));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testExecute() throws RepositoryException, TaskExecutionException {
// GIVEN
Property property1 = NodeUtil.createPath(websiteSession.getRootNode(), "/demo-project/about/subsection-articles/article", NodeTypes.ContentNode.NAME).setProperty("someProperty", "someValue");
String property1Path = property1.getPath();
List<String> pathsToRemove = Arrays.asList(property1Path, "/nonexistingPath");
Task task = new RemovePropertiesTask("name", RepositoryConstants.WEBSITE, pathsToRemove, true);
// WHEN
task.execute(ctx);
// THEN
assertFalse("Property should have been removed", websiteSession.propertyExists(property1Path));
assertEquals("Remove properties: '[/demo-project/about/subsection-articles/article/someProperty, /nonexistingPath]' from 'website' workspace.", task.getDescription());
}
}
代码示例来源:origin: apache/jackrabbit-oak
public void testCombination() throws RepositoryException {
Privilege[] readPrivs = AccessControlUtils.privilegesFromNames(superuser, Privilege.JCR_READ);
AccessControlUtils.addAccessControlEntry(superuser, testRoot, testPrincipal, readPrivs, false);
AccessControlUtils.addAccessControlEntry(superuser, childPath, testGroupPrincipal, readPrivs, true);
superuser.save();
// EXERCISE what is the expected result?
testSession.refresh(false);
Boolean canRead = null; // EXERCISE
assertEquals(canRead.booleanValue(), testSession.nodeExists(testRoot));
assertEquals(canRead.booleanValue(), testSession.propertyExists(propertyPath));
assertEquals(canRead.booleanValue(), testSession.nodeExists(childPath));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testExecute() throws RepositoryException, TaskExecutionException {
// GIVEN
Property property1 = NodeUtil.createPath(session.getRootNode(), "/demo-project/about/subsection-articles/article", NodeTypes.ContentNode.NAME).setProperty("someProperty", "someValue");
Task task = new RemovePropertyTask("name", property1.getParent().getPath(), "someProperty");
// WHEN
task.execute(ctx);
// THEN
assertFalse("Property should have been removed", session.propertyExists("/demo-project/about/subsection-articles/article/someProperty"));
assertEquals("Remove property 'config:/demo-project/about/subsection-articles/article/someProperty'.", task.getDescription());
}
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility
@Test
public void testUpdateFrom50() throws ModuleManagementException, RepositoryException {
// GIVEN
this.setupConfigNode("/modules/ui-framework/dialogs/importZip/form/tabs/import/fields/encoding/options/utf-8/");
this.setupConfigNode("/modules/ui-framework/dialogs/importZip/form/tabs/import/fields/encoding/options/windows/");
// WHEN
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("5.0"));
// THEN
assertTrue(session.nodeExists("/modules/ui-framework/commands/default/importZip"));
assertTrue(session.propertyExists("/modules/ui-framework/dialogs/importZip/form/tabs/import/fields/encoding/options/utf-8/label"));
assertTrue(session.propertyExists("/modules/ui-framework/dialogs/importZip/form/tabs/import/fields/encoding/options/windows/label"));
}
代码示例来源:origin: apache/jackrabbit-oak
public void testHierarchy() throws RepositoryException {
assertFalse(testSession.nodeExists(testRoot));
assertFalse(testSession.nodeExists(childPath));
assertFalse(testSession.propertyExists(propertyPath));
Principal principal = testPrincipal;
// EXERCISE : create the correct permission setup such that the test session can read all items below.
// EXERCISE : how many entries do you need to create?
superuser.save();
testSession.refresh(false);
assertTrue(testSession.nodeExists(testRoot));
assertTrue(testSession.nodeExists(childPath));
assertTrue(testSession.propertyExists(propertyPath));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void execute() throws Exception {
// GIVEN
setUpActivation();
Task task = new SetupModuleRepositoriesTask();
// WHEN
task.execute(installContext);
// THEN
assertTrue(sessionConfig.itemExists("/server/activation/subscribers/someSubscriber/subscriptions"));
assertTrue(sessionConfig.propertyExists("/server/activation/subscribers/someSubscriber/subscriptions/config/repository"));
assertEquals(RepositoryConstants.CONFIG, sessionConfig.getProperty("/server/activation/subscribers/someSubscriber/subscriptions/config/repository").getString());
assertThat(installContext.getMessages().values(), hasSize(0));
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testReadAccessControlContent() throws Exception {
// test access to ac content if the corresponding access controlled
// parent node is not accessible.
allow(path, privilegesFromName(Privilege.JCR_READ_ACCESS_CONTROL));
deny(path, privilegesFromName(Privilege.JCR_READ));
// the policy node however must be visible to the test-user
assertTrue(testSession.nodeExists(path + "/rep:policy"));
assertTrue(testSession.propertyExists(path + "/rep:policy/jcr:primaryType"));
assertFalse(testSession.nodeExists(path));
assertFalse(testSession.propertyExists(path + "/jcr:primaryType"));
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testGlobRestriction6() throws Exception {
Privilege[] readPrivs = privilegesFromName(Privilege.JCR_READ);
allow(path, readPrivs);
deny(path, readPrivs, createGlobRestriction("/*"));
assertTrue(testSession.nodeExists(path));
assertFalse(testSession.propertyExists(path + '/' + JcrConstants.JCR_PRIMARYTYPE));
assertFalse(testSession.nodeExists(childNPath));
assertFalse(testSession.propertyExists(childPPath));
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testGlobRestriction6() throws Exception {
Privilege[] readPrivs = privilegesFromName(Privilege.JCR_READ);
allow(path, readPrivs);
deny(path, readPrivs, createGlobRestriction("/*"));
assertTrue(testSession.nodeExists(path));
assertFalse(testSession.propertyExists(path + '/' + JcrConstants.JCR_PRIMARYTYPE));
assertFalse(testSession.nodeExists(childNPath));
assertFalse(testSession.propertyExists(childPPath));
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* @see <a href="https://issues.apache.org/jira/browse/OAK-2441">OAK-2441</a>
*/
public void testNodeGetPrimaryType() throws Exception {
deny(path, privilegesFromName(PrivilegeConstants.REP_READ_PROPERTIES));
assertFalse(testSession.propertyExists(path + '/' + JcrConstants.JCR_PRIMARYTYPE));
Node n = testSession.getNode(path);
assertFalse(n.hasProperty(JcrConstants.JCR_PRIMARYTYPE));
NodeType primary = n.getPrimaryNodeType();
assertEquals(superuser.getNode(path).getPrimaryNodeType().getName(), primary.getName());
}
内容来源于网络,如有侵权,请联系作者删除!