Skip to content

Commit

Permalink
Merge branch 'release2.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
sporth committed Oct 15, 2024
2 parents de4fb24 + 2ff4027 commit 4dd085c
Showing 1 changed file with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import edu.internet2.tier.shibboleth.admin.ui.security.repository.UserRepository;
import edu.internet2.tier.shibboleth.admin.ui.security.service.IGroupService;
import edu.internet2.tier.shibboleth.admin.ui.security.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
Expand All @@ -23,6 +25,7 @@
*/
@Component
public class MigrationTasksContextLoadedListener implements ApplicationListener<ContextRefreshedEvent> {
private static final Logger log = LoggerFactory.getLogger(MigrationTasksContextLoadedListener.class);
private static boolean attrBundleMigrated = false;

@Autowired
Expand Down Expand Up @@ -81,20 +84,27 @@ void doshibui_1740_migration() {

@Transactional
void doAttributeBundleMigration() {
attributeBundleRepository.migrateData();
attributeBundleRepository.findAll().forEach(attrBundleEntry -> {
try {
Set<String> names = new HashSet<String>();
attrBundleEntry.getAttributeNames().forEach(value -> {
names.add(BundleableAttributeType.values()[Integer.parseInt(value)].label());
});
attrBundleEntry.setAttributeNames(names);
attributeBundleRepository.save(attrBundleEntry);
}
catch (NumberFormatException ignore) {
}
});
attrBundleMigrated = true;
attributeBundleRepository.clearMigratedValues();
try {
attributeBundleRepository.migrateData();
attributeBundleRepository.findAll().forEach(attrBundleEntry -> {
try {
Set<String> names = new HashSet<String>();
attrBundleEntry.getAttributeNames().forEach(value -> {
names.add(BundleableAttributeType.values()[Integer.parseInt(value)].label());
});
attrBundleEntry.setAttributeNames(names);
attributeBundleRepository.save(attrBundleEntry);
}
catch (NumberFormatException ignore) {
}
});
attrBundleMigrated = true;
attributeBundleRepository.clearMigratedValues();
}
catch (Throwable e){
// can happen if the db is new, skip trying to do this
log.error("You may safely ignore: *** ERROR: relation \"attribute_bundle_definition_attributes\" does not exist ***");
attrBundleMigrated = true;
}
}
}

0 comments on commit 4dd085c

Please sign in to comment.