Пример #1
0
 /**
  * Either loads the default property file on the first access, or reloads it if it has been
  * modified since last access.
  *
  * @throws DataAccessResourceFailureException
  */
 void checkUserMap() throws DataAccessResourceFailureException {
   try {
     if ((userMap == null) || userDefinitionsFile == null || userDefinitionsFile.isStale()) {
       if (userDefinitionsFile == null) {
         Resource propFile = findUserProperties();
         userDefinitionsFile = new PropertyFileWatcher(propFile);
       }
       userMap = loadUsersFromProperties(userDefinitionsFile.getProperties());
     }
   } catch (Exception e) {
     LOGGER.log(Level.SEVERE, "An error occurred loading user definitions", e);
   }
 }
Пример #2
0
  /** Writes down the current users map to file system */
  public void storeUsers() throws IOException {
    OutputStream os = null;
    try {
      // turn back the users into a users map
      Properties p = storeUsersToProperties(userMap);

      // write out to the data dir
      Resource propFile = userDefinitionsFile.getResource();
      os = propFile.out();
      p.store(os, null);
    } catch (Exception e) {
      if (e instanceof IOException) throw (IOException) e;
      else
        throw (IOException)
            new IOException("Could not write updated users list to file system").initCause(e);
    } finally {
      if (os != null) os.close();
    }
  }