From ccfaa6f289ab20ce74b8440598c960ed30e8d0f3 Mon Sep 17 00:00:00 2001 From: Roy Teeuwen Date: Mon, 16 Sep 2024 20:09:28 +0200 Subject: [PATCH] fixes issue for deleting keys that did not have a translation yet --- .../impl/CombiningMessageEntryResourceProvider.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/be/orbinson/aem/dictionarytranslator/services/impl/CombiningMessageEntryResourceProvider.java b/core/src/main/java/be/orbinson/aem/dictionarytranslator/services/impl/CombiningMessageEntryResourceProvider.java index d923bc02..24ef1650 100644 --- a/core/src/main/java/be/orbinson/aem/dictionarytranslator/services/impl/CombiningMessageEntryResourceProvider.java +++ b/core/src/main/java/be/orbinson/aem/dictionarytranslator/services/impl/CombiningMessageEntryResourceProvider.java @@ -17,6 +17,8 @@ import java.util.*; +import static be.orbinson.aem.dictionarytranslator.utils.DictionaryConstants.SLING_MESSAGEENTRY; + @Component( service = ResourceProvider.class, property = { @@ -45,8 +47,8 @@ private Map getValuesAndMessageEntryPaths(Resource dictionaryRes Resource languageResource = dictionaryService.getLanguageResource(dictionaryResource, language); if (languageResource != null) { Resource messageEntryResource = dictionaryService.getMessageEntryResource(languageResource, key); - if (messageEntryResource != null && (messageEntryResource.getValueMap().containsKey(DictionaryConstants.SLING_MESSAGE))) { - properties.put(language, messageEntryResource.getValueMap().get(DictionaryConstants.SLING_MESSAGE, String.class)); + if (messageEntryResource != null && messageEntryResource.isResourceType(DictionaryConstants.SLING_MESSAGEENTRY)) { + properties.put(language, messageEntryResource.getValueMap().get(DictionaryConstants.SLING_MESSAGE, "")); messageEntryPaths.add(messageEntryResource.getPath()); } } @@ -96,7 +98,7 @@ private boolean isMessageEntry(Resource dictionaryResource, String key) { Resource languageResource = dictionaryService.getLanguageResource(dictionaryResource, language); if (languageResource != null) { Resource messageEntryResource = dictionaryService.getMessageEntryResource(languageResource, key); - if (messageEntryResource != null && messageEntryResource.isResourceType(DictionaryConstants.SLING_MESSAGEENTRY)) { + if (messageEntryResource != null && messageEntryResource.isResourceType(SLING_MESSAGEENTRY)) { return true; } }