Skip to content

Commit

Permalink
Merge pull request CESNET#4150 from dBucik/fix_bbmri_reg_module
Browse files Browse the repository at this point in the history
fix: 🐛 Fix BBMRIResources registration module possible NullPExc
  • Loading branch information
HejdaJakub authored Nov 7, 2023
2 parents 1c90655 + e3f17d8 commit 12161d2
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*/
public class BBMRIResources extends DefaultRegistrarModule {

private final static Logger log = LoggerFactory.getLogger(BBMRIResources.class);
private static final Logger log = LoggerFactory.getLogger(BBMRIResources.class);

// field names
private static final String RESOURCE_IDS = "resourceIds";
Expand All @@ -70,7 +70,6 @@ public class BBMRIResources extends DefaultRegistrarModule {
* @param session who approves the application
* @param app application
* @return unchanged application
* @throws PerunException in case of internal error in Perun
*/
@Override
public Application approveApplication(PerunSession session, Application app)
Expand Down Expand Up @@ -157,8 +156,8 @@ public void canBeApproved(PerunSession session, Application app) throws PerunExc
* @return Map of String to Group, where key is the ID of the resource and Group is the representation
*/
private Map<String, Group> getPerunResourceIdToGroupMap(PerunSession session, Application app, PerunBl perun)
throws PrivilegeException, RegistrarException, VoNotExistsException, WrongAttributeAssignmentException,
AttributeNotExistsException, GroupNotExistsException
throws PrivilegeException, RegistrarException, WrongAttributeAssignmentException,
AttributeNotExistsException
{
// get root group for resources hierarchy
Group resourceOriginGroup = getResourceOriginGroup(session, app, perun);
Expand Down Expand Up @@ -189,13 +188,13 @@ private String getResourceIdAttributeName(PerunSession session, Application app,
* @return resource IDs set
*/
private Group getResourceOriginGroup(PerunSession session, Application app, PerunBl perun)
throws PrivilegeException, RegistrarException, VoNotExistsException
throws PrivilegeException, RegistrarException
{
try {
if (perun.getAttributesManagerBl()
Boolean resourceOriginEnabled = perun.getAttributesManagerBl()
.getAttribute(session, app.getGroup(), RESOURCE_ORIGIN_ENABLED_ATTR_NAME)
.valueAsBoolean()
) {
.valueAsBoolean();
if (resourceOriginEnabled != null && resourceOriginEnabled) {
try {
String resourceOriginGroupName = getResourceOriginGroupNameFromApplication(session, app);
return perun.getGroupsManagerBl().getGroupByName(session, app.getVo(), resourceOriginGroupName);
Expand Down Expand Up @@ -290,7 +289,7 @@ private Map<String, Group> getResourceIDsToGroupsMap(PerunSession session,
{
Map<String, Group> resourceIDsToGroupMap = new HashMap<>();

List<Group> resourceGroups = perun.getGroupsManagerBl().getSubGroups(session, resourceOriginGroup);
List<Group> resourceGroups = perun.getGroupsManagerBl().getAllSubGroups(session, resourceOriginGroup);
if (resourceGroups == null || resourceGroups.isEmpty()) {
log.debug("No resource groups found, returning empty map.");
return resourceIDsToGroupMap;
Expand Down

0 comments on commit 12161d2

Please sign in to comment.