Page 1 of 1

Problem with getting a particular version of file

Posted: Wed Jul 01, 2009 1:17 am
by jdennes
I am using the

Code: Select all

GetOperations.ProcessCommandGetVersionToLocationOutsideWorkingFolder()
method to retrieve versions of files.

For some version numbers (as retrieved using

Code: Select all

ServerOperations.ProcessCommandHistory()
) of some files, I am receiving exceptions, e.g.:

Code: Select all

   at VaultClientOperationsLib.ClientInstance.ProcessGetFileRequests(GetFileInfo[] infos, MakeWritableType makeWritable, SetFileTimeType setFileTime, MergeType merge, Boolean updateHiddenFilesOnly, String ancestorFullPath, Boolean flat, String ancestorDiskPath, OverwritePrompt PromptData, Boolean isLabelGet, String currentPathToLabelItem, Int64 labelID, Boolean isRetry, Boolean isGetByDisplayVersion)
   at VaultClientOperationsLib.ClientInstance.GetByDisplayVersionToNonWorkingFolder(VaultClientFile[] files, MakeWritableType makeWritable, SetFileTimeType setFileTime, String ancestorFullPath, String ancestorDiskPath, OverwritePrompt PromptData)
   at VaultClientOperationsLib.ClientInstance.GetByDisplayVersionToNonWorkingFolder(VaultClientFile file, MakeWritableType makeWritable, SetFileTimeType setFileTime, String ancestorFullPath, String ancestorDiskPath, OverwritePrompt PromptData)
   at VaultClientIntegrationLib.GetOperations.performGetVersion(String objectPath, Int32 version, String strDestFolder, GetOptions getOptions)
   at VaultClientIntegrationLib.GetOperations.ProcessCommandGetVersionToLocationOutsideWorkingFolder(String objectPath, Int32 version, GetOptions getOptions, String destPath)
I have verified that I also receive an error when using the command line client to retrieve a particular version of a particular file:

Code: Select all

vault GETVERSION -host repo.example.com -user user -password pass -repository repo -verbose 1 $/path/to/file .

<vault>
  <!--Get latest version failed for $/path/to/file: Invalid revision number.-->
  <error>
    <exception>VaultClientOperationsLib.GetLatestVersionFailedException: Exception of type 'VaultClientOperationsLib.GetLatestVersionFailedException' was thrown.
   at VaultClientOperationsLib.ClientInstance.ProcessGetFileRequests(GetFileInfo[] infos, MakeWritableType makeWritable, SetFileTimeType setFileTime, MergeType merge, Boolean updateHiddenFilesOnly, String ancestorFullPath, Boolean flat, String ancestorDiskPath, OverwritePrompt PromptData, Boolean isLabelGet, String currentPathToLabelItem, Int64 labelID, Boolean isRetry, Boolean isGetByDisplayVersion)
   at VaultClientOperationsLib.ClientInstance.GetByDisplayVersionToNonWorkingFolder(VaultClientFile[] files, MakeWritableType makeWritable, SetFileTimeType setFileTime, String ancestorFullPath, String ancestorDiskPath, OverwritePrompt PromptData)
   at VaultClientOperationsLib.ClientInstance.GetByDisplayVersionToNonWorkingFolder(VaultClientFile file, MakeWritableType makeWritable, SetFileTimeType setFileTime, String ancestorFullPath, String ancestorDiskPath, OverwritePrompt PromptData)
   at VaultClientIntegrationLib.GetOperations.performGetVersion(String objectPath, Int32 version, String strDestFolder, GetOptions getOptions)
   at VaultClientIntegrationLib.GetOperations.ProcessCommandGetVersionToLocation OutsideWorkingFolder(String objectPath, Int32 version, GetOptions getOptions, String destPath)
   at VaultCmdLineClient.VaultCmdLineClient.ProcessCommand(Args curArg)
   at VaultCmdLineClient.VaultCmdLineClient.Main(String[] args)</exception>
  </error>
  <result>
    <success>False</success>
  </result>
</vault>
The strange thing about this is that when I view the history of such files in the Vault Windows client, I see the versions which are reported as invalid without a problem.

Any assistance would be appreciated. Thanks.

Re: Problem with getting a particular version of file

Posted: Wed Jul 01, 2009 6:46 am
by lbauer
Can you get that version to that path with the Vault GUI Client?

It would help to see the entire error. You can send it to support at sourcegear.com, Attn: Linda. Please include a link to this forum post.

Re: Problem with getting a particular version of file

Posted: Wed Jul 01, 2009 5:41 pm
by jdennes
After executing the following command using the Vault command line client:

Code: Select all

vault GETVERSION -host repo.example.com -user user -password pass -repository repo -verbose 1 $/path/to/file .
The entire error is shown in the output of the command:

Code: Select all

<vault>
  <!--Get latest version failed for $/path/to/file: Invalid revision number.-->
  <error>
    <exception>VaultClientOperationsLib.GetLatestVersionFailedException: Exception of type 'VaultClientOperationsLib.GetLatestVersionFailedException' was thrown.
   at VaultClientOperationsLib.ClientInstance.ProcessGetFileRequests(GetFileInfo[] infos, MakeWritableType makeWritable, SetFileTimeType setFileTime, MergeType merge, Boolean updateHiddenFilesOnly, String ancestorFullPath, Boolean flat, String ancestorDiskPath, OverwritePrompt PromptData, Boolean isLabelGet, String currentPathToLabelItem, Int64 labelID, Boolean isRetry, Boolean isGetByDisplayVersion)
   at VaultClientOperationsLib.ClientInstance.GetByDisplayVersionToNonWorkingFolder(VaultClientFile[] files, MakeWritableType makeWritable, SetFileTimeType setFileTime, String ancestorFullPath, String ancestorDiskPath, OverwritePrompt PromptData)
   at VaultClientOperationsLib.ClientInstance.GetByDisplayVersionToNonWorkingFolder(VaultClientFile file, MakeWritableType makeWritable, SetFileTimeType setFileTime, String ancestorFullPath, String ancestorDiskPath, OverwritePrompt PromptData)
   at VaultClientIntegrationLib.GetOperations.performGetVersion(String objectPath, Int32 version, String strDestFolder, GetOptions getOptions)
   at VaultClientIntegrationLib.GetOperations.ProcessCommandGetVersionToLocationOutsideWorkingFolder(String objectPath, Int32 version, GetOptions getOptions, String destPath)
   at VaultCmdLineClient.VaultCmdLineClient.ProcessCommand(Args curArg)
   at VaultCmdLineClient.VaultCmdLineClient.Main(String[] args)</exception>
  </error>
  <result>
    <success>False</success>
  </result>
</vault>
In answer to your question, yes, I can see version 1 of the file via the Vault GUI Client. Can you explain why the GUI would allow me to see and get version 1 of this file without a problem, while the command line client and the API won't (which both use the same code in VaultClientOperationsLib according to the stack trace)?

The other information I am including is the SOAP request and response - which I have captured - to /VaultService/VaultService.asmx. I have only included the request/response where the SOAPAction is "http://www.sourcegear.com/schemas/vault ... nloadFiles" for the case of using the command line interface as above and when using the GUI client.

The request/response recorded when using the command line client as shown above:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <VaultAuth xmlns="http://www.sourcegear.com/schemas/vault">
      <Token>
      d8a735b3-634c-4a17-b34c-6a25b5fdec11IHoT3R087CZ8sk5lOfWtLw==</Token>
    </VaultAuth>
  </soap:Header>
  <soap:Body>
    <BeginDownloadFiles xmlns="http://www.sourcegear.com/schemas/vault">
      <nRepID>10</nRepID>
      <requests>
        <VaultRequestGetFile>
          <ItemPath>
          $/path/to/file</ItemPath>
          <BaseObjVerID>0</BaseObjVerID>
          <TargetObjVerID>0</TargetObjVerID>
          <ObjID>417923</ObjID>
          <Version>1</Version>
        </VaultRequestGetFile>
      </requests>
    </BeginDownloadFiles>
  </soap:Body>
</soap:Envelope>

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <BeginDownloadFilesResponse xmlns="http://www.sourcegear.com/schemas/vault">

      <BeginDownloadFilesResult>0</BeginDownloadFilesResult>
      <requests>
        <VaultRequestGetFile>
          <ItemPath>
          $/path/to/file</ItemPath>
          <Response xsi:type="VaultResponseGetFile">
            <Status>1013</Status>
            <FileToken>
            5b7174c0-2d0a-47a7-855f-25981c5815a5</FileToken>
            <FileLength>0</FileLength>
            <FileCRC>4294967295</FileCRC>
            <ObjVerID>-1</ObjVerID>
            <ID>-1</ID>
            <Version>-1</Version>
            <EOL>2</EOL>    
            <FileDeltaLength>0</FileDeltaLength>
            <DeltaFileInfoIDLength>0</DeltaFileInfoIDLength>
          </Response>
          <BaseObjVerID>0</BaseObjVerID>
          <TargetObjVerID>0</TargetObjVerID>
          <ObjID>417923</ObjID>
          <Version>1</Version>
        </VaultRequestGetFile>
      </requests>
      <strDownloadID>
      485238c7-0fce-4834-8296-69e9b77be0ed</strDownloadID>
    </BeginDownloadFilesResponse>
  </soap:Body>
</soap:Envelope>
This request/response recorded when using the windows client to achieve the same thing as I am trying to achieve using the command line client:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <VaultAuth xmlns="http://www.sourcegear.com/schemas/vault">
      <Token>
      1e9b84ac-f7db-49d7-a88f-914e5d53085abtmle3n3REBur6uB6Ed5rw==</Token>
    </VaultAuth>
  </soap:Header>
  <soap:Body>
    <BeginDownloadFiles xmlns="http://www.sourcegear.com/schemas/vault">
      <nRepID>10</nRepID>
      <requests>
        <VaultRequestGetFile>
          <ItemPath>
          $/path/to/file</ItemPath>
          <BaseObjVerID>0</BaseObjVerID>
          <TargetObjVerID>217619</TargetObjVerID>
          <ObjID>417923</ObjID>
          <Version>0</Version>
        </VaultRequestGetFile>
      </requests>
    </BeginDownloadFiles>
  </soap:Body>
</soap:Envelope>

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <BeginDownloadFilesResponse xmlns="http://www.sourcegear.com/schemas/vault">
      <BeginDownloadFilesResult>0</BeginDownloadFilesResult>
      <requests>
        <VaultRequestGetFile>
          <ItemPath>
          $/path/to/file</ItemPath>
          <Response xsi:type="VaultResponseGetFile">
            <Status>1590</Status>
            <FileToken>
            4d9cfddb-56ca-48fd-9726-8829e11fdbd3</FileToken>
            <FileLength>4780</FileLength>
            <FileCRC>3261393260</FileCRC>
            <ModifiedDate>
              <Ticks>633056293211870000</Ticks>
            </ModifiedDate>
            <TxDate>
              <Ticks>633092513627500000</Ticks>
            </TxDate>
            <ObjVerID>217619</ObjVerID>
            <ID>23774</ID>
            <Version>1</Version>
            <EOL>2</EOL>
            <FileDeltaLength>810</FileDeltaLength>
            <DeltaFileInfoIDLength>810</DeltaFileInfoIDLength>
          </Response>
          <BaseObjVerID>0</BaseObjVerID>
          <TargetObjVerID>217619</TargetObjVerID>
          <ObjID>417923</ObjID>
          <Version>0</Version>
        </VaultRequestGetFile>
      </requests>
      <strDownloadID>
      7fa2c9d5-bb55-4017-a98f-371351604c67</strDownloadID>
    </BeginDownloadFilesResponse>
  </soap:Body>
</soap:Envelope>
You will no doubt notice the differences. Any explanation (even if it is just that there is a bug in VaultClientOperationsLib) would be appreciated. I am using Vault version 4.1.2.18185 and the corresponding version of the command line client and the client API.

Thanks.

Re: Problem with getting a particular version of file

Posted: Thu Jul 02, 2009 3:43 pm
by lbauer
This could happen if you are trying to get version 1 of a branched file (branched
files don't have a version 1, but history shows the trunk version 1)

Is that the case here?

Re: Problem with getting a particular version of file

Posted: Thu Jul 02, 2009 4:25 pm
by jdennes
Yes, that is the case. There are 19 versions of the file shown in the history returned by ServerOperations.ProcessCommandHistory(), numbered 1-19.

I cannot retrieve versions 1-5 of the file. Version 5 has the comment "Branched from ...".

So the history returned from ServerOperations.ProcessCommandHistory() is a bit misleading. Could you suggest a way of using the API to get around this if I want to get all versions (as reported by ServerOperations.ProcessCommandHistory()) of a particular file?

Thanks.

Re: Problem with getting a particular version of file

Posted: Tue Jul 07, 2009 1:32 pm
by jeremy_sg
I can give you a little help on this. You'll have to write this at a lower level, below VaultClientIntegrationLib.

Code: Select all

VaultClientFile vcfile = new VaultClientFile(FindVaultFileAtReposOrLocalPath("$/MyPath/To/File");
VaultHistoryItem histItem = TheHistoryItem;
vcfile.ID = histItem.ID;
vcfile.Version = histItem.Version;
vcfile.ObjVerID = histItem.ObjVerID;
vcfile.TxDate = histItem.TxDate;

ServerOperations.client.ClientInstance.GetToNonWorkingFolder(vcfile, false, true, MakeWritableType.MakeAllFilesReadOnly, SetFileTimeType.Current, vcfile.Parent.FullPath, "C:\path\to\location\to\put\the\file", null);

Re: Problem with getting a particular version of file

Posted: Tue Jul 07, 2009 4:22 pm
by jdennes
Thanks Jeremy -that's exactly what I was looking for. Your help is very much appreciated.

Re: Problem with getting a particular version of file

Posted: Wed Jul 08, 2009 7:31 am
by jeremy_sg
You're welcome!