ProcessCommandRenameLabel

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear


Posts: 58
Joined: Thu Nov 13, 2014 10:12 am
Location: Lake in the Hills, IL
PostPosted: Mon Apr 04, 2016 10:27 am
Beth -

I am trying to use the C# API and am calling the following method to change the labels on the files and folders under the oldLabel name. The method I used and the errors I received are below. What did I do wrong or is there a better way to change an existing label name to a new name?

Thanks -

Eric

public static void ProcessCommandRenameLabel(string objectPath, string oldLabelName, string newLabelName)
{
try
{
long labelID = 0;
long rootID = 0;
string[] discoveredPaths;
VaultClientTreeObject labelStructure = null;

ServerOperations.client.ClientInstance.Refresh();

VaultClientTreeObject reposTreeObj = RepositoryUtil.FindVaultTreeObjectAtReposOrLocalPath(objectPath);

try
{
// There isn't a good API to get a label ID based on a label name, so just get the whole structure
ServerOperations.client.ClientInstance.GetByLabel_GetStructure(objectPath, oldLabelName, ref labelID, "", out discoveredPaths, out labelStructure, out rootID); // labelID = -1

if (reposTreeObj.ID == rootID && labelID != 0)
{
// We found the label ID. Now rename it.
VaultDateTime lastModified = VaultDateTime.Now;
int indexFailed;
string rootPathConflict;

int ret = ServerOperations.client.ClientInstance.PromoteLabelItems
(objectPath, labelID,
newLabelName, ref lastModified,
null, out indexFailed, out rootPathConflict);

if (ret == VaultStatusCode.FailDuplicateLabel)
{
// FailDuplicateLabel requires some string formatting.
throw new Exception(
String.Format(VaultConnection.GetSoapExceptionMessage(ret), rootPathConflict));
}
else if (ret != VaultStatusCode.Success)
{
throw new Exception(VaultConnection.GetSoapExceptionMessage(ret));
}
}
else
{
throw new Exception(string.Format("Could not find label \"{0}\" created at item \"{1}\". ", oldLabelName, objectPath));
}
}
catch
{
if (labelStructure == null)
{
throw new Exception(string.Format("Could not find label \"{0}\" created at item \"{1}\". ", oldLabelName, objectPath));
}
else
{
throw;
}
}
}
catch (Exception e)
{
int errorcode = VaultConnection.GetSoapExceptionStatusCodeInt(e);
if (errorcode == VaultLib.VaultStatusCode.FailInvalidSessionToken)
{
ServerOperations.Logout();
}
throw e;
}
}

When it gets to int ret = ServerOperations.client.ClientInstance.PromoteLabelItems
(objectPath, labelID, newLabelName, ref lastModified, null, out indexFailed, out rootPathConflict)


It jumps to the CATCH EXCEPTION with the following errors:
Step into: Stepping over non-user code 'VaultClientIntegrationLib.ServerOperations.client.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.Uri.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.GetWebRequest'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.PendingSyncRequest.set'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.GetWebRequest'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.Credentials.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.GetWebRequest'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.PreAuthenticate.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.GetWebRequest'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.BypassCache.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.GetWebRequest'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.HttpWebClientProtocol.UserAgent.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.NotifyClientCallOut'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.RemoteDebugger.IsClientCallOutEnabled'
Step into: Stepping over non-user code 'System.ComponentModel.CompModSwitches.DisableRemoteDebugging.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.RemoteDebugger.IsClientCallOutEnabled'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.RemoteDebugger.Connection.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.RemoteDebugger.IsClientCallOutEnabled'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.NotifyClientCallOut'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapClientType.GetMethod'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.CombineExtensionsHelper'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.InitializeExtensions'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.Url.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapClientMessage.SoapClientMessage'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.SoapMessage'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderCollection.SoapHeaderCollection'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.SoapMessage'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapClientMessage.SoapClientMessage'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.InitExtensionStreamChain'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.UrlEncoder.EscapeString'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.UrlEncoder.EscapeStringInternal'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.UrlEncoder.EscapeString'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.SetStage'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.RequestEncoding.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.ContentType.Compose'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.ContentType.Compose'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.ContentType.Compose'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.ContentType.set'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.EnsureStage'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.ContentType.set'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.SetParameterValues'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.Headers.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.GetHeaderMembers'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.MemberHelper.GetValue'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.GetHeaderMembers'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderCollection.Add'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.GetHeaderMembers'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.RunExtensions'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.ContentType.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.ContentEncoding.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.BeforeSerialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.SetStream'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Serialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.Stream.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Serialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapClientMessage.Method.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Serialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.EnvelopeNs.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Serialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.EncodingNs.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Serialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.GetWriterForMessage'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Serialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.WriteHeaders'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderCollection.this[int].get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.WriteHeaders'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.FindMapping'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.WriteHeaders'
Step into: Stepping over non-user code 'System.Web.Services.Diagnostics.Tracing.On.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.WriteHeaders'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeader.EncodedMustUnderstand.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeader.MustUnderstand.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeader.InternalMustUnderstand.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeader.MustUnderstand.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeader.EncodedMustUnderstand.get'
Step into: Stepping over non-user code 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterVaultService.Write12_VaultAuth'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeader.EncodedMustUnderstand12.get'
Step into: Stepping over non-user code 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterVaultService.Write12_VaultAuth'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeader.Actor.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeader.InternalActor.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeader.Actor.get'
Step into: Stepping over non-user code 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterVaultService.Write12_VaultAuth'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeader.Role.get'
Step into: Stepping over non-user code 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterVaultService.Write12_VaultAuth'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeader.EncodedRelay.get'
Step into: Stepping over non-user code 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterVaultService.Write12_VaultAuth'
Step into: Stepping over non-user code 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterVaultService.Write306_PromoteLabelItemsInHeaders'
Step into: Stepping over non-user code 'Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer379.Serialize'
Step into: Stepping over non-user code 'System.Xml.Serialization.XmlSerializer.Serialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.WriteHeaders'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Serialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.GetParameterValues'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Serialize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.GetWebResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.ContentEncoding.set'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.ContentType.IsSoap'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.ContentType.GetBase'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.ContentType.IsSoap'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.Exception.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.RequestResponseUtils.GetBufferSize'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.GetReaderForMessage'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapClientMessage.SoapVersion.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.SoapVersion.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapClientMessage.SoapVersion.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.GetReaderForMessage'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.RequestResponseUtils.GetEncoding'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.ContentType.GetCharset'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.ContentType.GetParameter'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.ContentType.GetCharset'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.RequestResponseUtils.GetEncoding'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.GetReaderForMessage'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.SoapHeaderHandling'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.ReadHeaders'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadSoapException'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadFaultCode'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadSoapException'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapException.SoapException'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadSoapException'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapMessage.Exception.set'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHeaderHandling.SetHeaderMembers'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse'
A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.WebClientProtocol.PendingSyncRequest.get'
Step into: Stepping over non-user code 'System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke'
Step into: Stepping over non-user code 'VaultClientNetLib.VaultConnection.PromoteLabelItems'
The thread '<No Name>' (0xa600) has exited with code 0 (0x0).
The thread '<No Name>' (0x226c) has exited with code 0 (0x0).

A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in hdms.sourcecontrol.vault.promotiontool.exe
Step into: Stepping over non-user code 'VaultClientNetLib.VaultConnection.GetSoapExceptionStatusCodeInt'
A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in hdms.sourcecontrol.vault.promotiontool.exe
Step into: Stepping over non-user code 'System.Exception.Message.get'
Server was unable to process request. ---> Object reference not set to an instance of an object.
Step into: Stepping over non-user code 'System.Exception.GetStackTrace'
at hdms.sourcecontrol.vault.promotiontool.VaultAccess.ProcessCommandRenameLabel(String objectPath, String oldLabelName, String newLabelName)
at hdms.sourcecontrol.vault.promotiontool.VaultAccess.RequestPromotion(VaultRequest vaultRequest)
Thanks!

Eric

Posts: 8418
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
PostPosted: Mon Apr 04, 2016 2:38 pm
When you are trying to rename the label, are you using the exact top location where it was applied? By that I mean, if the label was applied at $/Folder1, you would have to rename at that same level and not at $ nor a subfolder of Folder1.

I can't tell from what's posted what the issue was. Can you check your Vault server log at around the same time?

Also, check the Event Viewer on the Vault server to make sure there aren't any .NET errors there.
Beth Kieler
SourceGear Technical Support

Posts: 58
Joined: Thu Nov 13, 2014 10:12 am
Location: Lake in the Hills, IL
PostPosted: Tue Apr 05, 2016 8:21 am
No. I pass only the top level "$/Folder1" when the label may be located in "$/Folder1/Folder2"

Is there a method that can fetch the labels (wherever they are under the project level (i.e. "$/folder1")) and then rename them?
Thanks!

Eric

Posts: 8418
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
PostPosted: Tue Apr 05, 2016 10:52 am
You could use the code you current have, but get your arguments from part b.
    a) Do a label query ClientInstance.BeginLabelQuery(...)
    b) Retrieve the main/recursive items ClientInstance.GetLabelQueryItems_X()
    c) Close the query ClientInstance.EndLabelQuery
Beth Kieler
SourceGear Technical Support

Return to Questions (API)

Who is online

Users browsing this forum: No registered users and 2 guests

cron