How can I test permissions on IBaselineHandle before resolving to full item?
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
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
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.
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
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.