UIApplication uiApp = context.getUIApplication();
UIGroupExplorer uiGroupExplorer = uiGroupManagement.getChild(UIGroupExplorer.class);
Group currentGroup = uiGroupExplorer.getCurrentGroup();
if (currentGroup == null)
{
uiApp.addMessage(new ApplicationMessage("UIGroupManagement.msg.Edit", null));
return;
}
UIGroupForm groupForm = uiGroupManagement.findFirstComponentOfType(UIGroupForm.class);
if (groupForm.getGroupId() != null)
{
uiApp.addMessage(new ApplicationMessage("UIGroupManagement.msg.Delete", null));
return;
}
OrganizationService service = uiGroupManagement.getApplicationComponent(OrganizationService.class);
UserACL acl = uiGroupManagement.getApplicationComponent(UserACL.class);
List<String> mandatories = acl.getMandatoryGroups();
if (!mandatories.isEmpty() && isMandatory(service.getGroupHandler(), currentGroup, mandatories))
{
uiApp.addMessage(new ApplicationMessage("UIGroupManagement.msg.DeleteMandatory", null));
return;
}
String parentId = currentGroup.getParentId();
service.getGroupHandler().removeGroup(currentGroup, true);
uiGroupExplorer.changeGroup(parentId);