We would like to add a "Include" function in a utility that is written in Borland Delphi. At first, I started looking at using the Client API to interface with Vault. Marrying the Client API with Delphi started to look like a real project. However, I also noticed the valult HTTP interface can be used to extract a module out of vault.
What I couldn't find on the vault HTTP interface was a getlastestversion request. I have been able to Login, followed by a VaultHistory.aspx request, and then extract the first GetFile.aspx from the returned page.
While this works, the VaultHistory.aspx call seems to be fairly expensive when all I want to get is the lastest version. Is there a way to call getfile.aspx directly to fetch the lastest version of a module? I tried making the call without the version=n paramater, but that doesn't work...
For those that might be interested, here's what I've got so far using the native Delphi Indy components:
// login (make sure http component will handle redirects
VaultUrl := 'http://vault.dts/VaultService/VaultWeb/';
tsl := TStringList.Create;
cookiemgr := TIdCookieManager.Create(nil);
http := TIdHTTP.Create(nil);
http.handleredirects := True;
http.CookieManager := cookiemgr;
tsl.Add('login=******');
tsl.Add('pass=******');
s := http.Post(VaultUrl + 'action_login.aspx', tsl);
tsl.Free;
// Get history for the file, extract the link to the download the lastest
// version, and then get the file from vault.
s := '$/accr22/#linkp.jcl';
s := HTTPEncode(s);
s := http.Get(VaultUrl + 'VaultHistory.aspx?File=1' + s);
s := copy(S, Pos('GetFile.aspx',S), Length(S)- Pos('GetFile.aspx',S));
s := copy(S, 1, Pos('"',S)-1);
s := http.Get(VaultUrl + S);
Thanks for any ideas on getting rid of the 'VaultHistory.aspx call.
Don
Delphi program and GetLastestVersion request.
Moderator: SourceGear
-
- Posts: 114
- Joined: Fri Mar 05, 2004 11:18 am
- Location: Raleigh, NC
There's no way to get around this when you're going through the web client, but perhaps it would be better to shell out to the Vault command line client.
You can use "vault help" to get more information and "vault help get" to see specific information on the get command.
Code: Select all
vault -host SERVERNAME -user USERNAME -password PASSWORD -repository "REPOSITORYNAME" -destpath PATHTOPUTTHEFILE get FULLREPOSITORYPATHTOFILE
-
- Posts: 114
- Joined: Fri Mar 05, 2004 11:18 am
- Location: Raleigh, NC
I've used the vault cmdline for scripts that we've written, and considered using it for the utility. However, the very first test case had include cards getting the same file names from different folders. Since there are fair number of includes, I was planning on using a batch command to get them all at once with a single logon. Not being able to use a single -destpath would have complicated the problem.
The advantage to the HTTP interface it's faster and can directly load a string variable without writing then reading a temporary disk file - perfect for this application.
I was just hoping there might be a way (now or in the future) that 'GetFile.aspx' could get the lastest version directly. For example, version=0 or version=-1 gets the lastest version.
Thanks,
Don
The advantage to the HTTP interface it's faster and can directly load a string variable without writing then reading a temporary disk file - perfect for this application.
I was just hoping there might be a way (now or in the future) that 'GetFile.aspx' could get the lastest version directly. For example, version=0 or version=-1 gets the lastest version.
Thanks,
Don
Don,
Right now, some web client commands are good about taking -1 and some are not. Unfortunately, Get is one that is not good. You could try using the batch mode of the command line client. In your case, you would need to output a temp file containing lines like this:
and then call the command line with a similar syntax
You could use "-" instead of tmpfilename.txt to specify that the CLC should read commands off standard input.
Right now, some web client commands are good about taking -1 and some are not. Unfortunately, Get is one that is not good. You could try using the batch mode of the command line client. In your case, you would need to output a temp file containing lines like this:
Code: Select all
get $/repospath/file1 -destpath c:\somedir
get $/repospath/file2 -destpath c:\someotherdir
Code: Select all
vault -host SERVERNAME -user USERNAME -password PASSWORD -repository "REPOSITORYNAME" batch tmpfilename.txt