[java-metadata-aggregator] branch master updated: MDA-250 - Remove ItemMetadataSupport
Ian Young
ian at iay.org.uk
Thu Jul 9 10:23:18 UTC 2020
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository java-metadata-aggregator.
View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=70c7d51fb2ff0e6fbb26502ce1a20ff281d7d576
The following commit(s) were added to refs/heads/master by this push:
new 70c7d51 MDA-250 - Remove ItemMetadataSupport
70c7d51 is described below
commit 70c7d51fb2ff0e6fbb26502ce1a20ff281d7d576
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu Jul 9 11:23:14 2020 +0100
MDA-250 - Remove ItemMetadataSupport
https://issues.shibboleth.net/jira/browse/MDA-250
---
.../shibboleth/metadata/dom/DOMElementItem.java | 15 +++--
.../dom/MultiOutputXSLTransformationStage.java | 13 ++--
.../metadata/dom/XSLTransformationStage.java | 17 +++--
.../metadata/pipeline/AbstractStage.java | 6 +-
.../metadata/pipeline/SimplePipeline.java | 5 +-
.../metadata/util/ItemMetadataSupport.java | 73 ----------------------
.../java/net/shibboleth/metadata/MockItem.java | 9 ++-
7 files changed, 31 insertions(+), 107 deletions(-)
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMElementItem.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMElementItem.java
index c788814..cf61929 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMElementItem.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMElementItem.java
@@ -20,16 +20,15 @@ package net.shibboleth.metadata.dom;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
import net.shibboleth.metadata.AbstractItem;
import net.shibboleth.metadata.Item;
-import net.shibboleth.metadata.util.ItemMetadataSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
/**
* A {@link Item} whose data is a DOM, version 3, {@link Element}.
*
@@ -76,10 +75,10 @@ public class DOMElementItem extends AbstractItem<Element> {
setData(newDocumentRoot);
}
- /** {@inheritDoc} */
- @Override public Item<Element> copy() {
+ @Override
+ public Item<Element> copy() {
final DOMElementItem clone = new DOMElementItem(unwrap());
- ItemMetadataSupport.addAll(clone, getItemMetadata().values());
+ clone.getItemMetadata().putAll(getItemMetadata());
return clone;
}
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/MultiOutputXSLTransformationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/MultiOutputXSLTransformationStage.java
index 0ec0634..56afd80 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/MultiOutputXSLTransformationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/MultiOutputXSLTransformationStage.java
@@ -29,14 +29,13 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
+import org.w3c.dom.Element;
+
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.StageProcessingException;
-import net.shibboleth.metadata.util.ItemMetadataSupport;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
-import org.w3c.dom.Element;
-
/**
* A pipeline stage which transforms each item in the {@link DOMElementItem} collection via an XSL transform. Each of
* the input items may result in zero, one or more XML elements, each of which results in a {@link DOMElementItem} in
@@ -47,8 +46,8 @@ import org.w3c.dom.Element;
@ThreadSafe
public class MultiOutputXSLTransformationStage extends AbstractXSLProcessingStage {
- /** {@inheritDoc} */
- @Override protected void executeTransformer(@Nonnull final Transformer transformer,
+ @Override
+ protected void executeTransformer(@Nonnull final Transformer transformer,
@Nonnull @NonnullElements final Collection<Item<Element>> itemCollection) throws StageProcessingException,
TransformerConfigurationException {
@@ -68,7 +67,7 @@ public class MultiOutputXSLTransformationStage extends AbstractXSLProcessingStag
final List<Element> transformedElements = ElementSupport.getChildElements(result.getNode());
for (final Element transformedElement : transformedElements) {
final DOMElementItem newItem = new DOMElementItem(transformedElement);
- ItemMetadataSupport.addAll(newItem, domItem.getItemMetadata().values());
+ newItem.getItemMetadata().putAll(domItem.getItemMetadata());
newItems.add(newItem);
}
}
@@ -78,4 +77,4 @@ public class MultiOutputXSLTransformationStage extends AbstractXSLProcessingStag
throw new StageProcessingException("Unable to transform DOM Element", e);
}
}
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XSLTransformationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XSLTransformationStage.java
index 23dc1ce..20f6437 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XSLTransformationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XSLTransformationStage.java
@@ -28,15 +28,14 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
-import net.shibboleth.metadata.Item;
-import net.shibboleth.metadata.pipeline.StageProcessingException;
-import net.shibboleth.metadata.util.ItemMetadataSupport;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import net.shibboleth.metadata.Item;
+import net.shibboleth.metadata.pipeline.StageProcessingException;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+
/**
* A pipeline stage which transforms each item in the {@link DOMElementItem} collection via an XSL transform. Each item
* is replaced by an item constructed from the result of the transform. The result {@link DOMElementItem} receives
@@ -47,8 +46,8 @@ import org.w3c.dom.Element;
@ThreadSafe
public class XSLTransformationStage extends AbstractXSLProcessingStage {
- /** {@inheritDoc} */
- @Override protected void executeTransformer(@Nonnull final Transformer transformer,
+ @Override
+ protected void executeTransformer(@Nonnull final Transformer transformer,
@Nonnull @NonnullElements final Collection<Item<Element>> itemCollection) throws StageProcessingException,
TransformerConfigurationException {
@@ -67,7 +66,7 @@ public class XSLTransformationStage extends AbstractXSLProcessingStage {
// Create the result Item and copy across the input's ItemMetadata objects.
final Item<Element> newItem = new DOMElementItem(newDocument);
- ItemMetadataSupport.addAll(newItem, domItem.getItemMetadata().values());
+ newItem.getItemMetadata().putAll(domItem.getItemMetadata());
newItems.add(newItem);
}
itemCollection.clear();
@@ -76,4 +75,4 @@ public class XSLTransformationStage extends AbstractXSLProcessingStage {
throw new StageProcessingException("Unable to transform DOM Element", e);
}
}
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java
index 6461d18..bfffc89 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java
@@ -19,7 +19,6 @@ package net.shibboleth.metadata.pipeline;
import java.time.Instant;
import java.util.Collection;
-import java.util.Collections;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
@@ -27,7 +26,6 @@ import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.impl.BaseIdentifiableInitializableComponent;
-import net.shibboleth.metadata.util.ItemMetadataSupport;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -82,7 +80,9 @@ public abstract class AbstractStage<T> extends BaseIdentifiableInitializableComp
}
final var componentInfo = new ComponentInfo(getId(), getClass(), start, Instant.now());
- ItemMetadataSupport.addToAll(itemCollection, Collections.singleton(componentInfo));
+ for (final var item : itemCollection) {
+ item.getItemMetadata().put(componentInfo);
+ }
}
/**
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java
index cfa259b..2900633 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java
@@ -27,7 +27,6 @@ import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.impl.BaseIdentifiableInitializableComponent;
-import net.shibboleth.metadata.util.ItemMetadataSupport;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
@@ -73,7 +72,9 @@ public class SimplePipeline<T> extends BaseIdentifiableInitializableComponent
}
final var componentInfo = new ComponentInfo(getId(), getClass(), start, Instant.now());
- ItemMetadataSupport.addToAll(itemCollection, Collections.singleton(componentInfo));
+ for (final var item : itemCollection) {
+ item.getItemMetadata().put(componentInfo);
+ }
}
@Override
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/util/ItemMetadataSupport.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/util/ItemMetadataSupport.java
deleted file mode 100644
index 04ff00a..0000000
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/util/ItemMetadataSupport.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements. See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You under the Apache
- * License, Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.shibboleth.metadata.util;
-
-import java.util.Collection;
-
-import javax.annotation.Nullable;
-
-import net.shibboleth.metadata.Item;
-import net.shibboleth.metadata.ItemMetadata;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
-
-/** Helper class for dealing with {@link ItemMetadata} operations. */
-public final class ItemMetadataSupport {
-
- /** Constructor. */
- private ItemMetadataSupport() {
-
- }
-
- /**
- * Adds all the give {@link ItemMetadata} items to each {@link Item} element in the given collection.
- *
- * @param itemCollection collection of {@link Item} elements
- * @param metadatas collection of {@link ItemMetadata} items to be added to each {@link Item} element of the given
- * collection
- */
- public static void addToAll(@Nullable final Collection<? extends Item<?>> itemCollection,
- @Nullable @NullableElements final Iterable<? extends ItemMetadata> metadatas) {
- if (itemCollection == null || metadatas == null) {
- return;
- }
-
- for (final Item<?> item : itemCollection) {
- addAll(item, metadatas);
- }
- }
-
- /**
- * Adds all the given {@link ItemMetadata} items to the given {@link Item} element.
- *
- * @param item element to which {@link ItemMetadata} will be added
- * @param metadatas {@link ItemMetadata} to be added to the metadata element
- */
- public static void addAll(@Nullable final Item<?> item,
- @Nullable @NullableElements final Iterable<? extends ItemMetadata> metadatas) {
- if (item == null || metadatas == null) {
- return;
- }
-
- for (final ItemMetadata metadata : metadatas) {
- if (metadata != null) {
- item.getItemMetadata().put(metadata);
- }
- }
- }
-
-}
diff --git a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/MockItem.java b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/MockItem.java
index c0a6c3d..d18bfde 100644
--- a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/MockItem.java
+++ b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/MockItem.java
@@ -19,7 +19,6 @@ package net.shibboleth.metadata;
import java.util.Objects;
-import net.shibboleth.metadata.util.ItemMetadataSupport;
import net.shibboleth.utilities.java.support.collection.ClassToInstanceMultiMap;
/** A mock implementation of {@link Item}. */
@@ -49,10 +48,10 @@ public class MockItem extends AbstractItem<String> {
getItemMetadata().putAll(info);
}
- /** {@inheritDoc} */
- @Override public Item<String> copy() {
- MockItem clone = new MockItem(new String(unwrap()));
- ItemMetadataSupport.addAll(clone, getItemMetadata().values());
+ @Override
+ public Item<String> copy() {
+ final MockItem clone = new MockItem(new String(unwrap()));
+ clone.getItemMetadata().putAll(getItemMetadata());
return clone;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list