コード例 #1
0
 static Properties getAuIdProperties(String location) {
   File propFile = new File(location + File.separator + AU_ID_FILE);
   try {
     InputStream is = new BufferedInputStream(new FileInputStream(propFile));
     Properties idProps = new Properties();
     idProps.load(is);
     is.close();
     return idProps;
   } catch (Exception e) {
     logger.warning("Error loading au id from " + propFile.getPath() + ".");
     return null;
   }
 }
コード例 #2
0
 static void saveAuIdProperties(String location, Properties props) {
   // XXX these AU_ID_FILE entries need to be backed up elsewhere to avoid
   // single-point corruption
   File propDir = new File(location);
   if (!propDir.exists()) {
     logger.debug("Creating directory '" + propDir.getAbsolutePath() + "'");
     propDir.mkdirs();
   }
   File propFile = new File(propDir, AU_ID_FILE);
   try {
     logger.debug3("Saving au id properties at '" + location + "'.");
     OutputStream os = new BufferedOutputStream(new FileOutputStream(propFile));
     props.store(os, "ArchivalUnit id info");
     os.close();
     propFile.setReadOnly();
   } catch (IOException ioe) {
     logger.error("Couldn't write properties for " + propFile.getPath() + ".", ioe);
     throw new LockssRepository.RepositoryStateException("Couldn't write au id properties file.");
   }
 }