diff --git a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/AbstractGroupSynchronizer.java b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/AbstractGroupSynchronizer.java index a36b13fe23..852178064f 100644 --- a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/AbstractGroupSynchronizer.java +++ b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/AbstractGroupSynchronizer.java @@ -155,15 +155,19 @@ public GroupLink synchronize(CanonicalGroup canonical) { updateLabelTranslations(canonical, group); } + link = externalGroupLinks.save(getSyncElements(group, canonical, link)); + assert link.isUpToDateWith(canonical); + + return link; + } + + protected GroupLink getSyncElements(Group group, CanonicalGroup canonical, GroupLink link) { logoUpdater.synchronize(canonical.getId(), group); group.setName(canonical.getName()); group.setDescription(canonical.getDescription()); group.setWebsite(canonical.getLinkage()); group.setEmail(canonical.getMail()); link.setCanonical(canonical); - link = externalGroupLinks.save(link); - assert link.isUpToDateWith(canonical); - return link; } diff --git a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/RolesBasedGroupSynchronizer.java b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/RolesBasedGroupSynchronizer.java index ea2c163f8b..cec1354adc 100644 --- a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/RolesBasedGroupSynchronizer.java +++ b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/RolesBasedGroupSynchronizer.java @@ -27,6 +27,7 @@ import java.util.stream.IntStream; import java.util.stream.Stream; +import org.fao.geonet.domain.Group; import org.geonetwork.security.external.configuration.ExternalizedSecurityProperties; import org.geonetwork.security.external.model.CanonicalGroup; import org.geonetwork.security.external.model.CanonicalUser; @@ -124,4 +125,11 @@ private boolean doesNotMatchesGeorchestraDefaultRoleNameFilter(CanonicalGroup ro return doesNotMatchesGeorchestraDefaultRoleNameFilter(role.getName()); } + @Override + protected GroupLink getSyncElements(Group group, CanonicalGroup canonical, GroupLink link) { + group.setName(canonical.getName()); + group.setDescription(canonical.getDescription()); + link.setCanonical(canonical); + return link; + } } diff --git a/georchestra-integration/externalized-accounts/src/test/java/org/geonetwork/security/external/integration/IntegrationTestSupport.java b/georchestra-integration/externalized-accounts/src/test/java/org/geonetwork/security/external/integration/IntegrationTestSupport.java index 4da71202a9..261b22b72c 100644 --- a/georchestra-integration/externalized-accounts/src/test/java/org/geonetwork/security/external/integration/IntegrationTestSupport.java +++ b/georchestra-integration/externalized-accounts/src/test/java/org/geonetwork/security/external/integration/IntegrationTestSupport.java @@ -186,7 +186,9 @@ public GroupLink assertGroupLink(CanonicalGroup expected) { public void assertGroup(CanonicalGroup expected, Group actual) { assertEquals(expected.getName(), actual.getName()); assertEquals(expected.getDescription(), actual.getDescription()); - assertEquals(expected.getLinkage(), actual.getWebsite()); + if (!getConfig().getSyncMode().equals(GroupSyncMode.roles)) { + assertEquals(expected.getLinkage(), actual.getWebsite()); + } } public void addGeonetworkGroup(CanonicalGroup g) {