public void deserializeArchivedVersions() throws RuntimeException {
  System.out.println("Deserializing archived instances in " + getArchiveDirectory() + ".");
  File archive=new File(getArchiveDirectory());
  if (!archive.exists() || !archive.isDirectory()) {
    return;
  }
  String[] listing=archive.list();
  for (  String archiveName : listing) {
    if (!(archiveName.endsWith(".zip"))) {
      continue;
    }
    try {
      File file=new File(getArchiveDirectory(),archiveName);
      ZipFile zipFile=new ZipFile(file);
      ZipEntry entry=zipFile.getEntry("class_fields.ser");
      InputStream inputStream=zipFile.getInputStream(entry);
      ObjectInputStream objectIn=new ObjectInputStream(inputStream);
      Map<String,List<String>> classFields=(Map<String,List<String>>)objectIn.readObject();
      zipFile.close();
      for (      String className : classFields.keySet()) {
        List<String> fieldNames=classFields.get(className);
        Class<?> clazz=Class.forName(className);
        ObjectStreamClass streamClass=ObjectStreamClass.lookup(clazz);
        if (streamClass == null) {
          System.out.println();
        }
        for (        String fieldName : fieldNames) {
          assert streamClass != null;
          ObjectStreamField field=streamClass.getField(fieldName);
          if (field == null) {
            throw new RuntimeException("Field '" + fieldName + "' was dropped from class '"+ className+ "' as a serializable field! Please "+ "put it back!!!"+ "\nIt used to be in "+ className+ " in this archive: "+ archiveName+ ".");
          }
        }
      }
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException("Could not read class_fields.ser in archive + " + archiveName + " .",e);
    }
catch (    IOException e) {
      throw new RuntimeException("Problem reading archive" + archiveName + "; see cause.",e);
    }
    System.out.println("...Deserializing instances in " + archiveName + "...");
    ZipEntry zipEntry=null;
    try {
      File file=new File(getArchiveDirectory(),archiveName);
      FileInputStream in=new FileInputStream(file);
      ZipInputStream zipinputstream=new ZipInputStream(in);
      while ((zipEntry=zipinputstream.getNextEntry()) != null) {
        if (!zipEntry.getName().endsWith(".ser")) {
          continue;
        }
        ObjectInputStream objectIn=new ObjectInputStream(zipinputstream);
        objectIn.readObject();
        zipinputstream.closeEntry();
      }
      zipinputstream.close();
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException("Could not read object zipped file " + zipEntry.getName() + " in archive "+ archiveName+ ". "+ "Perhaps the class was renamed, moved to another package, or "+ "removed. In any case, please put it back where it was.",e);
    }
catch (    IOException e) {
      throw new RuntimeException("Problem reading archive" + archiveName + "; see cause.",e);
    }
  }
  System.out.println("Finished deserializing archived instances.");
}

public void deserializeArchivedVersions ( ) throws RuntimeException { System . out . println ( "Deserializing archived instances in " + getArchiveDirectory ( ) + "." ) ; File archive = new File ( getArchiveDirectory ( ) ) ; if ( ! archive . exists ( ) || ! archive . isDirectory ( ) ) { return ; } String [ ] listing = archive . list ( ) ; for ( String archiveName : listing ) { if ( ! ( archiveName . endsWith ( ".zip" ) ) ) { continue ; } try { File file = new File ( getArchiveDirectory ( ) , archiveName ) ; ZipFile zipFile = new ZipFile ( file ) ; ZipEntry entry = zipFile . getEntry ( "class_fields.ser" ) ; InputStream inputStream = zipFile . getInputStream ( entry ) ; ObjectInputStream objectIn = new ObjectInputStream ( inputStream ) ; Map < String , List < String > > classFields = ( Map < String , List < String > > ) objectIn . readObject ( ) ; zipFile . close ( ) ; for ( String className : classFields . keySet ( ) ) { List < String > fieldNames = classFields . get ( className ) ; Class < ? > clazz = Class . forName ( className ) ; ObjectStreamClass streamClass = ObjectStreamClass . lookup ( clazz ) ; if ( streamClass == null ) { System . out . println ( ) ; } for ( String fieldName : fieldNames ) { assert streamClass != null ; ObjectStreamField field = streamClass . getField ( fieldName ) ; if ( field == null ) { throw new RuntimeException ( "Field '" + fieldName + "' was dropped from class '" + className + "' as a serializable field! Please " + "put it back!!!" + "\nIt used to be in " + className + " in this archive: " + archiveName + "." ) ; } } } } catch ( ClassNotFoundException e ) { throw new RuntimeException ( "Could not read class_fields.ser in archive + " + archiveName + " ." , e ) ; } catch ( IOException e ) { throw new RuntimeException ( "Problem reading archive" + archiveName + "; see cause." , e ) ; } System . out . println ( "...Deserializing instances in " + archiveName + "..." ) ; ZipEntry zipEntry = null ; try { File file = new File ( getArchiveDirectory ( ) , archiveName ) ; FileInputStream in = new FileInputStream ( file ) ; ZipInputStream zipinputstream = new ZipInputStream ( in ) ; while ( ( zipEntry = zipinputstream . getNextEntry ( ) ) != null ) { if ( ! zipEntry . getName ( ) . endsWith ( ".ser" ) ) { continue ; } ObjectInputStream objectIn = new ObjectInputStream ( zipinputstream ) ; objectIn . readObject ( ) ; zipinputstream . closeEntry ( ) ; } zipinputstream . close ( ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( "Could not read object zipped file " + zipEntry . getName ( ) + " in archive " + archiveName + ". " + "Perhaps the class was renamed, moved to another package, or " + "removed. In any case, please put it back where it was." , e ) ; } catch ( IOException e ) { throw new RuntimeException ( "Problem reading archive" + archiveName + "; see cause." , e ) ; } } System . out . println ( "Finished deserializing archived instances." ) ; }
deserializes examplars stored in archives in getarchivedirectory ( ) .
