private void initDB() throws Exception
{
if (!session.getRootNode().hasNode("concurrent_node"))
{
MimeTypeResolver mimeResolver = new MimeTypeResolver();
long startTime = System.currentTimeMillis();
int itemsCount = 0;
testRoot = (NodeImpl)session.getRootNode().addNode("concurrent_node", "nt:file");
NodeImpl content = (NodeImpl)testRoot.addNode("jcr:content", "nt:unstructured");
NodeImpl data = (NodeImpl)content.addNode(FILE_DATA);
data.setProperty(DATA_PROPERTY, DATA_STRING);
itemsCount = itemsCount + 3;
// add some SNSes
for (int i = 0; i < 500; i++)
{
data = (NodeImpl)content.addNode(FILE_DATA);
data.setProperty(DATA_PROPERTY, DATA_STRING + i);
data.addNode("empty node");
itemsCount = itemsCount + 3;
}
session.save();
NodeImpl childData = (NodeImpl)content.addNode(CHILDS_DATA);
for (int l = 1; l <= 4; l++)
{
Node subChild = childData.addNode(LIBRARY + " " + l);
long startLibrary = System.currentTimeMillis();
// add some nodes with diff names
for (int i = 0; i < 500; i++)
{
long addTime = System.currentTimeMillis();
String nodeName = "#" + i + " file";
Node n = subChild.addNode(nodeName, "nt:file");
Node nContent = n.addNode("jcr:content", "nt:unstructured");
nContent.setProperty("currenTime", Calendar.getInstance());
nContent.setProperty("info", "Info string");
Node resource = nContent.addNode("fileData", "nt:resource");
resource.setProperty("jcr:mimeType", mimeResolver.getMimeType("x.doc"));
resource.setProperty("jcr:lastModified", Calendar.getInstance());
resource.setProperty("jcr:data", contentFile.openStream());
itemsCount = itemsCount + 8;