@Override public Boolean exec(Session session) throws RepositoryException { return session.itemExists(srcAbsPath); } });
/** * Check if node exists. */ private boolean isExists(String nodePath, Node parent) throws RepositoryException { if (nodePath.startsWith("/")) { return getWrappedNode().getSession().itemExists(nodePath); } return parent.hasNode(nodePath); }
/** * Return true if item exists. */ public boolean itemExists(String arg0) throws RepositoryException { return getSession().itemExists(arg0); }
@Override public Node doExec(Session session) throws Throwable { if (session.itemExists(nodePath)) { return session.getNode(nodePath); } return null; } });
@Override protected void processApp(InstallContext installContext) throws RepositoryException, TaskExecutionException { final Session session = installContext.getConfigJCRSession(); final Node appsNode = NodeUtil.createPath(session.getRootNode(), "/modules/data/apps", NodeTypes.Content.NAME); if (!session.itemExists(appsNode.getPath() + "/" + appName)) { throw new TaskExecutionException(String.format("An app named [%s] doesn't exists at [%s], cannot add folder support.", appName, appsNode.getPath())); } Node subApps = session.getNode(appsNode.getPath() + "/" + appName + "/subApps"); processBrowserSubapp(subApps); }
@Override public void doExecute(InstallContext installContext) throws RepositoryException { final Session session = installContext.getJCRSession(workspace); if (session.itemExists(path)) { Node page = session.getNode(path); page.setProperty(NodeTypes.Renderable.TEMPLATE, templateId); } else { installContext.warn("The template of page " + path + " was to be changed but it was not found."); } } }
@Override protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException { final Session configSession = installContext.getConfigJCRSession(); for (String path : this.paths) { if (configSession.itemExists(path)) { final Node resourcesNode = configSession.getNode(path); migrateNodes(resourcesNode); } else { installContext.warn(String.format(WARN_STRING, path)); } } }
@Test public void testItemExists() throws Exception { assertTrue(sessionWrapper.itemExists("/included")); assertTrue(sessionWrapper.itemExists("/included/excludeChannels")); assertFalse(sessionWrapper.itemExists("/excluded")); assertFalse(sessionWrapper.itemExists("/excluded/excludeChannels")); assertFalse(sessionWrapper.itemExists("/excluded/childOfExcluded")); assertTrue(sessionWrapper.itemExists("/unspecified")); }
@Override protected void prepareTestData(Session s) throws RepositoryException { if (s.itemExists("/test")) { s.getNode("/test").remove(); s.save(); } s.getRootNode().addNode("test", "oak:Unstructured"); s.save(); }
public void testMoveAndRemove() throws RepositoryException { Node n = moveNode.addNode(nodeName3); String nPath = n.getPath(); superuser.save(); doMove(moveNode.getPath(), destinationPath); n.remove(); superuser.save(); assertFalse(testSession.itemExists(nPath)); assertFalse(testSession.itemExists(destinationPath + "/" + nodeName3)); }
public void testOldChildPropertyPath() throws RepositoryException { for (int i = 0; i < childPaths.size(); i++) { String propPath = childPaths.get(i).toString() + "/" + jcrPrimaryType; assertFalse(superuser.itemExists(propPath)); try { superuser.getItem(propPath); fail("Moving a node must move all child items as well."); } catch (PathNotFoundException e) { // ok } } }
/** * Reverting the MOVE of a NEW-node must remove the Node from the destination. * * @throws RepositoryException */ public void testRevertRemovedFromDestination() throws RepositoryException { superuser.refresh(false); assertFalse("Reverting move of a new node must remove the node from both positions.", superuser.itemExists(destinationPath)); }
@Test public void testItemExists() throws Exception { // withdraw READ privilege to 'testUser' at 'path' deny(path, readPrivileges); allow(childNPath, readPrivileges); assertFalse(testSession.itemExists(path)); assertTrue(testSession.itemExists(childNPath)); }
@Test public void updateFrom51RegistersActivationApp() throws Exception { // GIVEN NodeUtil.createPath(session.getRootNode(), "/modules/activation", NodeTypes.ContentNode.NAME); NodeUtil.createPath(session.getRootNode(), "/modules/ui-admincentral/config/appLauncherLayout/groups/tools/apps/websiteJcrBrowser", NodeTypes.ContentNode.NAME); // WHEN executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("5.1")); // THEN assertTrue(session.itemExists("/modules/ui-admincentral/config/appLauncherLayout/groups/tools/apps/activation")); assertTrue(session.itemExists("/modules/ui-admincentral/config/appLauncherLayout/groups/tools/apps/activationMonitor")); }
@Test public void executeWithoutActivation() throws Exception { // GIVEN activation is not installed Task task = new SetupModuleRepositoriesTask(); // WHEN task.execute(installContext); // THEN assertFalse(sessionConfig.itemExists("/server/activation/subscribers/someSubscriber/subscriptions")); assertThat(installContext.getMessages().values(), hasSize(0)); }
@Test public void updateFrom51DoesNotRegisterActivationApp() throws Exception { // GIVEN // WHEN executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("5.1")); // THEN assertFalse(session.itemExists("/modules/ui-admincentral/config/appLauncherLayout/groups/tools/apps/activation")); }
/** * JCR-3014 Identifier paths for inexistent items throw exception * * @see <a href="https://issues.apache.org/jira/browse/JCR-3014">JCR-3014</a> */ public void testCheckNonExistingItem() throws Exception { String dummyPath = "[" + NodeId.randomId() + "]"; assertFalse(superuser.itemExists(dummyPath)); assertFalse(superuser.nodeExists(dummyPath)); }
@Test public void updateFrom521AddsEmptyItemTypesInToParamsOfActivateAction() throws Exception { // GIVEN this.setupConfigNode("/modules/ui-admincentral/apps/configuration/subApps/browser/actions/activate"); // WHEN executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("5.2.1")); // THEN assertTrue(session.itemExists("/modules/ui-admincentral/apps/configuration/subApps/browser/actions/activate/params/itemTypes")); assertEquals("", session.getProperty("/modules/ui-admincentral/apps/configuration/subApps/browser/actions/activate/params/itemTypes").getString()); }
@Test public void updateFrom521RemovesICEPushMimeMapping() throws Exception { // GIVEN this.setupConfigNode("/server/MIMEMapping/icepush"); // WHEN executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("5.2.1")); // THEN assertFalse("ICEPush MIMEMapping is gone", session.itemExists("/server/MIMEMapping/icepush")); }
public void testRemoveDestParent() throws RepositoryException { String srcPath = moveNode.getPath(); testRootNode.getSession().move(srcPath, destinationPath); destParentNode.remove(); assertFalse(destParentNode.isNew()); assertFalse(destParentNode.isModified()); assertFalse(moveNode.isModified()); assertTrue(srcParentNode.isModified()); assertFalse(testRootNode.getSession().itemExists(srcPath)); }