Page 1 of 1
How do I add new file to Vault repository using the API?
Posted: Tue Apr 24, 2007 10:12 am
by sambati
How do I add new file to Vault repository using the API?
client.Repository.Root.Files.Add
or
Dim oItem As ChangeSetItem_AddFile = New ChangeSetItem_AddFile(System.DateTime.Now, "My Comments", "My Properties", PhysicalLocalPath, VaultPath)
is not helping me much. It will be great if you can point me to a good example.
Thanks
Srini
Posted: Tue Apr 24, 2007 12:42 pm
by jclausius
Once you've created a Change Set Item Collection with actual change set items, all you need to do is call Commit().
For more examples, download, build and step through the code for the Command Line Client in the
Vault Client API. In particular, step through the handlers for "vault.exe ADD" and "vault COMMIT".
How to add a file to repository ???
Posted: Thu Feb 28, 2008 2:00 pm
by mmoayyed
Here's the sample code I use:
col = new ChangeSetItemColl();
filePath = @"C:\dev1.txt";
project = "$/";
changeFile = new ChangeSetItem_AddFile(new VaultDateTime(), comment, String.Empty, filePath, project);
col.Add(changeFile);
res = moClient.Commit(col, "Changeset comments");
res is ALWAYS false.
Any ideas ?
Posted: Thu Feb 28, 2008 2:03 pm
by mmoayyed
Actually, if there was a way that I could know WHY the commit operation failed that would be great. A true/false value doesn't exactly describe the problem. Are there any logs somewhere on the server that I am not aware of ?
Posted: Thu Feb 28, 2008 2:06 pm
by mmoayyed
Forgot to mention that I am using the Client API 4.0.5
Posted: Thu Feb 28, 2008 2:13 pm
by mmoayyed
I tried calling different Commit() functions, adding different files to different branches and I also tried switch to different repositories. All failed. The result value is still FALSE.
Posted: Thu Feb 28, 2008 2:38 pm
by shannon
Posted: Thu Feb 28, 2008 2:41 pm
by mmoayyed
sure, but the examples use the integration library and the ServerOperations class. I am actually just using the <PORN SPAM> API since our application was written entirely based on that. Plus, I think the integration lib is just a wrapper around the <PORN SPAM> API and so they're calling the methods that I am. I am more interested to know what and how different we're calling the same functions. If we're both calling the same stuff, how can that lib work and not the way I am doing it ?
Posted: Thu Feb 28, 2008 3:00 pm
by shannon
try checking the server log : sgvault.log in %windir%\temp\sgvault
or client logs are in %TEMP%
Posted: Sat Mar 01, 2008 11:50 pm
by mmoayyed
Thanks for your help. For logs on the client side, do you happen to know what they're called or perhaps if there's a pattern ? my %TEMP% directory is huge and I only found 3 .log files which had nothing to do with SGV it seems.
I am planning to install the new client API 4.1.0.16216 and see if that makes any difference at all. If not, I will also try the integration lib. I will get back to you soon.
Thanks again.
Posted: Mon Mar 03, 2008 10:00 am
by shannon
The log files are .txt files, but one of my coworkers suggested using the message events.
Are you subscribing to the message events in your code? Try writing them to the console or a file (or whatever display you have).
//During clientinstance login:
if ( ClientInstance != null )
{
ClientInstance.EventEngine.addListener(client, typeof(MessageEvent));
ClientInstance.EventEngine.addListener(client, typeof(BulkMessageEvent));
}
//Then define these two handlers
public void HandleEvent(MessageEvent e)
{
}
/// <summary>
/// BulkMessageEvent handler. Writes the message if Verbose is true or the message level is error.
/// </summary>
/// <param name="e"></param>
public void HandleEvent(BulkMessageEvent e)
{
}
Posted: Tue Mar 04, 2008 11:36 am
by mmoayyed
Thanks. I subscribed to the message engine and here are the messages that I go back from: HandleEvent(MessageEvent e)
VaultClientOperationsLib.ProgressMessageBeforeTransactionBegin
VaultClientOperationsLib.ProgressMessageTransactionBegin
VaultClientOperationsLib.ProgressMessageTransactionItemFailed
VaultClientOperationsLib.ProgressMessageTransactionFailed
So I looked at the log file on the server and I found out that that I have a message for: AddFile: $/Aspen2000 returned: FailObjAlreadyExists
The file I am trying to add is: C:\dev1.txt and the folder that it's going to is $/Aspen2000
What's strange is that when I bring up the client to actually find this file, it isnt there. Do I need to refresh something or perhaps clear out the server cache somehow to make the file show up ?
Posted: Tue Mar 04, 2008 11:41 am
by mmoayyed
I also renamed and tried to add a completely new file that I am positive does not exist in vault. I got the same error back which said file object already exists. Any ideas ?
I am going to try the integration lib and see if it does anything different for me.
Posted: Tue Mar 04, 2008 12:07 pm
by shannon
I think your repository path is wrong. It looks like it expects you to be passing $/Aspen2000/dev1.txt but you are passing $/Aspen2000. So it is trying to add dev1.txt as Aspen2000 but already finding an object with that name.