this.fs = fs;
this.escFactory = new DynamicESCFactory(obsMgr);
// need to store the version storage root directly into the persistence manager
if (!pMgr.exists(storageId)) {
NodeState root = pMgr.createNew(storageId);
root.setParentId(rootParentId);
root.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_SYSTEM).getApplicableChildNodeDef(
NameConstants.JCR_VERSIONSTORAGE, NameConstants.REP_VERSIONSTORAGE, ntReg).getId());
root.setNodeTypeName(NameConstants.REP_VERSIONSTORAGE);
PropertyState pt = pMgr.createNew(new PropertyId(storageId, NameConstants.JCR_PRIMARYTYPE));
pt.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_SYSTEM).getApplicablePropertyDef(
NameConstants.JCR_PRIMARYTYPE, PropertyType.NAME, false).getId());
pt.setMultiValued(false);
pt.setType(PropertyType.NAME);
pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_VERSIONSTORAGE)});
root.addPropertyName(pt.getName());
ChangeLog cl = new ChangeLog();
cl.added(root);
cl.added(pt);
pMgr.store(cl);
}
// check for jcr:activities
if (!pMgr.exists(activitiesId)) {
NodeState root = pMgr.createNew(activitiesId);
root.setParentId(storageId);
root.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_VERSIONSTORAGE).getApplicableChildNodeDef(
NameConstants.JCR_ACTIVITIES, NameConstants.REP_ACTIVITIES, ntReg).getId());
root.setNodeTypeName(NameConstants.REP_ACTIVITIES);
PropertyState pt = pMgr.createNew(new PropertyId(activitiesId, NameConstants.JCR_PRIMARYTYPE));
pt.setDefinitionId(ntReg.getEffectiveNodeType(NameConstants.REP_ACTIVITIES).getApplicablePropertyDef(
NameConstants.JCR_PRIMARYTYPE, PropertyType.NAME, false).getId());
pt.setMultiValued(false);
pt.setType(PropertyType.NAME);
pt.setValues(new InternalValue[]{InternalValue.create(NameConstants.REP_ACTIVITIES)});
root.addPropertyName(pt.getName());
// add activities as child
NodeState historyState = pMgr.load(storageId);
historyState.addChildNodeEntry(NameConstants.JCR_ACTIVITIES, activitiesId);
ChangeLog cl = new ChangeLog();
cl.added(root);
cl.added(pt);
cl.modified(historyState);
pMgr.store(cl);
}
sharedStateMgr = createItemStateManager(pMgr, storageId, ntReg, cacheFactory, ismLocking);
stateMgr = LocalItemStateManager.createInstance(sharedStateMgr, escFactory, cacheFactory);
stateMgr.addListener(this);
NodeState nodeState = (NodeState) stateMgr.getItemState(storageId);
historyRoot = new NodeStateEx(stateMgr, ntReg, nodeState, NameConstants.JCR_VERSIONSTORAGE);
nodeState = (NodeState) stateMgr.getItemState(activitiesId);
activitiesRoot = new NodeStateEx(stateMgr, ntReg, nodeState, NameConstants.JCR_ACTIVITIES);