public void newLayer() throws Exception { // need to make a brand new stateDB userDataDB = new XMLDatabase(); otrunk.addDatabase(userDataDB); // System.out.println("otrunk: " + otrunk + " userDatabase: " + // userDataDB); OTObjectService objService = otrunk.createObjectService(userDataDB); OTStateRoot stateRoot = objService.createObject(OTStateRoot.class); userDataDB.setRoot(stateRoot.getGlobalId()); stateRoot.setFormatVersionString("1.0"); OTUserObject userObject = objService.createObject(OTUserObject.class); OTID userId = userObject.getUserId(); OTObjectMap userStateMapMap = stateRoot.getUserMap(); refMap = objService.createObject(OTReferenceMap.class); userStateMapMap.putObject(userId.toExternalForm(), refMap); refMap.setUser(userObject); otrunk.registerReferenceMap(refMap); userDataDB.setDirty(false); currentUserFile = null; }
protected void initUserDb(XMLDatabase userDataDb) throws Exception { this.userDataDB = userDataDb; otrunk.addDatabase(userDataDB); OTObjectService objService = otrunk.createObjectService(userDataDb); OTDataObject rootDO = userDataDb.getRoot(); OTStateRoot stateRoot = (OTStateRoot) objService.getOTObject(rootDO.getGlobalId()); OTObjectMap userMap = stateRoot.getUserMap(); // find the user from this database. // this currently is the first user in the userMap Vector<String> keys = userMap.getObjectKeys(); refMap = (OTReferenceMap) userMap.getObject(keys.get(0)); }