diff --git a/account-gui/pom.xml b/account-gui/pom.xml index f93d9609..ce55b950 100644 --- a/account-gui/pom.xml +++ b/account-gui/pom.xml @@ -4,7 +4,7 @@ org.openconext myconext - 7.3.3 + 7.3.4 ../pom.xml account-gui diff --git a/myconext-gui/pom.xml b/myconext-gui/pom.xml index 057b6758..f03f7553 100644 --- a/myconext-gui/pom.xml +++ b/myconext-gui/pom.xml @@ -4,7 +4,7 @@ org.openconext myconext - 7.3.3 + 7.3.4 ../pom.xml myconext-gui diff --git a/myconext-server/pom.xml b/myconext-server/pom.xml index ad073ab0..461aacea 100644 --- a/myconext-server/pom.xml +++ b/myconext-server/pom.xml @@ -4,7 +4,7 @@ org.openconext myconext - 7.3.3 + 7.3.4 ../pom.xml myconext-server diff --git a/myconext-server/src/main/java/myconext/model/EduID.java b/myconext-server/src/main/java/myconext/model/EduID.java index f3195500..1cb67095 100644 --- a/myconext-server/src/main/java/myconext/model/EduID.java +++ b/myconext-server/src/main/java/myconext/model/EduID.java @@ -42,13 +42,8 @@ public EduID(String value, ServiceProvider serviceProvider) { } public EduID updateServiceProvider(ServiceProvider serviceProvider) { - //We migrate to the situation that en eduID only has a unique value and multiple services - this.serviceProviderEntityId = null; - this.serviceName = null; - this.serviceNameNl = null; - this.serviceLogoUrl = null; - this.serviceHomeUrl = null; - this.serviceInstutionGuid = null; + //We migrate to the situation that an eduID only has a unique value and multiple services + //but the version for the migration also needs to work with this situation //We only consider an SP as the same SP, if the entityId's equal OR the institutionGUID's are equal and the entityId's are null Optional optionalServiceProvider = this.services.stream() .filter(sp -> (StringUtils.hasText(sp.getEntityId()) && sp.getEntityId().equals(serviceProvider.getEntityId())) || diff --git a/myconext-server/src/main/java/myconext/mongo/Migrations.java b/myconext-server/src/main/java/myconext/mongo/Migrations.java index 61b5f339..bfba5027 100644 --- a/myconext-server/src/main/java/myconext/mongo/Migrations.java +++ b/myconext-server/src/main/java/myconext/mongo/Migrations.java @@ -4,17 +4,18 @@ import com.github.cloudyrock.mongock.ChangeSet; import com.github.cloudyrock.mongock.driver.mongodb.springdata.v3.decorator.impl.MongockTemplate; import myconext.manage.Manage; -import myconext.manage.RemoteManage; import myconext.model.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.schema.JsonSchemaObject; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.time.temporal.ChronoUnit; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; @ChangeLog(order = "001") @@ -139,6 +140,26 @@ public void deleteSessionOneMore(MongockTemplate mongoTemplate) { mongoTemplate.remove(new Query(), "sessions"); } + @SuppressWarnings("unchecked") + @ChangeSet(order = "010", id = "bugfixForFaultyMigration", author = "okke.harsta@surf.nl") + public void bugfixForFaultyMigration(MongockTemplate mongoTemplate) { + List users = mongoTemplate.findAll(User.class, "users"); + users.forEach(user -> { + if (!CollectionUtils.isEmpty(user.getEduIDS())) { + AtomicBoolean userNeedsUpdate = new AtomicBoolean(false); + user.getEduIDS().forEach(eduID -> { + if (!StringUtils.hasText(eduID.getServiceProviderEntityId()) && !CollectionUtils.isEmpty(eduID.getServices()) ) { + eduID.backwardCompatibleTransformation(eduID.getServices().get(0)); + userNeedsUpdate.set(true); + } + }); + if (userNeedsUpdate.get()) { + mongoTemplate.save(user); + } + } + }); + } + protected User mergeEduIDs(User user) { List eduIDS = user.getEduIDS(); //Make a copy to search in diff --git a/pom.xml b/pom.xml index e02a0576..0ba8f886 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.openconext myconext - 7.3.3 + 7.3.4 pom myconext My OpenConext diff --git a/tiqr-mock/pom.xml b/tiqr-mock/pom.xml index 05eac1a4..102e2f80 100644 --- a/tiqr-mock/pom.xml +++ b/tiqr-mock/pom.xml @@ -4,7 +4,7 @@ org.openconext myconext - 7.3.3 + 7.3.4 ../pom.xml tiqr-mock