* @see MementoVersionSet
*/
@Override
public MementoVersionSet getVersionSet(Resource resource, Date date) throws MementoException {
try {
MementoVersionSet versionset = new MementoVersionSet(resource);
//get current version
versionset.setCurrent(versioningService.getLatestVersion(resource,date));
//loop to all versions to fill the versionset
RepositoryResult<Version> versions = versioningService.listVersions(resource);
while(versions.hasNext()) {
Version v = versions.next();
//set first as current if there is no current version yet
if(versionset.getCurrent() == null) versionset.setCurrent(v);
//set first version
if(versionset.getFirst() == null) versionset.setFirst(v);
//set last version
versionset.setLast(v);
//set previous as long as id is smaller than the current one
if(v.getId() < versionset.getCurrent().getId()) {
versionset.setPrevious(v);
}
//set next if it is not set yet and the id is greater than the current one
if(v.getId() > versionset.getCurrent().getId() && versionset.getNext() == null) {
versionset.setNext(v);
}
}
return versionset;
} catch (SailException e) {