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 load(File file) throws Exception { currentUserFile = file; URL fileUrl = file.toURL(); load(fileUrl); if (userName == null) { OTUserObject userObject = getUserObject(); if (userObject.getName() == null) { userObject.setName(currentUserFile.getName()); } } }
protected void load(XMLDatabase db) throws Exception { initUserDb(db); // Set the username OTUser user = refMap.getUser(); OTUserObject aUser = (OTUserObject) user; if (userName != null) { aUser.setName(userName); } otrunk.registerReferenceMap(getReferenceMap()); // just loading the database shouldn't cause it to have changes that need // saving. If the user name was set that would be change. userDataDB.setDirty(false); }