use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class SessionItemStateManager method createTransientNodeState.
//------< methods for creating & discarding transient ItemState instances >
/**
* @param id
* @param nodeTypeName
* @param parentId
* @param initialStatus
* @return
* @throws RepositoryException
*/
public NodeState createTransientNodeState(NodeId id, Name nodeTypeName, NodeId parentId, int initialStatus) throws RepositoryException {
if (initialStatus == ItemState.STATUS_NEW && id != null && hasItemState(id)) {
throw new InvalidItemStateException("Node " + id + " already exists");
}
// check map; synchronized to ensure an entry is not created twice.
synchronized (transientStore) {
if (id == null) {
id = stateMgr.getNodeIdFactory().newNodeId();
} else if (transientStore.containsKey(id)) {
throw new RepositoryException("There is already a transient state for node " + id);
}
NodeState state = new NodeState(id, nodeTypeName, parentId, initialStatus, true);
// put transient state in the map
transientStore.put(state.getId(), state);
state.setContainer(this);
return state;
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class MoveRemoveTest method testMoveRemove.
public void testMoveRemove() throws RepositoryException, NotExecutableException {
Session session1 = getHelper().getSuperuserSession();
Session session2 = getHelper().getSuperuserSession();
session1.move(folder1Path + "/node", folder2Path + "/node");
session2.getNode(folder1Path + "/node").remove();
session1.save();
try {
session2.save();
} catch (InvalidItemStateException e) {
if (e.getCause() == null || e.getCause().getClass() != StaleItemStateException.class) {
throw e;
}
}
ConsistencyReport consistencyReport = TestHelper.checkConsistency(testRootNode.getSession(), false, null);
//for (ReportItem item : consistencyReport.getItems()) {
// System.out.println(item.getMessage());
//}
assertTrue(consistencyReport.getItems().size() == 0);
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class ConcurrentAddRemoveMoveTest method testMoveFromWithRemove.
public void testMoveFromWithRemove() throws Exception {
Node d = session.getNode(testRoot).getNode("A").addNode("D");
session.save();
superuser.move(testRoot + "/A/B", testRoot + "/C/B");
d.remove();
superuser.save();
try {
session.save();
} catch (InvalidItemStateException e) {
fail("must not throw exception");
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class ConcurrentAddRemovePropertyTest method testRemove.
public void testRemove() throws Exception {
Node n = testRootNode.addNode(nodeName1);
n.setProperty(propertyName1, "foo");
n.setProperty(propertyName2, "bar");
superuser.save();
n.getProperty(propertyName1).remove();
session.getNode(testRoot).getNode(nodeName1).getProperty(propertyName2).remove();
superuser.save();
try {
session.save();
} catch (InvalidItemStateException e) {
fail("must not throw InvalidItemStateException");
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class ConcurrentAddRemovePropertyTest method testAdd.
public void testAdd() throws Exception {
Node n = testRootNode.addNode(nodeName1);
superuser.save();
n.setProperty(propertyName1, "foo");
session.getNode(testRoot).getNode(nodeName1).setProperty(propertyName2, "bar");
superuser.save();
try {
session.save();
} catch (InvalidItemStateException e) {
fail("must not throw InvalidItemStateException");
}
}
Aggregations