Skip to content

Commit

Permalink
Handle broken LDAP group subscription while refreshing cache
Browse files Browse the repository at this point in the history
  • Loading branch information
fdaugan committed Jul 14, 2023
1 parent 7479355 commit 937a234
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/org/ligoj/app/plugin/id/dao/IdCacheDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private int persistUsersAndMemberships(final Map<String, UserOrg> users, final M
});
}

// Remove old users
// Remove old users and related membership
deleteOldCacheEntities(CacheUser.class, cacheUsers, users, u ->
em.createQuery("DELETE FROM CacheMembership WHERE user.id=:user")
.setParameter("user", u)
Expand Down Expand Up @@ -455,19 +455,19 @@ public void reset(final Map<String, CompanyOrg> companies, final Map<String, Gro
// Remove old groups and companies
deleteOldCacheEntities(CacheGroup.class, oldGroups, groups, g -> {
log.info("Deleting removed cache entry {}#{} (sub/groups)", CacheMembership.class.getSimpleName(), g);
em.createQuery("DELETE FROM CacheMembership WHERE group.id=:group OR subGroup.id=:group")
.setParameter("group", g)
.executeUpdate();
em.createQuery("DELETE FROM CacheMembership WHERE group.id=:group OR subGroup.id=:group")
.setParameter("group", g)
.executeUpdate();
em.createQuery("DELETE FROM CacheProjectGroup WHERE group.id=:group")
.setParameter("group", g)
.executeUpdate();
}
);

deleteOldCacheEntities(CacheCompany.class, oldCompanies, companies, null);
em.flush();

em.clear();

// Cleanup, remove deleted

log.info("Updated cache: {} groups, {} companies, {} users, {} memberships, {} project groups, {} updated delegates in {}",
groups.size(), companies.size(), users.size(), memberships, subscribedProjects, updatedDelegate,
DurationFormatUtils.formatDurationHMS(System.currentTimeMillis() - start));
Expand Down

0 comments on commit 937a234

Please sign in to comment.