public void testItemAdd_DataManager() throws Exception
{
SessionDataManager sdm = session.getTransientNodesManager();
TransactionableDataManager trm = sdm.getTransactManager();
SharedDataManager wdm = trm.getStorageDataManager();
NodeData rootData = (NodeData)wdm.getItemData(Constants.ROOT_UUID);
InternalQName nodeName = InternalQName.parse("[]testNode");
QPath path = QPath.makeChildPath(rootData.getQPath(), nodeName, 1);
AccessControlList acl = rootData.getACL();
TransientNodeData nodeData =
new TransientNodeData(path, IdGenerator.generate(), -1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
rootData.getIdentifier(), acl);
// jcr:primaryType
TransientPropertyData ptData =
TransientPropertyData.createPropertyData(nodeData, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(Constants.NT_UNSTRUCTURED));
// jcr:mixinTypes
TransientPropertyData mtData =
TransientPropertyData.createPropertyData(nodeData, Constants.JCR_MIXINTYPES, PropertyType.NAME, true,
new TransientValueData(Constants.MIX_REFERENCEABLE));
// jcr:uuid
TransientPropertyData uuidData =
TransientPropertyData.createPropertyData(nodeData, Constants.JCR_UUID, PropertyType.STRING, false,
new TransientValueData(nodeData.getIdentifier()));
// add
CompositeChangesLog clog = new TransactionChangesLog();
PlainChangesLogImpl changes = new PlainChangesLogImpl();
try
{
changes.add(ItemState.createAddedState(nodeData));
changes.add(ItemState.createAddedState(ptData));
changes.add(ItemState.createAddedState(mtData));
changes.add(ItemState.createAddedState(uuidData));
clog.addLog(changes);
wdm.save(clog);
}
finally
{
cleanUpList.add(nodeData);
cleanUpList.add(ptData);
cleanUpList.add(mtData);
cleanUpList.add(uuidData);
}
// get
try
{
NodeData storedNode = (NodeData)wdm.getItemData(rootData, new QPathEntry(nodeName, 1), ItemType.NODE);
assertEquals(path, storedNode.getQPath());
}
catch (Exception e)
{
throw e;