It's all about the answers!

Ask a question

Details of API to fetch status of a object in stream


arun sudarsanam (254) | asked Nov 09 '17, 1:27 a.m.

 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.

Accepted answer


permanent link
Shashikant Padur (4.2k27) | answered Nov 09 '17, 11:16 p.m.
JAZZ DEVELOPER

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

One other answer



permanent link
arun sudarsanam (254) | answered Nov 13 '17, 2:14 a.m.

  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());
                }

            }

        } 


Comments
Shashikant Padur commented Nov 13 '17, 4:13 a.m.
JAZZ DEVELOPER

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


arun sudarsanam commented Nov 14 '17, 2:14 a.m.

 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 to post your answer.