From c3e90a27e11e72c5728452a7eed9162854cda1e6 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Tue, 24 Jan 2023 19:22:03 +0100 Subject: [PATCH] Removed another final modifier --- .../assets/AbstractAssetImExporter.java | 28 +++++++++++++++---- .../AbstractContentItemImExporter.java | 17 ++++++++++- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/ccm-cms/src/main/java/org/librecms/assets/AbstractAssetImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/AbstractAssetImExporter.java index 5356bef8c..8c9e3da44 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/AbstractAssetImExporter.java +++ b/ccm-cms/src/main/java/org/librecms/assets/AbstractAssetImExporter.java @@ -45,18 +45,18 @@ public abstract class AbstractAssetImExporter @Inject @Any private ItemAttachmentImExporter itemAttachmentImExporter; - + @PostConstruct @Override protected final void init() { // ItemAttachmentImExporter requires that all assets to be imported itemAttachmentImExporter.addRequiredEntities(Set.of(getEntityClass())); - + initAssetImExporter(); } - + protected abstract void initAssetImExporter(); - + @Override protected Optional findExistingEntity(final String uuid) { return assetRepo.findByUuidAndType(uuid, getEntityClass()); @@ -67,8 +67,24 @@ public abstract class AbstractAssetImExporter assetRepo.save(asset); } + /** + * Implementation of + * {@link AbstractEntityImExporter#updateExistingEntity(org.libreccm.imexport.Exportable, org.libreccm.imexport.Exportable)} + * for {@link Asset}s. + * + * !!!Warning: ImExporters for assets MUST never override this method. + * Instead, they MUST implement + * {@link #updateExistingAsset(org.librecms.contentsection.Asset, org.librecms.contentsection.Asset)}. + * + * Unfortunetly, CDI does not support final methods, therefore we can't make + * this method final. + * + * + * @param existingEntity The existing entity. + * @param importedEntity The imported entity. + */ @Override - protected final void updateExistingEntity( + protected void updateExistingEntity( final T existingEntity, final T importedEntity ) { if (!Objects.equals( @@ -77,7 +93,7 @@ public abstract class AbstractAssetImExporter )) { existingEntity.setDisplayName(importedEntity.getDisplayName()); } - + if (!Objects.equals( existingEntity.getTitle(), importedEntity.getTitle() diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/AbstractContentItemImExporter.java b/ccm-cms/src/main/java/org/librecms/contentsection/AbstractContentItemImExporter.java index 3ba5e3d5b..c066db1f7 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/AbstractContentItemImExporter.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/AbstractContentItemImExporter.java @@ -100,6 +100,21 @@ public abstract class AbstractContentItemImExporter itemRepository.save(entity); } + /** + * Implementation of + * {@link AbstractEntityImExporter#updateExistingEntity(org.libreccm.imexport.Exportable, org.libreccm.imexport.Exportable)} + * for {@link ContentItem}s. + * + * !!!Warning: Implementations of this abstract class MUST NEVER override + * this method. Instead they MUST override + * {@link #updateExistingContentItem(org.librecms.contentsection.ContentItem, org.librecms.contentsection.ContentItem)}. + * + * Unfortunetly, CDI does not support final methods, therefore we can't make + * this method final. + * + * @param existingEntity + * @param importedEntity + */ @Override protected void updateExistingEntity( final T existingEntity, @@ -205,7 +220,7 @@ public abstract class AbstractContentItemImExporter importedEntity.getLastModifyingUserName() ); } - + updateExistingContentItem(existingEntity, importedEntity); itemRepository.save(existingEntity);