It's all about the answers!

Ask a question

Obtain file given stream and itemID (API)


Mark Richardson (2868) | asked Jun 10 '14, 8:52 a.m.
 Given a stream and an itemID uuid, how can I obtain a file item handle efficiently using the API? I know I could always traverse every file in the stream and compare id's but that takes too long to do.

2 answers



permanent link
sam detweiler (12.5k6195201) | answered Jun 10 '14, 9:22 a.m.
if you have the item (file/versionable) UUID you can get is item handle via (for example)
IItemHandle handle = IComponent.ITEM_TYPE.createHandle(uuid, null);


see accepted answer here
https://jazz.net/forum/questions/94538/get-iversionablehandle-from-uuid

as for which stream (or workspace) that versionable might be in? yeesh..

permanent link
Tim Mok (6.6k38) | answered Jun 10 '14, 9:36 a.m.
JAZZ DEVELOPER
From your stream, get your IWorkspaceConnection.

Using connection.configuration(IComponentHandle) will get you your configuration based on the component where your file resides.

Then call #fetchCompleteItem on your configuration. Give it the handle that you've obtained with the method Sam described. That will give you a versionable with state that represents the file in the stream. If you get just the handle, it has no state and refers to the item in a general sense.

Comments
sam detweiler commented Jun 10 '14, 10:13 a.m.

>how can I obtain a file item handle efficiently using the API

I think all he has is the file uuid.

how can u find what component that would be in? (in the stream he has)



Tim Mok commented Jun 10 '14, 11:15 a.m.
JAZZ DEVELOPER

It's more computation if the component isn't known. The IWorkspaceConfiguration can be retrieved to get all the component configurations in the stream. Then see if #fetchCompleteItem returns anything.


Mark Richardson commented Jun 10 '14, 4:11 p.m.

The fetchCompleteItem method expects a IVersionableHandle.  IComponent.ITEM_TYPE.createHandle is creating an IItemHandle where itemHandle.isAuditable() is true (IAuditableItemHandle). How do I create one of the type IVersionableHandle?


sam detweiler commented Jun 10 '14, 4:24 p.m.

it was a sample

uuid to ANY type handle is

type.ITEM_TYPE.createHandle(uuid, null);

so
IVersionable.ITEM_TYPE.createHandle(uuid, null);

workitem
IWorkItem.ITEM_TYPE.createHandle(uuid, null);

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.