protected synchronized void addOrUpdateVersionHistory(Resource resource,BigDecimal version,boolean published,BaseAction action){
  log.info("Adding or updating version: " + version.toPlainString());
  VersionHistory versionHistory;
  VersionHistory existingVersionHistory=resource.findVersionHistory(version);
  if (existingVersionHistory == null) {
    versionHistory=new VersionHistory(version,resource.getStatus());
    resource.addVersionHistory(versionHistory);
    log.info("Adding VersionHistory for version " + version.toPlainString());
  }
 else {
    versionHistory=existingVersionHistory;
    log.info("Updating VersionHistory for version " + version.toPlainString());
  }
  versionHistory.setDoi(resource.getDoi());
  versionHistory.setStatus(resource.getIdentifierStatus());
  versionHistory.setChangeSummary(resource.getChangeSummary());
  versionHistory.setRecordsPublished(resource.getRecordsPublished());
  versionHistory.setRecordsByExtension(resource.getRecordsByExtension());
  User modifiedBy=action.getCurrentUser();
  if (modifiedBy != null) {
    versionHistory.setModifiedBy(modifiedBy);
  }
  if (published) {
    versionHistory.setReleased(new Date());
  }
}

protected synchronized void addOrUpdateVersionHistory ( Resource resource , BigDecimal version , boolean published , BaseAction action ) { log . info ( "Adding or updating version: " + version . toPlainString ( ) ) ; VersionHistory versionHistory ; VersionHistory existingVersionHistory = resource . findVersionHistory ( version ) ; if ( existingVersionHistory == null ) { versionHistory = new VersionHistory ( version , resource . getStatus ( ) ) ; resource . addVersionHistory ( versionHistory ) ; log . info ( "Adding VersionHistory for version " + version . toPlainString ( ) ) ; } else { versionHistory = existingVersionHistory ; log . info ( "Updating VersionHistory for version " + version . toPlainString ( ) ) ; } versionHistory . setDoi ( resource . getDoi ( ) ) ; versionHistory . setStatus ( resource . getIdentifierStatus ( ) ) ; versionHistory . setChangeSummary ( resource . getChangeSummary ( ) ) ; versionHistory . setRecordsPublished ( resource . getRecordsPublished ( ) ) ; versionHistory . setRecordsByExtension ( resource . getRecordsByExtension ( ) ) ; User modifiedBy = action . getCurrentUser ( ) ; if ( modifiedBy != null ) { versionHistory . setModifiedBy ( modifiedBy ) ; } if ( published ) { versionHistory . setReleased ( new Date ( ) ) ; } }
construct or update the versionhistory for version v of resource , and make sure that it is added to the resource ' s versionhistory list .
