From 8d39c5f38783235f93a5a8116dcea4b02ddaecde Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Tue, 17 Apr 2018 08:56:30 +0200
Subject: [PATCH] OO-3436: if the admin user is not configured or doesn't
 exist, do nothing but write a message in log

---
 .../org/olat/group/manager/BusinessGroupServiceImpl.java  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java
index f9a92d67fff..45b5077e794 100644
--- a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java
+++ b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java
@@ -192,8 +192,12 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD
 			businessGroupRelationDAO.removeRole(identity, businessGroup, GroupRoles.coach.name());
 			if (businessGroupRelationDAO.countRoles(businessGroup, GroupRoles.coach.name()) == 0) {
 				Identity admin = deletionManager.getAdminUserIdentity();
-				businessGroupRelationDAO.addRole(admin, businessGroup, GroupRoles.coach.name());
-				log.info("Delete user-data, add Administrator-identity as owner of businessGroup=" + businessGroup.getName());
+				if(admin == null) {
+					log.info("Delete user-data, cannot add Administrator-identity as owner of businessGroup=" + businessGroup.getName() + ". Businesgroup is orphan");
+				} else {
+					businessGroupRelationDAO.addRole(admin, businessGroup, GroupRoles.coach.name());
+					log.info("Delete user-data, add Administrator-identity as owner of businessGroup=" + businessGroup.getName());
+				}
 			}
 		}
 		log.debug("Remove owner identity=" + identity + " from " + ownerGroups.size() + " groups");
-- 
GitLab