From f573139229c5c584934106e1c221be916d40b375 Mon Sep 17 00:00:00 2001 From: Benjamin Armintor Date: Thu, 30 Oct 2014 14:11:05 -0400 Subject: [PATCH 1/5] remove duplicate jcrRdfTools and unused session accessor in RDF iterators --- .../utils/iterators/PersistingRdfStreamConsumer.java | 11 ----------- .../fcrepo/kernel/impl/utils/iterators/RdfAdder.java | 8 ++------ 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/utils/iterators/PersistingRdfStreamConsumer.java b/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/utils/iterators/PersistingRdfStreamConsumer.java index b1a3cd71c9..53b78338c9 100644 --- a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/utils/iterators/PersistingRdfStreamConsumer.java +++ b/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/utils/iterators/PersistingRdfStreamConsumer.java @@ -55,8 +55,6 @@ public abstract class PersistingRdfStreamConsumer implements RdfStreamConsumer { private final IdentifierConverter idTranslator; - private final Session session; - // if it's not about a Fedora resource, we don't care. protected final Predicate isFedoraSubjectTriple; @@ -100,7 +98,6 @@ public boolean apply(final Triple t) { // we knock out non-Fedora RDF this.stream = stream.withThisContext(stream.filter(isFedoraSubjectTriple)); - this.session = session; this.exceptions = new ArrayList<>(); } @@ -190,14 +187,6 @@ public IdentifierConverter translator() { } - /** - * @return the session - */ - public Session session() { - return session; - } - - /** * @return the jcrRdfTools */ diff --git a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/utils/iterators/RdfAdder.java b/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/utils/iterators/RdfAdder.java index 50d52661aa..d3f5f4a6c2 100644 --- a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/utils/iterators/RdfAdder.java +++ b/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/utils/iterators/RdfAdder.java @@ -22,7 +22,6 @@ import org.fcrepo.kernel.models.FedoraResource; import org.fcrepo.kernel.identifiers.IdentifierConverter; -import org.fcrepo.kernel.impl.rdf.JcrRdfTools; import org.fcrepo.kernel.utils.iterators.RdfStream; import org.slf4j.Logger; @@ -41,8 +40,6 @@ public class RdfAdder extends PersistingRdfStreamConsumer { private static final Logger LOGGER = getLogger(RdfAdder.class); - private final JcrRdfTools jcrRdfTools; - /** * Ordinary constructor. * @@ -53,13 +50,12 @@ public class RdfAdder extends PersistingRdfStreamConsumer { public RdfAdder(final IdentifierConverter idTranslator, final Session session, final RdfStream stream) { super(idTranslator, session, stream); - jcrRdfTools = new JcrRdfTools(idTranslator, session); } @Override protected void operateOnMixin(final Resource mixinResource, final FedoraResource resource) throws RepositoryException { - jcrRdfTools.addMixin(resource, mixinResource, stream().namespaces()); + jcrRdfTools().addMixin(resource, mixinResource, stream().namespaces()); } @@ -68,6 +64,6 @@ protected void operateOnProperty(final Statement t, final FedoraResource resourc LOGGER.debug("Adding property from triple: {} to resource: {}.", t, resource .getPath()); - jcrRdfTools.addProperty(resource, t.getPredicate(), t.getObject(), stream().namespaces()); + jcrRdfTools().addProperty(resource, t.getPredicate(), t.getObject(), stream().namespaces()); } } From 33315510609083c2ddc0ce96545d6a7fca6e00ce Mon Sep 17 00:00:00 2001 From: Benjamin Armintor Date: Thu, 30 Oct 2014 14:45:41 -0400 Subject: [PATCH 2/5] remove unused pid-function-factory method from minters --- .../impl/identifiers/BasePidMinter.java | 40 ------------------- .../impl/identifiers/HttpPidMinter.java | 6 ++- .../impl/identifiers/UUIDPathMinter.java | 4 +- .../fcrepo/kernel/identifiers/PidMinter.java | 7 ---- 4 files changed, 7 insertions(+), 50 deletions(-) delete mode 100644 fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/BasePidMinter.java diff --git a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/BasePidMinter.java b/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/BasePidMinter.java deleted file mode 100644 index b8b898305b..0000000000 --- a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/BasePidMinter.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright 2014 DuraSpace, Inc. - * - * Licensed 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 org.fcrepo.kernel.impl.identifiers; - -import com.google.common.base.Function; -import org.fcrepo.kernel.identifiers.PidMinter; - -/** - * Minting FedoraObject unique identifiers - * - * @author ajs6f - * @since Mar 25, 2013 - */ -public abstract class BasePidMinter implements PidMinter { - - @Override - public Function makePid() { - return new Function() { - - @Override - public String apply(final Object input) { - return mintPid(); - } - }; - } - -} diff --git a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/HttpPidMinter.java b/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/HttpPidMinter.java index 4b55094d68..a1cf403560 100644 --- a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/HttpPidMinter.java +++ b/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/HttpPidMinter.java @@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkArgument; import org.slf4j.Logger; + import com.codahale.metrics.annotation.Timed; import java.io.ByteArrayInputStream; @@ -27,6 +28,7 @@ import java.net.URI; import org.w3c.dom.Document; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.xpath.XPathException; @@ -42,11 +44,11 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.util.EntityUtils; - import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.impl.client.BasicCredentialsProvider; +import org.fcrepo.kernel.identifiers.PidMinter; /** @@ -55,7 +57,7 @@ * @author escowles * @since 04/28/2014 */ -public class HttpPidMinter extends BasePidMinter { +public class HttpPidMinter implements PidMinter { private static final Logger log = getLogger(HttpPidMinter.class); protected final String url; diff --git a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/UUIDPathMinter.java b/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/UUIDPathMinter.java index 0e168901a7..4796765391 100644 --- a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/UUIDPathMinter.java +++ b/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/UUIDPathMinter.java @@ -19,6 +19,8 @@ import static com.google.common.base.Joiner.on; import static com.google.common.base.Splitter.fixedLength; import static java.util.UUID.randomUUID; + +import org.fcrepo.kernel.identifiers.PidMinter; import org.fcrepo.metrics.RegistryService; import com.codahale.metrics.Timer; @@ -28,7 +30,7 @@ * * @author awoods */ -public class UUIDPathMinter extends BasePidMinter { +public class UUIDPathMinter implements PidMinter { static final Timer timer = RegistryService.getInstance().getMetrics().timer( name(UUIDPathMinter.class, "mint")); diff --git a/fcrepo-kernel/src/main/java/org/fcrepo/kernel/identifiers/PidMinter.java b/fcrepo-kernel/src/main/java/org/fcrepo/kernel/identifiers/PidMinter.java index abf34766ad..9840cbeb1c 100644 --- a/fcrepo-kernel/src/main/java/org/fcrepo/kernel/identifiers/PidMinter.java +++ b/fcrepo-kernel/src/main/java/org/fcrepo/kernel/identifiers/PidMinter.java @@ -15,8 +15,6 @@ */ package org.fcrepo.kernel.identifiers; -import com.google.common.base.Function; - /** * Defines the behavior of a component that can accept responsibility * for the creation of Fedora PIDs. Do not implement this interface directly. @@ -34,9 +32,4 @@ public interface PidMinter { */ String mintPid(); - /** - * Provide a helpful function to mint any number of PIDs - * @return a function for minting new identifiers - */ - Function makePid(); } From b1cf57a2d58e1adb3773e0f92d9f845b8f077619 Mon Sep 17 00:00:00 2001 From: Benjamin Armintor Date: Thu, 30 Oct 2014 14:49:23 -0400 Subject: [PATCH 3/5] remove unused function and input iterator-traversing ZippingIterator --- .../rdf/impl/mappings/ZippingIterator.java | 71 ----------------- .../impl/mappings/ZippingIteratorTest.java | 77 ------------------- 2 files changed, 148 deletions(-) delete mode 100644 fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/rdf/impl/mappings/ZippingIterator.java delete mode 100644 fcrepo-kernel-impl/src/test/java/org/fcrepo/kernel/impl/rdf/impl/mappings/ZippingIteratorTest.java diff --git a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/rdf/impl/mappings/ZippingIterator.java b/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/rdf/impl/mappings/ZippingIterator.java deleted file mode 100644 index 88f121943d..0000000000 --- a/fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/rdf/impl/mappings/ZippingIterator.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright 2014 DuraSpace, Inc. - * - * Licensed 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 org.fcrepo.kernel.impl.rdf.impl.mappings; - -import static org.slf4j.LoggerFactory.getLogger; - -import java.util.Iterator; - -import org.slf4j.Logger; -import com.google.common.collect.AbstractIterator; -import com.google.common.base.Function; - -/** - * An {@link Iterator} that zips an Iterator of functions with an iterator of - * values on which the functions must act. - * - * @author ajs6f - * @since Oct 10, 2013 - * @param - * @param - */ -public class ZippingIterator extends AbstractIterator { - - private Iterator from; - - private Iterator> through; - - private static final Logger LOGGER = getLogger(ZippingIterator.class); - - /** - * Default constructor. - * - * @param from - * @param through - */ - public ZippingIterator(final Iterator from, - final Iterator> through) { - super(); - this.from = from; - this.through = through; - } - - @Override - protected ToType computeNext() { - final boolean hasNext = (from.hasNext() && through.hasNext()); - if (hasNext) { - LOGGER.trace("Found next element."); - final FromType f = from.next(); - final Function t = through.next(); - LOGGER.trace("Supplying from next element {} through function {}", - f, t); - return t.apply(f); - } - return endOfData(); - - } - -} diff --git a/fcrepo-kernel-impl/src/test/java/org/fcrepo/kernel/impl/rdf/impl/mappings/ZippingIteratorTest.java b/fcrepo-kernel-impl/src/test/java/org/fcrepo/kernel/impl/rdf/impl/mappings/ZippingIteratorTest.java deleted file mode 100644 index f9f76323f8..0000000000 --- a/fcrepo-kernel-impl/src/test/java/org/fcrepo/kernel/impl/rdf/impl/mappings/ZippingIteratorTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright 2014 DuraSpace, Inc. - * - * Licensed 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 org.fcrepo.kernel.impl.rdf.impl.mappings; - -import static com.google.common.base.Functions.forMap; -import static com.google.common.collect.ImmutableMap.of; -import static com.google.common.collect.Iterators.forArray; -import static com.google.common.collect.Iterators.singletonIterator; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -import java.util.Iterator; -import org.junit.Test; - -import com.google.common.base.Function; - -/** - * @author ajs6f - * @since Oct 2013 - */ -public class ZippingIteratorTest { - - private ZippingIterator zip; - - /* - * We test to see that a ZippingIterator will return correct results until - * one or the other source iterator is exhausted. - */ - - @Test - public void testMoreValuesThanFunctions() { - values = forArray(from1, from2); - functions = singletonIterator(f); - zip = new ZippingIterator<>(values, functions); - assertEquals("Got wrong value!", to1, zip.next()); - assertFalse("Too many values!", zip.hasNext()); - } - - @Test - @SuppressWarnings("unchecked") - public void testMoreFunctionsThanValues() { - values = singletonIterator(from1); - functions = forArray(f, f); - zip = new ZippingIterator<>(values, functions); - assertEquals("Got wrong value!", to1, zip.next()); - assertFalse("Too many values!", zip.hasNext()); - } - - Iterator values; - - Iterator> functions; - - private static Object from1 = new Object(); - - private static Object from2 = new Object(); - - private static Object to1 = new Object(); - - private static Object to2 = new Object(); - - private static final Function f = forMap(of(from1, to1, - from2, to2)); - -} From 0b7a9ab1430eec50d25fd1a0b19b6d3b86aa1cc4 Mon Sep 17 00:00:00 2001 From: Benjamin Armintor Date: Thu, 30 Oct 2014 15:25:23 -0400 Subject: [PATCH 4/5] remove vestigal String constant from abandoned ATOM-JMS impl --- .../src/main/java/org/fcrepo/kernel/observer/FedoraEvent.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/fcrepo-kernel/src/main/java/org/fcrepo/kernel/observer/FedoraEvent.java b/fcrepo-kernel/src/main/java/org/fcrepo/kernel/observer/FedoraEvent.java index a908f00338..5c2d81f51e 100644 --- a/fcrepo-kernel/src/main/java/org/fcrepo/kernel/observer/FedoraEvent.java +++ b/fcrepo-kernel/src/main/java/org/fcrepo/kernel/observer/FedoraEvent.java @@ -47,8 +47,6 @@ */ public class FedoraEvent { - public static final String NODE_TYPE_KEY = "fedora:nodeTypeKey"; - private Event e; private Set eventTypes = new HashSet<>(); From ea63ee03b82c175ae8448e5d85bdbea752d2dcd3 Mon Sep 17 00:00:00 2001 From: Benjamin Armintor Date: Thu, 30 Oct 2014 16:58:46 -0400 Subject: [PATCH 5/5] document a temporarily unused constant in RdfLexicon --- fcrepo-kernel/src/main/java/org/fcrepo/kernel/RdfLexicon.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fcrepo-kernel/src/main/java/org/fcrepo/kernel/RdfLexicon.java b/fcrepo-kernel/src/main/java/org/fcrepo/kernel/RdfLexicon.java index 14a7a96c0a..2f8e0c1b91 100644 --- a/fcrepo-kernel/src/main/java/org/fcrepo/kernel/RdfLexicon.java +++ b/fcrepo-kernel/src/main/java/org/fcrepo/kernel/RdfLexicon.java @@ -67,7 +67,9 @@ public final class RdfLexicon { * Fedora configuration namespace "fedora-config", used for user-settable * configuration properties. **/ - public static final String FEDORA_CONFIG_NAMESPACE = + // TODO from UCDetector: Constant "RdfLexicon.FEDORA_CONFIG_NAMESPACE" has 0 references + // should be referenced again when versioning is back in REST api + public static final String FEDORA_CONFIG_NAMESPACE = // NO_UCD (unused code) "http://fedora.info/definitions/v4/config#"; /**