public static Resource reconstructVersion(@NotNull BigDecimal version,@NotNull String shortname,@Nullable DOI doi,@Nullable Organisation organisation,@Nullable VersionHistory versionHistory,@Nullable File versionEmlFile,@Nullable UUID key){
  Preconditions.checkNotNull(version);
  Preconditions.checkNotNull(shortname);
  if (organisation == null || versionHistory == null || versionEmlFile == null) {
    throw new IllegalArgumentException("Failed to reconstruct resource version because not all of organisation, version history, or version eml file were provided");
  }
  Resource resource=new Resource();
  resource.setShortname(shortname);
  resource.setEmlVersion(version);
  resource.setDoi(doi);
  resource.setOrganisation(organisation);
  resource.setKey(key);
  resource.setStatus(versionHistory.getPublicationStatus());
  resource.setIdentifierStatus(versionHistory.getStatus());
  resource.setRecordsPublished(versionHistory.getRecordsPublished());
  resource.setLastPublished(versionHistory.getReleased());
  if (versionEmlFile.exists()) {
    Eml eml=EmlUtils.loadWithLocale(versionEmlFile,Locale.US);
    resource.setEml(eml);
  }
 else {
    throw new IllegalArgumentException("Failed to reconstruct resource: " + versionEmlFile.getAbsolutePath() + " not found!");
  }
  return resource;
}

public static Resource reconstructVersion ( @ NotNull BigDecimal version , @ NotNull String shortname , @ Nullable DOI doi , @ Nullable Organisation organisation , @ Nullable VersionHistory versionHistory , @ Nullable File versionEmlFile , @ Nullable UUID key ) { Preconditions . checkNotNull ( version ) ; Preconditions . checkNotNull ( shortname ) ; if ( organisation == null || versionHistory == null || versionEmlFile == null ) { throw new IllegalArgumentException ( "Failed to reconstruct resource version because not all of organisation, version history, or version eml file were provided" ) ; } Resource resource = new Resource ( ) ; resource . setShortname ( shortname ) ; resource . setEmlVersion ( version ) ; resource . setDoi ( doi ) ; resource . setOrganisation ( organisation ) ; resource . setKey ( key ) ; resource . setStatus ( versionHistory . getPublicationStatus ( ) ) ; resource . setIdentifierStatus ( versionHistory . getStatus ( ) ) ; resource . setRecordsPublished ( versionHistory . getRecordsPublished ( ) ) ; resource . setLastPublished ( versionHistory . getReleased ( ) ) ; if ( versionEmlFile . exists ( ) ) { Eml eml = EmlUtils . loadWithLocale ( versionEmlFile , Locale . US ) ; resource . setEml ( eml ) ; } else { throw new IllegalArgumentException ( "Failed to reconstruct resource: " + versionEmlFile . getAbsolutePath ( ) + " not found!" ) ; } return resource ; }
reconstruct published version , using version ' s eml file , version history , etc .
