Problems with ChangeSetItem_CreateFolder

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
SallyC
Posts: 3
Joined: Thu Jan 08, 2009 11:46 am

Problems with ChangeSetItem_CreateFolder

Post by SallyC » Thu Jan 08, 2009 11:56 am

Hi,

I would like to share each file in a folder, but not the folders themselves. I can not figure out how to do this through vault without having to share each folder individually, so I am using the Vault Client API.

I am using version 3.5 Vault Client API and am having trouble using ChangeSetItem_CreateFolder. I am able to navigate through the tree and display all folders in vault, but I get an error when trying to create a new folder.

Here is my code:

shareToFolder and shareFromFolder are VaultClientFolder objects that the user has selected from a TreeView displayed on a UI.

After I am already logged in to vault, I do the following:

string fullFolderPath = shareToFolder.FullPath + "/" + shareFromFolder.Name + "/";

ClientInstance ci = new ClientInstance();
ci.UseFileSystemWatchers = false;
ci.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client);

ChangeSetItem_CreateFolder csaf = new ChangeSetItem_CreateFolder(
VaultDateTime.Now,
"Sharing by automated tool",
String.Empty,
fullFolderPath);

ChangeSetItemColl csic = new ChangeSetItemColl();
csic.Add(csaf);
ci.InternalChangeSet_Append(csic);
ci.Commit(csic);

I get the error at ci.InternalChangeSet_Append(csic)
The error is the following:
Message:"Object reference not set to an instance of an object."
Source:"VaultClientOperationsLib"


Any help on this would be appreciated. Thanks!

shannon

Re: Problems with ChangeSetItem_CreateFolder

Post by shannon » Thu Jan 08, 2009 12:05 pm

You need to set a repository. Look at ClientInstance.SetActiveRepositoryID

SallyC
Posts: 3
Joined: Thu Jan 08, 2009 11:46 am

Re: Problems with ChangeSetItem_CreateFolder

Post by SallyC » Thu Jan 08, 2009 12:34 pm

I figured out what this problem was. I was not setting the repository. I have changed the code to set the repository as follows. However, now Commit is coming back with FALSE instead of TRUE and the folder is not being created. Any ideas?

public void LogIn()
{

_vaultClient.UseFileSystemWatchers = false;
_vaultClient.Init(VaultConnection.AccessLevelType.Client);


if (_vaultClient.ConnectionStateType == VaultClientOperationsLib.ConnectionStateType.Unconnected)
{
string url = "http://uslaxpxvault/VaultService/";
string user = "*****";
string password = "*****";
string repository = "phoenix";
_vaultClient.Login(url, user, password);
SetRepository(repository, user);

_vaultClient.EventEngine.addListener(this, typeof(MessageEvent));
_vaultClient.EventEngine.addListener(this, typeof(BulkMessageEvent));
}
}


private void RecursivelyShareFiles(VaultClientFolder shareFromFolder, VaultClientFolder shareToFolder)
{
//Create the share from folder under the share to folder
string fullFolderPath = shareToFolder.FullPath + "/" + shareFromFolder.Name;

_vaultClient.UseFileSystemWatchers = false;
_vaultClient.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client);


ChangeSetItem_CreateFolder csaf = new ChangeSetItem_CreateFolder(
VaultDateTime.Now,
"Sharing by automated tool",
String.Empty,
fullFolderPath);
ChangeSetItemColl csic = new ChangeSetItemColl();
csic.Add(csaf);
_vaultClient.InternalChangeSet_Append(csic);
_vaultClient.InternalChangeSet_SetComment("Sharing by automated tool");
bool result = _vaultClient.Commit(csic);
}

SallyC
Posts: 3
Joined: Thu Jan 08, 2009 11:46 am

Re: Problems with ChangeSetItem_CreateFolder

Post by SallyC » Thu Jan 08, 2009 12:54 pm

Shannon - Thank you for your response. I posted mine before I saw yours. Do you have any idea why commit is not working for me?

Thanks!

shannon

Re: Problems with ChangeSetItem_CreateFolder

Post by shannon » Thu Jan 08, 2009 1:26 pm

Is there anything in the log file?

You shouldn't be calling these lines more than once:

_vaultClient.UseFileSystemWatchers = false;
_vaultClient.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client);

Post Reply