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
Need to know API and corresponding methods used to perform these actions.
|
Accepted answer
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
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 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
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.