@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; } });
@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; } } }
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); }
/** 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); }
@Test public void testNodeExists() throws Exception { assertTrue(sessionWrapper.nodeExists("/included")); assertFalse(sessionWrapper.nodeExists("/excluded")); assertFalse(sessionWrapper.nodeExists("/excluded/childOfExcluded")); assertTrue(sessionWrapper.nodeExists("/unspecified")); }
@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)); }
/** * @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())); }
@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")); }
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()); }
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()); } }
@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()); } }
@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()); }
@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)); }
@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()); } }
@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)); }
@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)); }
@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)); }
@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)); }
@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")); }
@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")); }