Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content Fragment Model unnecessarily/incompletely implements ContainerExporter #2860

Open
HitmanInWis opened this issue Sep 20, 2024 · 0 comments

Comments

@HitmanInWis
Copy link

ContentFragment interface unnecessarily extends ContainerExporter
ContentFragmentImpl unnecessarily implements ContainerExporterImpl

This results in confusing and unnecessary code implementing getExportedItems() and getExportedItemsOrder() which always results in empty values in practical use. Looking at all of the test cases for ContentFragmentImplTest, all of the export values for items and itemsOrder are always empty.

Just a bunch of unnecessary code that can be removed:

Index: bundles/core/src/test/resources/contentfragment/exporter-structured.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-structured.json b/bundles/core/src/test/resources/contentfragment/exporter-structured.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-structured.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-structured.json	(date 1726858347038)
@@ -7,8 +7,6 @@
         "main",
         "second"
     ],
-    ":items": {},
-    ":itemsOrder": [],
     ":type": "core/wcm/components/contentfragment/v1/contentfragment",
     "elements": {
         "main": {
Index: bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/contentfragment/ContentFragment.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/contentfragment/ContentFragment.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/contentfragment/ContentFragment.java
--- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/contentfragment/ContentFragment.java	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/contentfragment/ContentFragment.java	(date 1726858256403)
@@ -15,16 +15,10 @@
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 package com.adobe.cq.wcm.core.components.models.contentfragment;
 
-import java.util.Collections;
-import java.util.Map;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import com.adobe.cq.export.json.ComponentExporter;
-import com.adobe.cq.export.json.ContainerExporter;
 import com.adobe.cq.wcm.core.components.models.Component;
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Defines the Sling model for the {@code /apps/core/wcm/components/contentfragment} component. The model
@@ -32,7 +26,7 @@
  *
  * @since com.adobe.cq.wcm.core.components.models.contentfragment 1.0.0
  */
-public interface ContentFragment extends DAMContentFragment, ContainerExporter, Component {
+public interface ContentFragment extends DAMContentFragment, Component {
 
     /**
      * Name of the mandatory resource property that stores the path to a content fragment.
@@ -75,28 +69,6 @@
         return "";
     }
 
-    /**
-     * Returns the map of all exported child items (resource names from Sling Model classes).
-     *
-     * @since com.adobe.cq.wcm.core.components.models.contentfragment 1.0.0
-     */
-    @NotNull
-    @Override
-    default Map<String, ? extends ComponentExporter> getExportedItems() {
-        return Collections.emptyMap();
-    }
-
-    /**
-     * Returns the order of items in the map.
-     *
-     * @since com.adobe.cq.wcm.core.components.models.contentfragment 1.0.0
-     */
-    @NotNull
-    @Override
-    default String[] getExportedItemsOrder() {
-        return new String[]{};
-    }
-
     /**
      * Returns the type of the resource for which the export is performed.
      *
Index: bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/contentfragment/ContentFragmentImpl.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/contentfragment/ContentFragmentImpl.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/contentfragment/ContentFragmentImpl.java
--- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/contentfragment/ContentFragmentImpl.java	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/contentfragment/ContentFragmentImpl.java	(date 1726858256398)
@@ -42,7 +42,6 @@
 import com.adobe.cq.dam.cfm.content.FragmentRenderService;
 import com.adobe.cq.dam.cfm.converter.ContentTypeConverter;
 import com.adobe.cq.export.json.ComponentExporter;
-import com.adobe.cq.export.json.ContainerExporter;
 import com.adobe.cq.export.json.ExporterConstants;
 import com.adobe.cq.wcm.core.components.internal.ContentFragmentUtils;
 import com.adobe.cq.wcm.core.components.util.AbstractComponentImpl;
@@ -58,7 +57,6 @@
         adapters = {
                 ContentFragment.class,
                 DAMContentFragment.class,
-                ContainerExporter.class,
                 ComponentExporter.class
         },
         resourceType = ContentFragmentImpl.RESOURCE_TYPE
@@ -184,18 +182,6 @@
         return slingHttpServletRequest.getResource().getResourceType();
     }
 
-    @NotNull
-    @Override
-    public Map<String, ? extends ComponentExporter> getExportedItems() {
-        return ContentFragmentUtils.getComponentExporters(resource.listChildren(), modelFactory, slingHttpServletRequest, resource);
-    }
-
-    @NotNull
-    @Override
-    public String[] getExportedItemsOrder() {
-        return ContentFragmentUtils.getItemsOrder(getExportedItems());
-    }
-
     @Nullable
     @Override
     public String[] getParagraphs() {
Index: bundles/core/src/test/resources/contentfragment/exporter-structured-non-existing-variation.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-structured-non-existing-variation.json b/bundles/core/src/test/resources/contentfragment/exporter-structured-non-existing-variation.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-structured-non-existing-variation.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-structured-non-existing-variation.json	(date 1726858347156)
@@ -24,8 +24,6 @@
             "multiValue": true
         }
     },
-    ":items": {},
-    ":itemsOrder": [],
     "elementsOrder": [
         "main",
         "second"
Index: bundles/core/src/test/resources/contentfragment/exporter-structured-multiple-elements.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-structured-multiple-elements.json b/bundles/core/src/test/resources/contentfragment/exporter-structured-multiple-elements.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-structured-multiple-elements.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-structured-multiple-elements.json	(date 1726858347085)
@@ -21,8 +21,6 @@
             "multiValue": false
         }
     },
-    ":items": {},
-    ":itemsOrder": [],
     "elementsOrder": [
         "second",
         "main"
Index: bundles/core/src/test/resources/contentfragment/exporter-structured-nested-model.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-structured-nested-model.json b/bundles/core/src/test/resources/contentfragment/exporter-structured-nested-model.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-structured-nested-model.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-structured-nested-model.json	(date 1726858347023)
@@ -21,8 +21,6 @@
             "multiValue": true
         }
     },
-    ":items": {},
-    ":itemsOrder": [],
     "elementsOrder": [
         "main",
         "second"
Index: bundles/core/src/test/resources/contentfragment/exporter-text-only-non-existing-variation.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-text-only-non-existing-variation.json b/bundles/core/src/test/resources/contentfragment/exporter-text-only-non-existing-variation.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-text-only-non-existing-variation.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-text-only-non-existing-variation.json	(date 1726858347147)
@@ -3,8 +3,6 @@
     "description": "This is a test content fragment.",
     "title": "Test Content Fragment",
     "model": "/content/dam/contentfragments/text-only/jcr:content/model",
-    ":items": {},
-    ":itemsOrder": [],
     "elementsOrder": [
         "main",
         "second"
Index: bundles/core/src/test/resources/contentfragment/exporter-text-only-multiple-elements.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-text-only-multiple-elements.json b/bundles/core/src/test/resources/contentfragment/exporter-text-only-multiple-elements.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-text-only-multiple-elements.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-text-only-multiple-elements.json	(date 1726858347116)
@@ -18,8 +18,6 @@
             "multiValue": false
         }
     },
-    ":items": {},
-    ":itemsOrder": [],
     "elementsOrder": [
         "second",
         "main"
Index: bundles/core/src/test/resources/contentfragment/exporter-structured-variation.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-structured-variation.json b/bundles/core/src/test/resources/contentfragment/exporter-structured-variation.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-structured-variation.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-structured-variation.json	(date 1726858347069)
@@ -21,8 +21,6 @@
             "multiValue": true
         }
     },
-    ":items": {},
-    ":itemsOrder": [],
     "elementsOrder": [
         "main",
         "second"
Index: bundles/core/src/test/resources/contentfragment/exporter-structured-single-element.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-structured-single-element.json b/bundles/core/src/test/resources/contentfragment/exporter-structured-single-element.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-structured-single-element.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-structured-single-element.json	(date 1726858346991)
@@ -15,8 +15,6 @@
             "multiValue": true
         }
     },
-    ":items": {},
-    ":itemsOrder": [],
     "elementsOrder": [
         "second"
     ]
Index: bundles/core/src/test/resources/contentfragment/exporter-text-only.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-text-only.json b/bundles/core/src/test/resources/contentfragment/exporter-text-only.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-text-only.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-text-only.json	(date 1726858347006)
@@ -18,8 +18,6 @@
             ":type": "text/plain"
         }
     },
-    ":items": {},
-    ":itemsOrder": [],
     "elementsOrder": [
         "main",
         "second"
Index: bundles/core/src/test/resources/contentfragment/exporter-structured-single-element-main.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-structured-single-element-main.json b/bundles/core/src/test/resources/contentfragment/exporter-structured-single-element-main.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-structured-single-element-main.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-structured-single-element-main.json	(date 1726858347171)
@@ -6,8 +6,6 @@
     ],
     "title": "Test Content Fragment",
     "model": "global/models/test",
-    ":items": {},
-    ":itemsOrder": [],
     "elementsOrder": [
         "main"
     ],
Index: bundles/core/src/test/resources/contentfragment/exporter-text-only-single-element.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-text-only-single-element.json b/bundles/core/src/test/resources/contentfragment/exporter-text-only-single-element.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-text-only-single-element.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-text-only-single-element.json	(date 1726858347054)
@@ -3,8 +3,6 @@
     "description": "This is a test content fragment.",
     "title": "Test Content Fragment",
     "model": "/content/dam/contentfragments/text-only/jcr:content/model",
-    ":items": {},
-    ":itemsOrder": [],
     "elementsOrder": [
         "second"
     ],
Index: bundles/core/src/test/resources/contentfragment/exporter-text-only-variation.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/core/src/test/resources/contentfragment/exporter-text-only-variation.json b/bundles/core/src/test/resources/contentfragment/exporter-text-only-variation.json
--- a/bundles/core/src/test/resources/contentfragment/exporter-text-only-variation.json	(revision d2a7b02405db241fadbad02a4878f8770b36e246)
+++ b/bundles/core/src/test/resources/contentfragment/exporter-text-only-variation.json	(date 1726858347101)
@@ -3,8 +3,6 @@
     "description": "This is a test content fragment.",
     "title": "Test Content Fragment",
     "model": "/content/dam/contentfragments/text-only/jcr:content/model",
-    ":items": {},
-    ":itemsOrder": [],
     "elementsOrder": [
         "main",
         "second"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant