How do I retrieve the current label comment?

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

Moderator: SourceGear

Post Reply
itsckl
Posts: 7
Joined: Thu Feb 04, 2010 5:25 am

How do I retrieve the current label comment?

Post by itsckl » Thu Feb 18, 2010 7:31 am

I need to retrieve the current label comment in my own vault client (like the vault GUI client does with "show labels..."). From wiresharking the GUI client I got this implementation:

Code: Select all

public string GetLabelComment(string item, string label)
        {
            string objectPath = fixPath(item);
            string token;
            long n1, n2;
            try
            {
                ServerOperations.client.ClientInstance.BeginLabelQuery(
                    objectPath,
                    0,
                    false,
                    false,
                    false,
                    false,
                    10,
                    out n1,
                    out n2,
                    out token);
            }
            catch
            {
                throw new UsageException(objectPath + ": no such object");
            }
            VaultLabelItemX[] lis;
            ServerOperations.client.ClientInstance.GetLabelQueryItems_Main(token, 0, 1, out lis);

            foreach (VaultLabelItemX li in lis)
            {
                if (li.Label == label)
                {
                    return li.Comment;
                }
            }
            throw new UsageException(label + ": label not found for '" + objectPath + "'");
        }
    }
In fact this works fine. However, I feel a little uneasy as this is not part of the official API. Is there a documented version that I missed?

Regards, Christoph

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Re: How do I retrieve the current label comment?

Post by jeremy_sg » Thu Feb 18, 2010 8:49 am

If that's working for you, I have no objections to how you found the method, or how you're calling it. Any official exposure of the labelcomment functionality would use that method under the hood anyway.

To compare your code with other label methods, you can look at the ServerOperations.cs file which is included in the ClientAPI zip file.

Also, it would be polite to call EndLabelQuery when you're done with it.
Subscribe to the Fortress/Vault blog

itsckl
Posts: 7
Joined: Thu Feb 04, 2010 5:25 am

Re: How do I retrieve the current label comment?

Post by itsckl » Thu Feb 18, 2010 9:03 am

jeremy_sg wrote: To compare your code with other label methods, you can look at the ServerOperations.cs file which is included in the ClientAPI zip file.
I surely did. But there is no method that would do this in ServerOperations.cs, or did I overlook it?
jeremy_sg wrote: Also, it would be polite to call EndLabelQuery when you're done with it.
Thanks, good advice! I was wondering how the server gets rid of the cached result list. Then again, it will probably through it away on logout anyway, right? As my client is just used in batch mode (and thus does not live more than a few seconds) I must admit that I am a bit lazy when it comes to clean up everything as I probably should...

:-) Christoph

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Re: How do I retrieve the current label comment?

Post by jeremy_sg » Thu Feb 18, 2010 9:10 am

You didn't overlook anything. I'm glad that you have something that is working for you.
Subscribe to the Fortress/Vault blog

Post Reply