From 0d00794ffbf5b2412dff33823d6a27aa09804151 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Tue, 24 Jan 2023 19:03:25 +0100 Subject: [PATCH] Removal of final modifier from a method since that prevents CDI from proxying the bean. --- .../imexport/AbstractEntityImExporter.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) 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 3f4ac15af..f936d00da 100644 --- a/ccm-core/src/main/java/org/libreccm/imexport/AbstractEntityImExporter.java +++ b/ccm-core/src/main/java/org/libreccm/imexport/AbstractEntityImExporter.java @@ -204,8 +204,8 @@ public abstract class AbstractEntityImExporter { * values of the imported entity. Related entities must not be updated by an * implementation, expect for embedded entities. * - * @param existingEntity The existing entity. - * @param withImportedEntity The imported entity. + * @param existingEntity The existing entity. + * @param withImportedEntity The imported entity. * * @see #importEntity(java.lang.String) * @see #findExistingEntity(java.lang.String) @@ -246,7 +246,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 {@link #exportEntity(org.libreccm.imexport.Exportable) method. The + * 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. @@ -254,9 +254,18 @@ public abstract class AbstractEntityImExporter { * @return The reloaded entity */ protected abstract T reloadEntity(final T entity); - - - protected final void syncLocalizedStrings( + + /** + * A helper method to sync a localized string property. + * + * !!!Warning: CDI does not allow final methods to forbid overriding a + * method. Nevertheless this method should never be + * overriden by a child class!!! + * + * @param source The source property. + * @param target The target property. + */ + protected void syncLocalizedStrings( final LocalizedString source, final LocalizedString target ) { @@ -267,18 +276,18 @@ public abstract class AbstractEntityImExporter { locale -> !target.getAvailableLocales().contains(locale) ) .collect(Collectors.toSet()); - + final Set localesToRemove = target .getAvailableLocales() .stream() .filter(locale -> !source.getAvailableLocales().contains(locale)) .collect(Collectors.toSet()); - - for(final Locale toRemove : localesToRemove) { + + for (final Locale toRemove : localesToRemove) { target.removeValue(toRemove); } - - for(final Locale toAdd : localesToAdd) { + + for (final Locale toAdd : localesToAdd) { target.putValue(toAdd, source.getValue(toAdd)); } }