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

Details of API to fetch status of a object in stream

 Details of API to fetch status of a object in stream.


Need to get the status of the objects in stream. whether objects are
  1. locked 
  2. unlocked
  3. how to unlock the object force fully using administrator user id.
Need to know API and corresponding methods used to perform these actions.

0 votes


Accepted answer

Permanent link

You can pass the list of versionables to IWorkspaceManager#findLocks(ILockSearchCriteria criteria, IProgressMonitor monitor) and it will return ILockSearchResult that indicates the versionables that are locked.


To unlock when the user is not the same as the user who has locked the file, you need to pass a custom ILockDilemmaHandler to IUnlockOperation where you override the method currentUserDoesntOwnLock and return IDilemmaHandler.CONTINUE. The lock will be released only if the user has the right permissions.

arun sudarsanam selected this answer as the correct answer

0 votes


One other answer

Permanent link

  Hi Shashikant,


ILockSearchResult  returns whether the object is locked or not. But it doesn't return user who locked the object in stream. instead it shows repository login user id.

IFileItemHandle fileH = (IFileItemHandle) item;
file = (IFileItem) componentConfig.fetchCompleteItem(fileH, null);
criteria.getVersionables().add(file);
criteria.getComponents().add(component);
criteria.getStreams().add(workspace);
// wkspManager = SCMPlatform.getWorkspaceManager(teamRepository);

ILockSearchResult result = wkspManager.findLocks(criteria, IWorkspaceManager.MAX_QUERY_SIZE, null);
        Collection<IStreamLockReport> reports = result.getReports();
       // IProgressMonitor monitor = new LoggerProgressMonitor();
   //    ILockAttribute lockAttribute = newLockAttribute(false,"");
        for (IStreamLockReport report : reports) {
            Collection<IComponentLockReport> componentLocks = report.getComponentLocks();
            for (IComponentLockReport componentLock : componentLocks) {
                Collection<IVersionableLock> locks1 = componentLock.getLocks();

                if (!locks1.isEmpty()) {
                    for (IVersionableLock iVersionableLock : locks1) {
                     iVersionableLock.getContributor();
                     iVersionableLock.getVersionable();
                      //  IContributor contributor = (IContributor) repo.itemManager().fetchCompleteItem(iVersionableLock.getContributor(), ItemManager.DEFAULT, null);
               //         lockAttribute = new LockAttribute(true, contributor.getName());

                    }

                } else {

              //      IComponent component = (IComponent) repo.itemManager().fetchCompleteItem(componentLock.getComponent(), ItemManager.DEFAULT, monitor);
                //   if (logger.isDebugEnabled()) logger.debug("no lock for component " + component.getName());
                }

            }

        } 

0 votes

Comments

versionableLock.getContributor() should get the contributor who has locked the versionable. 

 Hi Padur,


get contributor gives repository user name, how to find object locked user name, how it will display. whether by name or any UUID.

Also could you please elaborate forceful unlock using administrator account. 
"ILockDilemmaHandler to IUnlockOperation where you override the method currentUserDoesntOwnLock and return IDilemmaHandler.CONTINUE. The lock will be released only if the user has the right permissions."

Any example code snippets or methods and its corresponding parameters which needs to be passed. 

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
× 11,078

Question asked: Nov 09 '17, 1:27 a.m.

Question was seen: 4,086 times

Last updated: Nov 14 '17, 2:14 a.m.

Confirmation Cancel Confirm