Skip to content

Commit

Permalink
Aliasing any jcr-namespaced properties to fedora...
Browse files Browse the repository at this point in the history
- before sending along to the jms producer

Resolves: https://jira.duraspace.org/browse/FCREPO-1405
  • Loading branch information
acoburn authored and Andrew Woods committed Mar 20, 2015
1 parent fb45d63 commit be0e046
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Expand Up @@ -23,6 +23,9 @@
import javax.jcr.RepositoryException;
import javax.jcr.Session;

import static com.hp.hpl.jena.rdf.model.ResourceFactory.createProperty;
import static org.fcrepo.kernel.RdfLexicon.jcrProperties;
import static org.fcrepo.kernel.RdfLexicon.REPOSITORY_NAMESPACE;
import static org.fcrepo.kernel.utils.NamespaceTools.getNamespaceRegistry;
import static org.slf4j.LoggerFactory.getLogger;

Expand Down Expand Up @@ -54,11 +57,19 @@ public FedoraEvent apply(final FedoraEvent evt) {
final String[] parts = property.split(":", 2);
if (parts.length == 2) {
final String prefix = parts[0];
try {
event.addProperty(namespaceRegistry.getURI(prefix) + parts[1]);
} catch (RepositoryException ex) {
LOGGER.trace("Prefix could not be dereferenced using the namespace registry: {}", property);
event.addProperty(property);
if ("jcr".equals(prefix)) {
if (jcrProperties.contains(createProperty(REPOSITORY_NAMESPACE + parts[1]))) {
event.addProperty(REPOSITORY_NAMESPACE + parts[1]);
} else {
LOGGER.debug("Swallowing jcr property: {}", property);
}
} else {
try {
event.addProperty(namespaceRegistry.getURI(prefix) + parts[1]);
} catch (RepositoryException ex) {
LOGGER.debug("Prefix could not be dereferenced using the namespace registry: {}", property);
event.addProperty(property);
}
}
} else {
event.addProperty(property);
Expand Down
Expand Up @@ -16,7 +16,7 @@
package org.fcrepo.integration.kernel.impl.observer;

import static org.fcrepo.kernel.FedoraJcrTypes.FEDORA_CONTAINER;
import static org.fcrepo.kernel.RdfLexicon.JCR_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.REPOSITORY_NAMESPACE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -84,7 +84,7 @@ public void countMessages(final FedoraEvent e) {
final Set<String> properties = e.getProperties();
assertNotNull(properties);

final String expected = JCR_NAMESPACE + "mixinTypes";
final String expected = REPOSITORY_NAMESPACE + "mixinTypes";
assertTrue("Should contain: " + expected + properties, properties.contains(expected));
}

Expand Down
Expand Up @@ -111,7 +111,7 @@ public void testApply() {
final String expected1 = FEDORA_CONTAINER.replace("fedora:", REPOSITORY_NAMESPACE);
final String expected2 = FEDORA_TOMBSTONE.replace("fedora:", REPOSITORY_NAMESPACE);
final String expected3 = LDP_BASIC_CONTAINER.replace("ldp:", LDP_NAMESPACE);
final String expected4 = JCR_MIXIN_TYPES.replace("jcr:", JCR_NAMESPACE);
final String expected4 = JCR_MIXIN_TYPES.replace("jcr:", REPOSITORY_NAMESPACE);

assertTrue("Should contain: " + expected1 + ", " + properties, properties.contains(expected1));
assertTrue("Should contain: " + expected2 + ", " + properties, properties.contains(expected2));
Expand Down

0 comments on commit be0e046

Please sign in to comment.