javax.jcr.Session.itemExists()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中javax.jcr.Session.itemExists()方法的一些代码示例,展示了Session.itemExists()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.itemExists()方法的具体详情如下:
包路径:javax.jcr.Session
类名称:Session
方法名:itemExists

Session.itemExists介绍

[英]Returns true if an item 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 exec(Session session) throws RepositoryException {
    return session.itemExists(srcAbsPath);
  }
});

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * 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);
}

代码示例来源:origin: apache/jackrabbit

/**
 * Return true if item exists.
 */
public boolean itemExists(String arg0)
    throws RepositoryException {
  return getSession().itemExists(arg0);
}

代码示例来源:origin: info.magnolia/magnolia-module-observation

@Override
  public Node doExec(Session session) throws Throwable {
    if (session.itemExists(nodePath)) {
      return session.getNode(nodePath);
    }
    return null;
  }
});

代码示例来源:origin: info.magnolia/magnolia-module-data

@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);
}

代码示例来源:origin: info.magnolia/magnolia-core

@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.");
    }
  }
}

代码示例来源:origin: info.magnolia/magnolia-module-standard-templating-kit

@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));
    }
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

@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"));
}

代码示例来源:origin: apache/jackrabbit-oak

@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();
}

代码示例来源:origin: apache/jackrabbit

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));
}

代码示例来源:origin: apache/jackrabbit

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
    }
  }
}

代码示例来源:origin: apache/jackrabbit

/**
 * 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));
}

代码示例来源:origin: apache/jackrabbit-oak

@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));
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-admincentral

@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"));
}

代码示例来源:origin: info.magnolia/magnolia-core

@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));
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-admincentral

@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"));
}

代码示例来源:origin: apache/jackrabbit

/**
 * 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));
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-admincentral

@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());
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-admincentral

@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"));
}

代码示例来源:origin: apache/jackrabbit

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));
}

相关文章

微信公众号

最新文章

更多