}
if (null == bundleGroupIds || bundleGroupIds.length == 0) {
String msg = "Subject [" + subject.getName()
+ "] requires Global CREATE_BUNDLES and VIEW_BUNDLES to create unassigned initial bundle version.";
throw new PermissionException(msg, new BundleNotFoundException()); // set the cause to BNFE, this is helpful to some callers
}
for (int bundleGroupId : bundleGroupIds) {
boolean authzPassed;
if (hasGlobalCreateBundles) {
authzPassed = authorizationManager.canViewBundleGroup(subject, bundleGroupId);
} else {
authzPassed = authorizationManager.hasBundleGroupPermission(subject,
Permission.CREATE_BUNDLES_IN_GROUP, bundleGroupId);
}
if (!authzPassed) {
String msg = "Subject ["
+ subject.getName()
+ "] requires either Global.CREATE_BUNDLES + BundleGroup.VIEW_BUNDLES_IN_GROUP, or BundleGroup.CREATE_BUNDLES_IN_GROUP, to create or update a bundle in bundle group ["
+ Arrays.toString(bundleGroupIds) + "].";
throw new PermissionException(msg);
}
}
}