public void initGroups() { // After every migrate, ensure default Groups are setup correctly. Context context = null; try { context = new Context(); context.turnOffAuthorisationSystem(); // While it's not really a formal "registry", we need to ensure the // default, required Groups exist in the DSpace database groupService.initDefaultGroupNames(context); context.restoreAuthSystemState(); // Commit changes and close context context.complete(); } catch (Exception e) { log.error("Error attempting to add/update default DSpace Groups", e); throw new RuntimeException(e); } finally { // Clean up our context, if it still exists & it was never completed if (context != null && context.isValid()) { context.abort(); } } }