It's all about the answers!

Ask a question

How can I test permissions on IBaselineHandle before resolving to full item?


Arne Bister (2.6k12832) | asked Mar 17 '15, 3:14 a.m.
JAZZ DEVELOPER
Team,

in a code not unlike
try {
... lots of other stuff
IBaselineHandle currentBLHandle;
IBaseline currentBL = (IBaseline) teamRepository
            .itemManager().fetchCompleteItem(currentBLHandle,
            IItemManager.DEFAULT, null);
} catch (final PermissionDeniedException e) {
           
        } ... and lots of other catches

how can I test the currentBLHandle for permissions before I run into the PermissionDeniedException?

gg,
Arne

One answer



permanent link
Arne Bister (2.6k12832) | answered Mar 17 '15, 5:00 a.m.
JAZZ DEVELOPER
Ah, this is how it works:
Resolve the whole list of baseline handles at once with

IFetchResult fetchResult = teamRepository.itemManager().fetchCompleteItemsPermissionAware(...)
and then test for fetchResult.hasPermissionDeniedItems() or iterate over fetchResult.getRetrievedItems()

I will comment if anything funny comes up that mandates more explicit explanations.

Comments
Evan Hughes commented Mar 17 '15, 10:04 a.m.
JAZZ DEVELOPER

That's the right way to do it. 


For performance reasons you should always try and fetch as many items as you can at a time. The cost of hitting the database on the server is (usually) very low, but the cost of crossing the network is very high. 

You can detect permission failures in the manner you suggest, or by using an IItemManager.fetch* and checking for null. 

Your answer


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