本文整理了Java中javax.jcr.Session.nodeExists()
方法的一些代码示例,展示了Session.nodeExists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.nodeExists()
方法的具体详情如下:
包路径:javax.jcr.Session
类名称:Session
方法名:nodeExists
[英]Returns true
if a node 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 Void doExec(Session configSession) throws RepositoryException {
if (!configSession.nodeExists(SECURITY_CONFIG_PATH)) {
return null;
}
Session usersSession = MgnlContext.getJCRSession(RepositoryConstants.USERS);
if (usersSession.nodeExists(SYSTEM_SUPERUSER_PATH)) {
reload();
}
return null;
}
});
代码示例来源:origin: info.magnolia/magnolia-core
@Override
protected boolean condition(InstallContext ctx) {
try {
return ctx.getJCRSession(workspaceName).nodeExists(pathToCheck);
} catch (RepositoryException e) {
ctx.error("There was an error assessing if the node exists.", e);
return false;
}
}
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
public BucketNodeFactory(Session session, String cacheRootPath, CacheKey key, Integer cacheKeySplitDepth)
throws RepositoryException, BucketNodeFactoryException
{
this.key = key;
this.cacheKeySplitDepth = cacheKeySplitDepth;
if(!session.nodeExists(cacheRootPath)) {
throw new BucketNodeFactoryException("Cache root path " + cacheRootPath + " not found!");
}
this.cacheRoot = session.getNode(cacheRootPath);
}
代码示例来源:origin: apache/jackrabbit-oak
/** Creates an nt:file with a binary at the given path. Does not save the session. */
public static void putBinary(Session session, String ntFilePath, Binary binary) throws RepositoryException {
Node ntResource;
if (session.nodeExists(ntFilePath + "/" + JcrConstants.JCR_CONTENT)) {
ntResource = session.getNode(ntFilePath + "/" + JcrConstants.JCR_CONTENT);
} else {
Node file = session.getRootNode().addNode(ntFilePath.substring(1), JcrConstants.NT_FILE);
ntResource = file.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_RESOURCE);
}
ntResource.setProperty(JcrConstants.JCR_DATA, binary);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testNodeExists() throws Exception {
assertTrue(sessionWrapper.nodeExists("/included"));
assertFalse(sessionWrapper.nodeExists("/excluded"));
assertFalse(sessionWrapper.nodeExists("/excluded/childOfExcluded"));
assertTrue(sessionWrapper.nodeExists("/unspecified"));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void cleanInstall() throws Exception {
// GIVEN
// WHEN
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(null);
// THEN
assertTrue(usersSession.nodeExists("/system/anonymous/acl_config"));
assertTrue(usersSession.nodeExists("/system/anonymous/acl_userroles"));
assertThat(userRolesSession.nodeExists("/anonymous/acl_dam"), is(true));
assertThat(userRolesSession.nodeExists("/anonymous/acl_dms"), is(false));
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* @since oak
*/
@Test
public void testHasVersionContentNodes() throws Exception {
// version information must still be accessible
assertTrue(testSession.nodeExists(v.getPath()));
assertTrue(testSession.nodeExists(v2.getPath()));
assertTrue(testSession.nodeExists(vh.getPath()));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testExecute() throws RepositoryException, TaskExecutionException {
// GIVEN
RemoveNodeTask task = new RemoveNodeTask("name", "description", RepositoryConstants.WEBSITE, valideNodePath1);
// WHEN
task.execute(ctx);
// THEN
assertFalse("Node should have been removed", websiteSession.nodeExists(valideNodePath1));
assertTrue("Parent node should exist", websiteSession.nodeExists("/demo-project/about/subsection-articles"));
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
public BucketNodeFactory(Session session, CacheKey key, JCRHttpCacheStoreImpl.Config config) throws RepositoryException, BucketNodeFactoryException {
this.key = key;
this.cacheKeySplitDepth = config.httpcache_config_jcr_bucketdepth();
if(!session.nodeExists(config.httpcache_config_jcr_rootpath())) {
throw new BucketNodeFactoryException("Cache root path " + config.httpcache_config_jcr_rootpath() + " not found!");
}
this.cacheRoot = session.getNode(config.httpcache_config_jcr_rootpath());
}
代码示例来源:origin: info.magnolia/magnolia-core
private void checkACL(String path, long right, String permissionNodeName) throws RepositoryException {
assertTrue(userRoleSession.nodeExists("/superuser/acl_userroles"));
aclUserrolesNode = userRoleSession.getNode("/superuser/acl_userroles");
assertTrue(aclUserrolesNode.hasNode(permissionNodeName));
Node permission = aclUserrolesNode.getNode(permissionNodeName);
assertTrue(permission.hasProperty("path"));
assertEquals(path, permission.getProperty("path").getString());
assertTrue(permission.hasProperty("permissions"));
assertEquals(right, permission.getProperty("permissions").getLong());
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testExecute() throws RepositoryException, TaskExecutionException {
// GIVEN
session.getRootNode().addNode("someParent");
Task task = new CreateNodeTask("name", "/someParent", "someNode", NodeTypes.ContentNode.NAME);
// WHEN
task.execute(installContext);
// THEN
assertTrue("Node was created", session.nodeExists("/someParent/someNode"));
assertEquals("Create node 'config:/someParent/someNode'.", task.getDescription());
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testOperateOnNode() throws TaskExecutionException, RepositoryException {
// GIVEN
RemoveOpenWFEPermissionsTask task = new RemoveOpenWFEPermissionsTask("name", "description");
long childrenNumber = userRoleSession.getNode("/superuser").getNodes().getSize();
// WHEN
task.execute(installContext);
// THEN
assertFalse("ACL removed by the task", userRoleSession.nodeExists("/superuser/acl_Expressions"));
assertFalse("ACL removed by the task", userRoleSession.nodeExists("/superuser/acl_Store"));
assertEquals("Only two acl should have been removed", childrenNumber - 2, userRoleSession.getNode("/superuser").getNodes().getSize());
}
代码示例来源: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: info.magnolia/magnolia-core
@Test
public void execute() throws Exception {
// GIVEN
Task task = new CreateNodePathTask("name", "/someParent/someNode", NodeTypes.ContentNode.NAME);
// WHEN
task.execute(installContext);
// THEN
assertTrue("Node was created", session.nodeExists("/someParent/someNode"));
assertEquals("Create node path 'config:/someParent/someNode'.", task.getDescription());
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testDenyGroupAllowEveryone() throws Exception {
/*
deny READ privilege for group at 'path'
*/
deny(path, getTestGroup().getPrincipal(), readPrivileges);
/*
allow READ privilege for everyone at 'path'
*/
allow(path, EveryonePrincipal.getInstance(), readPrivileges);
assertTrue(testSession.nodeExists(path));
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testDenyGroupPathAllowEveryoneChildPath() throws Exception {
/*
deny READ privilege for group at 'path'
*/
deny(path, getTestGroup().getPrincipal(), readPrivileges);
/*
allow READ privilege for everyone at 'childNPath'
*/
allow(path, EveryonePrincipal.getInstance(), readPrivileges);
assertTrue(testSession.nodeExists(childNPath));
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testDenyGroupPathAllowUserChildPath() throws Exception {
/*
deny READ privilege for group at 'path'
*/
deny(path, getTestGroup().getPrincipal(), readPrivileges);
/*
allow READ privilege for testUser at 'childNPath'
*/
allow(path, testUser.getPrincipal(), readPrivileges);
assertTrue(testSession.nodeExists(childNPath));
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testAllowGroupPathDenyUserChildPath() throws Exception {
/*
allow READ privilege for the group at 'path'
*/
allow(path, getTestGroup().getPrincipal(), readPrivileges);
/*
deny READ privilege for testUser at 'childNPath'
*/
deny(path, testUser.getPrincipal(), readPrivileges);
assertFalse(testSession.nodeExists(childNPath));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testCreateRole() throws Exception {
// GIVEN
Session session = SessionTestUtil.createSession(RepositoryConstants.USER_ROLES, "/");
MgnlRoleManager roleManager = createMgnlRoleManager(session);
// WHEN
Role role = roleManager.createRole("roleName");
// THEN
assertNotNull(role);
assertEquals("roleName", role.getName());
assertTrue(session.nodeExists("/roleName"));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testCreateGroup() throws Exception {
// GIVEN
Session session = SessionTestUtil.createSession(RepositoryConstants.USER_GROUPS, "/");
MgnlGroupManager groupManager = createMgnlGroupManager(session);
// WHEN
Group group = groupManager.createGroup("groupName");
// THEN
assertNotNull(group);
assertEquals("groupName", group.getName());
assertTrue(session.nodeExists("/groupName"));
}
内容来源于网络,如有侵权,请联系作者删除!