Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to programatically get the lock status of a file from a stream?

Hi ,

I have prepared a change set with some files and associated that change set to some work item. I have developed a Plugin which will take input of Work Item number and fetch the files inside change set(s) associated to it.

Now to enhance that plugin, I want to display the List of files from change set which are locked by any Team user.
Currently I am using the IsImmutable method of IFileItem class. But there are some refresh problems occurring like even after the user has released / Locked the file, same is not reflecting to my plugin ONLINE.
Is there any direct method to know whether the given file in the Stream was locked by an user or not.

Regards
Pugazh

0 votes


Accepted answer

Permanent link
SCMPlatform#getWorkspaceManager() will get you an IWorkspaceManager.  IWorkspaceManager#findLocks() should let you search for locks in a stream.  It takes an ILockSearchCriteria that you can customize to return exactly the locks you want.  (Use ILockSearchCriteria.LockSearchCriteriaFactory#newInstance() to create the ILockSearchCriteria.)
David Lafreniere selected this answer as the correct answer

2 votes

Comments

Hi John.
Thanks a lot. Based on your input i have followed the below link.

https://jazz.net/forum/questions/83178/scm-apis-use-auto-lock-to-imitate-reserved-check-out

But it always shown as file locked.

My Code :

criteria = ILockSearchCriteria.FACTORY.newInstance();             
criteria.getStreams().add(workspaceHandle);
criteria.getComponents().add(component);
criteria.getVersionables().add(fileItemHandle);

Note : i am using change set to get componet ,file handle and workspace handle is Stream. i need get the current status of a file(file is referred from change set) from Stream.

 

I don't see anything obviously wrong with the way you're constructing your search criteria.  Maybe there's an issue with the code that's interpreting the results you're getting back?  Or (and sorry in advance for the stupid question) is it at all possible that the file actually is locked?  If you go to your project area in the web UI and choose Source Control --> Locks, do any locks appear?

John has the correct answer here. Please raise a defect if something is not working as expected.

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,934
× 411
× 169
× 66
× 56

Question asked: Feb 21 '13, 3:59 a.m.

Question was seen: 6,621 times

Last updated: Oct 05 '17, 11:15 p.m.

Confirmation Cancel Confirm