本文整理了Java中javax.jcr.Session.removeItem()
方法的一些代码示例,展示了Session.removeItem()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.removeItem()
方法的具体详情如下:
包路径:javax.jcr.Session
类名称:Session
方法名:removeItem
[英]Removes the specified item and its subgraph.
This is a session-write method and therefore requires a save
in order to dispatch the change.
If a node with same-name siblings is removed, this decrements by one the indices of all the siblings with indices greater than that of the removed node. In other words, a removal compacts the array of same-name siblings and causes the minimal re-numbering required to maintain the original order but leave no gaps in the numbering.
A ReferentialIntegrityException
will be thrown on dispatch if the specified item or an item in its subgraph is currently the target of a REFERENCE
property located in this workspace but outside the specified item's subgraph and the current Session
has read access to that REFERENCE
property.
A ConstraintViolationException
will be thrown either immediately, on dispatch or on persist, if removing the specified item would violate a node type or implementation-specific constraint. Implementations may differ on when this validation is performed.
A VersionException
will be thrown either immediately, on dispatch or on persist, if the parent node of the specified item is read-only due to a checked-in node. Implementations may differ on when this validation is performed.
A LockException
will be thrown either immediately, on dispatch or on persist, if a lock prevents the removal of the specified item. Implementations may differ on when this validation is performed.
A PathNotFoundException
will be thrown either immediately, on dispatch or on persist, if no accessible item is found at at absPath
.
A AccessDeniedException
will be thrown either immediately, on dispatch or on persist, if the specified item or an item in its subgraph is currently the target of a REFERENCE
property located in this workspace but outside the specified item's subgraph and the current Session
does not have read access to that REFERENCE
property.
[中]删除指定的项及其子图。
这是一种会话写入方法,因此需要save
才能分派更改。
如果移除同名同级节点,则索引大于移除节点索引的所有同级节点的索引将递减一。换句话说,移除会压缩同名同级的数组,并导致最小的重新编号,以保持原始顺序,但不会在编号中留下任何间隙。
如果指定项或其子图中的项当前是位于此工作区中但在指定项的子图之外的REFERENCE
属性的目标,并且当前Session
具有对该REFERENCE
属性的读取权限,则调度时将抛出ReferentialIntegrityException
。
如果删除指定的项会违反节点类型或特定于实现的约束,则ConstraintViolationException
将在分派或持久化时立即抛出。执行此验证的时间可能会有所不同。
如果指定项的父节点由于签入节点而为只读,则VersionException
将在分派或持久化时立即抛出。执行此验证的时间可能会有所不同。
如果锁阻止删除指定项,则在分派或持久化时会立即抛出LockException
。执行此验证的时间可能会有所不同。
如果在[$9$]处找不到可访问的项目,则会在分派或持久化时立即抛出PathNotFoundException
。
如果指定的项或其子图中的项当前是位于此工作区中的REFERENCE
属性的目标,但位于指定项的子图之外,并且当前Session
没有对该REFERENCE
属性的读取权限,则AccessDeniedException
将在分派或持久化时立即抛出。
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
@Override
default void removeItem(final String absPath)
throws VersionException, LockException, ConstraintViolationException, AccessDeniedException,
RepositoryException {
unwrapSession().removeItem(absPath);
}
代码示例来源:origin: info.magnolia/magnolia-4-5-migration
/**
* Deletes all empty nodes collected during all template visits.
*/
private void deleteEmptyNodes(Session session) throws RepositoryException {
for(String emptyNodePath : emptyNodesPaths) {
if (session.nodeExists(emptyNodePath)) {
session.removeItem(emptyNodePath);
}
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testCanRemoveVisibleItem() throws Exception {
sessionWrapper.removeItem("/unspecified");
sessionWrapper.removeItem("/included/excludeChannels");
sessionWrapper.removeItem("/included");
}
代码示例来源:origin: apache/jackrabbit
public void testRemoveItem2() throws RepositoryException {
adminSession.removeItem(nPath);
try {
removeNode.getParent();
fail("Cannot retrieve the parent from a transiently removed item.");
} catch (InvalidItemStateException e) {
// success
}
}
代码示例来源:origin: apache/jackrabbit-oak
@After
public void tearDown() throws RepositoryException {
Session s = testNode.getSession();
s.removeItem(TEST_PATH);
s.save();
}
代码示例来源:origin: apache/jackrabbit-oak
@After
public void tearDown() throws RepositoryException {
Session s = testNode.getSession();
s.removeItem(TEST_PATH);
s.save();
}
代码示例来源:origin: Cognifide/APM
@Override
public void remove(final Script script, ResourceResolver resolver) throws RepositoryException {
scriptManager.getEventManager().trigger(Event.BEFORE_REMOVE, script);
final Session session = resolver.adaptTo(Session.class);
final String path = script.getPath();
if (path != null) {
session.removeItem(path);
session.save();
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void sequenceActionCreateSessionDelete() throws RepositoryException {
session.getRootNode().addNode("new-site");
session.removeItem("/new-site");
session.save();
assertEquals(0, audit.records.size());
}
代码示例来源:origin: apache/jackrabbit
@Override
protected void setUp() throws Exception {
super.setUp();
for (Node c : JcrUtils.getChildNodes(testRootNode)) {
testRootNode.getSession().removeItem(c.getPath());
}
testRootNode.getSession().save();
}
代码示例来源:origin: apache/jackrabbit
@Override
protected void tearDown() throws Exception {
for (Node c : JcrUtils.getChildNodes(testRootNode)) {
testRootNode.getSession().removeItem(c.getPath());
}
testRootNode.getSession().save();
super.tearDown();
}
代码示例来源:origin: apache/jackrabbit
@Override
protected void tearDown() throws Exception {
for (Node c : JcrUtils.getChildNodes(testRootNode)) {
testRootNode.getSession().removeItem(c.getPath());
}
testRootNode.getSession().save();
super.tearDown();
}
代码示例来源:origin: apache/jackrabbit
@Override
protected void tearDown() throws Exception {
for (Node c : JcrUtils.getChildNodes(testRootNode)) {
testRootNode.getSession().removeItem(c.getPath());
}
superuser.save();
super.tearDown();
}
代码示例来源:origin: apache/jackrabbit-oak
@After
public void tearDown() throws RepositoryException {
if (session != null) {
session.removeItem(TEST_PATH);
session.save();
session.logout();
}
if (repo != null) {
dispose(repo);
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void sequenceActionModifySessionDelete() throws RepositoryException {
Node node = session.getRootNode().getNode("articles");
node.setProperty("title", "test");
session.removeItem("/articles");
session.save();
assertEquals(1, audit.records.size());
assertEquals(AuditLoggingUtil.ACTION_DELETE, audit.records.get(0).getLeft());
assertEquals("/articles", audit.records.get(0).getRight()[4]);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void logNodeDeleteCreateDelete() throws RepositoryException {
session.getNode("/articles").remove();
session.getRootNode().addNode("articles");
session.removeItem("/articles");
session.save();
assertEquals(1, audit.records.size());
assertEquals(AuditLoggingUtil.ACTION_DELETE, audit.records.get(0).getLeft());
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void logSessionDelete() throws RepositoryException {
session.removeItem("/articles");
session.save();
assertEquals(1, audit.records.size());
assertEquals(AuditLoggingUtil.ACTION_DELETE, audit.records.get(0).getLeft());
assertEquals("/articles", audit.records.get(0).getRight()[4]);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void sequenceActionSessionDeleteCreate() throws RepositoryException {
session.removeItem("/articles");
session.getRootNode().addNode("articles");
session.save();
assertEquals(2, audit.records.size());
assertEquals(AuditLoggingUtil.ACTION_DELETE, audit.records.get(0).getLeft());
assertEquals("/articles", audit.records.get(0).getRight()[4]);
assertEquals(AuditLoggingUtil.ACTION_CREATE, audit.records.get(1).getLeft());
assertEquals("/articles", audit.records.get(1).getRight()[4]);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
@After
public void tearDown() throws Exception {
// TODO MAGNOLIA-6576 there's no way to reset the MIMEMappings, it's leaking into other tests.
session.removeItem("/server/MIMEMapping");
MIMEMapping.reload();
super.tearDown();
}
代码示例来源:origin: info.magnolia/magnolia-rendering
@After
public void tearDown() throws Exception {
// TODO MAGNOLIA-6576 there's no way to reset the MIMEMappings, it's leaking into other tests.
configMimeMapping.removeItem("/server/MIMEMapping");
MIMEMapping.reload();
ComponentsTestUtil.clear();
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testReplaceNode4() throws Exception {
allow(path, privilegesFromNames(new String[] {
Privilege.JCR_ADD_CHILD_NODES,
Privilege.JCR_REMOVE_NODE,
Privilege.JCR_REMOVE_CHILD_NODES,
Privilege.JCR_NODE_TYPE_MANAGEMENT}));
testSession.removeItem(targetNode.getPath());
Node newNode = testSession.getNode(childNPath).addNode(targetNode.getName(), targetNode.getPrimaryNodeType().getName());
newNode.addMixin(getMixinName());
testSession.save();
}
内容来源于网络,如有侵权,请联系作者删除!