[java-metadata-aggregator] branch main updated: MDA-245 - Terminology changes

Ian Young ian at iay.org.uk
Wed May 8 13:40:13 UTC 2024


This is an automated email from the git hooks/post-receive script.

iay pushed a commit to branch main
in repository java-metadata-aggregator.

View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=e54b96ed68efc774612b31c4e788892862a62a08

The following commit(s) were added to refs/heads/main by this push:
     new e54b96e  MDA-245 - Terminology changes
e54b96e is described below

commit e54b96ed68efc774612b31c4e788892862a62a08
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed May 8 14:40:11 2024 +0100

    MDA-245 - Terminology changes
    
    https://shibboleth.atlassian.net/browse/MDA-245
    
    This class is new in 0.10.0, so no migration assistance is required.
---
 .../metadata/dom/ElementsStrippingStage.java       | 62 ++++++++++++----------
 .../metadata/dom/ElementsStrippingStageTest.java   | 12 ++---
 2 files changed, 41 insertions(+), 33 deletions(-)

diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java b/mda-framework/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java
index eab5fbd..198c613 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java
@@ -39,19 +39,26 @@ import net.shibboleth.shared.primitive.StringSupport;
 /**
  * A stage which removes all instances of the specified elements from DOM metadata.
  *
+ * <p>
  * The elements to be removed are specified by the combination of a namespace
  * (as in {@link ElementStrippingStage}) and a collection of names.
+ * </p>
  *
+ * <p>
  * The stage ignores all elements not in the specified namespace.
- * 
+ * </p>
+ *
+ * <p>
  * If an element is in the specified namespace, it is by default removed if its
- * local name is in the specified list of names. In other words, the list of names acts
- * by default as a blacklist of element names.
+ * local name is in the specified list of names.
+ * </p>
  *
- * The default behaviour can be changed if the <code>whitelisting</code> property
+ * <p>
+ * The default behaviour can be changed if the <code>keeping</code> property
  * is set. In this case, the stage still ignores any elements not in the specified
  * namespace, but elements within that namespace will be removed if their local names
  * do <i>not</i> appear in the collection of names.
+ * </p>
  *
  * @since 0.10.0
  */
@@ -85,8 +92,8 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
         @Nonnull @NonnullElements @Unmodifiable
         private final Collection<String> elementNames;
 
-        /** Whether we are operating in a whitelisting mode (<code>false</code> by default). */
-        private final boolean whitelisting;
+        /** Whether we are keeping or removing elements (<code>false</code> by default, implying removing). */
+        private final boolean keeping;
 
         /**
          * Constructor.
@@ -94,16 +101,16 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
          * @param contextItem the {@link Item} we are traversing
          * @param namespace XML namespace for each of the elements to handle
          * @param names collection of element names within the namespace
-         * @param wl whether the named elements should be removed (false) or preserved (true)
+         * @param keep whether the named elements should be removed (false) or preserved (true)
          */
         public Context(@Nonnull final Item<Element> contextItem,
                 @Nonnull @NotEmpty final String namespace,
                 @Nonnull @NonnullElements @Unmodifiable final Collection<String> names,
-                final boolean wl) {
+                final boolean keep) {
             super(contextItem);
             elementNamespace = namespace;
             elementNames = names;
-            whitelisting = wl;
+            keeping = keep;
         }
 
         /**
@@ -125,12 +132,12 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
         }
         
         /**
-         * Indicates whether the {@link #elementNames} are being used as a whitelist.
+         * Indicates whether we are keeping the designated elements.
          *
-         * @return <code>true</code> if the names are being used as a whitelist
+         * @return <code>true</code> if the designated elements are being kept
          */
-        protected final boolean isWhitelisting() {
-            return whitelisting;
+        protected final boolean isKeeping() {
+            return keeping;
         }
 
         /**
@@ -150,6 +157,7 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
         }
     }
 
+
     /** Namespace of the elements to strip. */
     @NonnullAfterInit @NotEmpty @GuardedBy("this")
     private String elementNamespace;
@@ -158,8 +166,8 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
     @Nonnull @NonnullElements @Unmodifiable @GuardedBy("this")
     private Set<String> elementNames = CollectionSupport.emptySet();
 
-    /** Whether we are operating in a whitelisting mode (<code>false</code> by default). */
-    private boolean whitelisting;
+    /** Whether we are keeping the designaed elements (<code>false</code> by default). */
+    private boolean keeping;
 
     /**
      * Get the namespace of the elements to strip.
@@ -203,23 +211,23 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
     }
 
     /**
-     * Set whether the {@link #elementNames} are to be used as a whitelist.
+     * Set whether the designated elements are to be kept.
      *
-     * The default behaviour is for the names to be used as a blacklist.
+     * The default behaviour is for the designated elements to be removed.
      *
-     * @param whitelist <code>true</code> if the names are to be used as a whitelist
+     * @param keep <code>true</code> if the designated elements are to be keot
      */
-    public void setWhitelisting(final boolean whitelist) {
-        whitelisting = whitelist;
+    public void setKeeping(final boolean keep) {
+        keeping = keep;
     }
 
     /**
-     * Indicates whether the {@link #elementNames} are being used as a whitelist.
+     * Indicates whether the designated elements are being kept or removed.
      *
-     * @return <code>true</code> if the names are being used as a whitelist
+     * @return <code>true</code> if the designated elements are being kept
      */
-    public boolean isWhitelisting() {
-        return whitelisting;
+    public boolean isKeeping() {
+        return keeping;
     }
 
     @Override
@@ -229,8 +237,8 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
             return false;
         }
 
-        // Whitelisting reverses the meaning of presence in the list
-        return context.isWhitelisting() ^ context.getElementNames().contains(element.getLocalName());
+        // "keeping" reverses the meaning of presence in the list
+        return context.isKeeping() ^ context.getElementNames().contains(element.getLocalName());
     }
 
     @Override
@@ -251,7 +259,7 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
     protected synchronized @Nonnull Context buildContext(@Nonnull final Item<Element> item) {
         final var ns = getElementNamespace();
         assert ns != null;
-        return new Context(item, ns, getElementNames(), isWhitelisting());
+        return new Context(item, ns, getElementNames(), isKeeping());
     }
 
 }
diff --git a/mda-framework/src/test/java/net/shibboleth/metadata/dom/ElementsStrippingStageTest.java b/mda-framework/src/test/java/net/shibboleth/metadata/dom/ElementsStrippingStageTest.java
index c824f77..9e031dd 100644
--- a/mda-framework/src/test/java/net/shibboleth/metadata/dom/ElementsStrippingStageTest.java
+++ b/mda-framework/src/test/java/net/shibboleth/metadata/dom/ElementsStrippingStageTest.java
@@ -39,7 +39,7 @@ public class ElementsStrippingStageTest extends BaseDOMTest {
 
     // Equivalent to the test for ElementStrippingStage
     @Test
-    public void singleElementBlacklist() throws Exception {
+    public void singleElementRemove() throws Exception {
         final Element doc = readXMLData("in-sb.xml");
         final Item<Element> item = new DOMElementItem(doc);
         final List<Item<Element>> items = new ArrayList<>();
@@ -61,7 +61,7 @@ public class ElementsStrippingStageTest extends BaseDOMTest {
     }
 
     @Test
-    public void singleElementWhitelist() throws Exception {
+    public void singleElementKeep() throws Exception {
         final Element doc = readXMLData("in-sw.xml");
         final Item<Element> item = new DOMElementItem(doc);
         final List<Item<Element>> items = new ArrayList<>();
@@ -73,7 +73,7 @@ public class ElementsStrippingStageTest extends BaseDOMTest {
         final List<String> names = new ArrayList<>();
         names.add("StripMe");
         stage.setElementNames(names);
-        stage.setWhitelisting(true);
+        stage.setKeeping(true);
         stage.initialize();
 
         stage.execute(items);
@@ -84,7 +84,7 @@ public class ElementsStrippingStageTest extends BaseDOMTest {
     }
 
     @Test
-    public void multiElementWhitelist() throws Exception {
+    public void multiElementKeep() throws Exception {
         final Element doc = readXMLData("in-multi.xml");
         final Item<Element> item = new DOMElementItem(doc);
         final List<Item<Element>> items = new ArrayList<>();
@@ -107,7 +107,7 @@ public class ElementsStrippingStageTest extends BaseDOMTest {
     }
 
     @Test
-    public void multiElementBlacklist() throws Exception {
+    public void multiElementRemove() throws Exception {
         final Element doc = readXMLData("in-multi.xml");
         final Item<Element> item = new DOMElementItem(doc);
         final List<Item<Element>> items = new ArrayList<>();
@@ -120,7 +120,7 @@ public class ElementsStrippingStageTest extends BaseDOMTest {
         names.add("one");
         names.add("three");
         stage.setElementNames(names);
-        stage.setWhitelisting(true);
+        stage.setKeeping(true);
         stage.initialize();
 
         stage.execute(items);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list