Hi,
Yes this is a correct API. I use allVersionsFrom().
If you need previous revision you need to go throw all versions. They are usually sort by creation time.
First version is the latest one.
Check one by one VersionSortId if it is changed then it must be previous revision.
My solution to get previous revision. (code works for all objects not just WTPart...)
private static RevisionControlled getprevisousRevisionOfWTPart(RevisionControlled lastWTP)
{
RevisionControlled retValue = null;
String actualRev = lastWTP.getVersionIdentifier().getVersionSortId();
if (lastWTP != null)
{
try
{
QueryResult allVersions = VersionControlHelper.service.allVersionsFrom(lastWTP);
RevisionControlled prevRevision = null;
while (allVersions.hasMoreElements())
{
Object obj = allVersions.nextElement();
if (obj instanceof RevisionControlled)
{
String checkRevision = ((RevisionControlled) obj).getVersionIdentifier().getVersionSortId();
if (checkRevision.equals(actualRev))
{
System.out.println("next version");
} else
{
prevRevision = (RevisionControlled) obj;
break;
}
}
}
if (prevRevision != null)
{
retValue = prevRevision;
}
} catch (WTException e)
{
e.printStackTrace();
}
}
return retValue;
}
Hope this can help.
PetrH