diff --git a/ccm-core/src/main/java/org/libreccm/imexport/AbstractEntityImExporter.java b/ccm-core/src/main/java/org/libreccm/imexport/AbstractEntityImExporter.java index 99ff678fe..52755e2ad 100644 --- a/ccm-core/src/main/java/org/libreccm/imexport/AbstractEntityImExporter.java +++ b/ccm-core/src/main/java/org/libreccm/imexport/AbstractEntityImExporter.java @@ -51,7 +51,7 @@ import javax.transaction.Transactional; public abstract class AbstractEntityImExporter { private final ObjectMapper objectMapper; - + @Inject private EntityManager entityManager; @@ -163,12 +163,12 @@ public abstract class AbstractEntityImExporter { if (existingEntityResult.isPresent()) { final T existingEntity = existingEntityResult.get(); updateExistingEntity(existingEntity, importedEntity); - + entityManager.flush(); return existingEntity; } else { saveImportedEntity(importedEntity); - + entityManager.flush(); return importedEntity; } @@ -255,7 +255,7 @@ public abstract class AbstractEntityImExporter { /** * Reloads the entity to export. Entities become detacted for several * reasons before they are passed to the null null null null null null null - * null null null null null null null {@link #exportEntity(org.libreccm.imexport.Exportable) method. The + * null null null null null null null null {@link #exportEntity(org.libreccm.imexport.Exportable) method. The * implementation of this should reload the passed entity. * * @param entity The entity to reload. @@ -278,6 +278,9 @@ public abstract class AbstractEntityImExporter { final LocalizedString source, final LocalizedString target ) { + if (source == null || target == null) { + return; + } final Set localesToAdd = source .getAvailableLocales() .stream() @@ -286,16 +289,6 @@ public abstract class AbstractEntityImExporter { ) .collect(Collectors.toSet()); - final Set localesToRemove = target - .getAvailableLocales() - .stream() - .filter(locale -> !source.getAvailableLocales().contains(locale)) - .collect(Collectors.toSet()); - - for (final Locale toRemove : localesToRemove) { - target.removeValue(toRemove); - } - for (final Locale toAdd : localesToAdd) { target.putValue(toAdd, source.getValue(toAdd)); }