Open a connection to the data store.
()
| 314 | |
| 315 | /** Open a connection to the data store. */ |
| 316 | @Override |
| 317 | public void open() throws PersistenceException { |
| 318 | if(storageDir == null) |
| 319 | throw new PersistenceException("Can't open: storage dir is null"); |
| 320 | |
| 321 | // check storage directory is readable |
| 322 | if(! storageDir.canRead()) { |
| 323 | throw new PersistenceException("Can't read " + storageDir); |
| 324 | } |
| 325 | |
| 326 | // check storage directory is a valid serial datastore |
| 327 | // if we want to support old style: |
| 328 | // String versionInVersionFile = "1.0"; |
| 329 | // (but this means it will open *any* directory) |
| 330 | try { |
| 331 | FileReader fis = new FileReader(getVersionFile()); |
| 332 | BufferedReader isr = new BufferedReader(fis); |
| 333 | currentProtocolVersion = isr.readLine(); |
| 334 | if(DEBUG) Out.prln("opening SDS version " + currentProtocolVersion); |
| 335 | isr.close(); |
| 336 | } catch(IOException e) { |
| 337 | throw new PersistenceException( |
| 338 | "Invalid storage directory: " + e |
| 339 | ); |
| 340 | } |
| 341 | if(! isValidProtocolVersion(currentProtocolVersion)) |
| 342 | throw new PersistenceException( |
| 343 | "Invalid protocol version number: " + currentProtocolVersion |
| 344 | ); |
| 345 | |
| 346 | } // open() |
| 347 | |
| 348 | /** Close the data store. */ |
| 349 | @Override |