Get the owner and visibility of Component through API
![]()
Hi, I want to get the owner and visibility of Component through API.
There is a api for setting the owner and visibility for Component like below.
workspaceManager.setComponentOwnerAndVisibility(IComponentHandle ch, IAuditableHandle ah, IReadScope pscope, monitor);
But there is no API for querying.
I've found there is a class ComponentOwner and ComponentOwnerQueryModel in com.ibm.team.scm.common.internal.ComponentOwner.
I tried like below.
ComponentOwnerQueryModel componentOwnerQueryModel = ComponentOwnerQueryModel.ROOT;
// create a query for ComponentOwner
IItemQuery query = IItemQuery.FACTORY
.newInstance(componentOwnerQueryModel);
;
// allocate space for the parameter
IItemHandleInputArg[] itemHandleArgs = new IItemHandleInputArg[] { query
.newItemHandleArg() };
// the query filter
IPredicate filter = ((ComponentOwnerQueryModel) componentOwnerQueryModel)
.component()._in(itemHandleArgs);
// 1 parameter required
IItemQueryPage queryPage = RTCService
.iTeamBuildClient().queryItems(query,
new Object[] { iComponent },
IQueryService.ITEM_QUERY_MAX_PAGE_SIZE,
null);
if (queryPage.getResultSize() == 1) {
ComponentOwner componentOwner = (ComponentOwner) RTCService
.itemManager().fetchCompleteItem(
(ComponentOwnerHandle) queryPage
.getItemHandles().get(0),
IItemManager.DEFAULT, null);
System.out.println(componentOwner.getOwner()
.toString());
}
}
But I got an error message: com.ibm.team.repository.common.PermissionDeniedException: Remote queries are not allowed for the application-managed item type "com.ibm.team.scm#ComponentOwner"
how can i get this object?
Thanks!
|
Accepted answer
![]()
You should use the repo service com.ibm.team.scm.common.IScmService:
IScmService scmService = ...Cheers. Yung-Hsiang Chan selected this answer as the correct answer
|
One other answer
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.