public FrozenFileRecord restoreVersion( final Serializable fileId, final Serializable versionId,
final String author, final String versionMessage, final Date date ) {
List<FrozenFileRecord> history = versionMap.get( fileId );
if ( history == null ) {
throw new UnifiedRepositoryException( String.format( "version history for [%s] does not exist", fileId ) );
}
Integer versionNumber = versionNumber( versionId );
if ( versionNumber >= 0 && versionNumber < history.size() ) {
FrozenFileRecord r = history.get( versionNumber );
if ( r == null ) {
throw new UnifiedRepositoryException( String.format( "version [%s] does not exist", versionId ) );
}
history.add( new FrozenFileRecord( history.size(), new RepositoryFile.Builder( r.getFile() ).versionId(
history.size() ).build(), r.getData(), r.getMetadata(), author, versionMessage, date ) );
return history.get( history.size() - 1 );
}
throw new UnifiedRepositoryException( String.format( "unknown version [%s]", fileId ) );
}