From aad95f47b24d246a2fbff2a490a3dac2215fb025 Mon Sep 17 00:00:00 2001 From: Pierre Mauduit Date: Thu, 7 Sep 2023 18:17:20 +0200 Subject: [PATCH 1/2] geor-integration - synchronizing georchestra organizations mail attribute Note: this will require the following PR to be first merged in geOrchestra: https://github.com/georchestra/georchestra/pull/4028 Runtime tested with a local docker composition, the geonetwork.Groups table looking like the following afterwards: ``` georchestra=# select * from geonetwork.groups; id | description | email | enablecategoriesrestriction | logo | name | referrer | website | defaultcategory_id -----+-----------------------------+----------------------------+-----------------------------+--------------------------------------+----------+----------+------------------------------+-------------------- -1 | self-registered users | | n | | GUEST | | | 0 | | | n | | intranet | | | 1 | | | n | | all | | | 2 | | | n | | sample | | | 100 | Camptocamp SAS France | georchestra@camptocamp.com | n | | C2C | | https://www.camptocamp.com/ | 101 | Association PSC geOrchestra | psc@georchestra.org | n | bddf474d-125d-4b18-92bd-bd8ebb6699a9 | PSC | | https://www.georchestra.org/ | (6 rows) ``` --- .../integration/AbstractGroupSynchronizer.java | 3 ++- .../security/external/model/CanonicalGroup.java | 2 ++ .../external/model/CanonicalGroupImpl.java | 14 ++++++++++++++ .../security/integration/CanonicalModelMapper.java | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) 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 a4f812f720..4956267686 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 @@ -134,7 +134,7 @@ public GroupLink synchronize(CanonicalGroup canonical) { Group group = this.gnGroupRepository.findByName(canonical.getName()); if (null == group) { group = new Group(); - log.info("Creatinng GN group {} (Id: {}, version '{}')", // + log.info("Creating GN group {} (Id: {}, version '{}')", // canonical.getName(), canonical.getId(), canonical.getLastUpdated()); } else { log.info("Reconciling existing GN group {} with canonical group (id: {})", group.getName(), @@ -157,6 +157,7 @@ public GroupLink synchronize(CanonicalGroup canonical) { 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); diff --git a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/model/CanonicalGroup.java b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/model/CanonicalGroup.java index 54b8f4dc89..0d905f4a27 100644 --- a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/model/CanonicalGroup.java +++ b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/model/CanonicalGroup.java @@ -68,6 +68,8 @@ public interface CanonicalGroup { */ String getLinkage(); + String getMail(); + static CanonicalGroupImpl.Builder builder() { return CanonicalGroupImpl.builder(); } diff --git a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/model/CanonicalGroupImpl.java b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/model/CanonicalGroupImpl.java index 2d06c26086..9c32c29c67 100644 --- a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/model/CanonicalGroupImpl.java +++ b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/model/CanonicalGroupImpl.java @@ -41,6 +41,7 @@ public class CanonicalGroupImpl implements CanonicalGroup { private String linkage; private String orgTitle; + private String orgMail; private GroupSyncMode origin; @Generated("SparkTools") @@ -52,6 +53,7 @@ private CanonicalGroupImpl(Builder builder) { this.lastUpdated = builder.lastUpdated; this.origin = builder.origin; this.orgTitle = builder.orgTitle; + this.orgMail = builder.orgMail; } public @Override String getId() { @@ -78,6 +80,9 @@ private CanonicalGroupImpl(Builder builder) { return linkage; } + @Override + public String getMail() { return orgMail; } + public @Override String getLastUpdated() { return lastUpdated; } @@ -122,6 +127,8 @@ public static final class Builder { private String linkage; private String lastUpdated; private String orgTitle; + + private String orgMail; private GroupSyncMode origin; private Builder() { @@ -135,6 +142,7 @@ public Builder init(CanonicalGroup group) { this.linkage = group.getLinkage(); this.lastUpdated = group.getLastUpdated(); this.origin = group.getOrigin(); + this.orgMail = group.getMail(); return this; } @@ -173,6 +181,12 @@ public Builder withOrigin(GroupSyncMode origin) { return this; } + public Builder withMail(String mail) { + this.orgMail = mail; + return this; + } + + public CanonicalGroup build() { return new CanonicalGroupImpl(this); } diff --git a/georchestra-integration/georchestra-authnz/src/main/java/org/georchestra/geonetwork/security/integration/CanonicalModelMapper.java b/georchestra-integration/georchestra-authnz/src/main/java/org/georchestra/geonetwork/security/integration/CanonicalModelMapper.java index c542797d28..c6f5039a8e 100644 --- a/georchestra-integration/georchestra-authnz/src/main/java/org/georchestra/geonetwork/security/integration/CanonicalModelMapper.java +++ b/georchestra-integration/georchestra-authnz/src/main/java/org/georchestra/geonetwork/security/integration/CanonicalModelMapper.java @@ -55,6 +55,7 @@ public CanonicalGroup toCanonical(Organization org) { .withLastUpdated(org.getLastUpdated())// .withLinkage(org.getLinkage())// .withOrigin(GroupSyncMode.orgs)// + .withMail(org.getMail())// .build(); } From a853dd611a4e50a8bb6bc7e1b87147d1a442b3cf Mon Sep 17 00:00:00 2001 From: Pierre Mauduit Date: Thu, 7 Sep 2023 18:20:27 +0200 Subject: [PATCH 2/2] geor-integration - fixing georchestra version current master indicates 23.1-SNAPSHOT. --- georchestra-integration/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/georchestra-integration/pom.xml b/georchestra-integration/pom.xml index 0da15e9254..84ab0ec5a9 100644 --- a/georchestra-integration/pom.xml +++ b/georchestra-integration/pom.xml @@ -12,7 +12,7 @@ geOrchestra integration ${basedir}/.. - 23.0.3-SNAPSHOT + 23.1-SNAPSHOT georchestra-utils