Skip to content

Commit

Permalink
Eliminate duplicate namespace prefixes: fedora and fcrepo
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Woods committed Nov 25, 2014
1 parent c9bf0a8 commit e33f20c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Expand Up @@ -69,11 +69,8 @@ public NamespaceRdfContext(final Session session) throws RepositoryException {
final ImmutableCollection.Builder<Triple> nsTriples =
ImmutableSet.builder();
for (String prefix : namespaceRegistry.getPrefixes()) {
if (!prefix.isEmpty()) {
if (!prefix.isEmpty() && !prefix.equals("jcr")) {
final String nsURI = namespaceRegistry.getURI(prefix);
if (prefix.equals("jcr")) {
prefix = "fcrepo";
}
LOGGER.trace(
"Discovered namespace prefix \"{}\" with URI \"{}\"",
prefix, nsURI);
Expand Down
Expand Up @@ -71,8 +71,10 @@ public void testConstructor() throws RepositoryException {
public void testJcrUris() throws RepositoryException {
when(mockNamespaceRegistry.getPrefixes()).thenReturn(new String[] {"jcr"});
when(mockNamespaceRegistry.getURI("jcr")).thenReturn("http://www.jcp.org/jcr/1.0");
assertTrue(new NamespaceRdfContext(mockSession).asModel().contains(
assertTrue(!new NamespaceRdfContext(mockSession).asModel().contains(
createResource(REPOSITORY_NAMESPACE), HAS_NAMESPACE_URI, REPOSITORY_NAMESPACE));
assertTrue(!new NamespaceRdfContext(mockSession).asModel().contains(
createResource("jcr"), HAS_NAMESPACE_URI, "http://www.jcp.org/jcr/1.0"));
}

@Test
Expand All @@ -94,9 +96,12 @@ public final void testGetJcrNamespaceModel() throws Exception {
new String[] {"jcr", "some-prefix"});

final Model jcrNamespaceModel = new NamespaceRdfContext(mockSession).asModel();
assertTrue(jcrNamespaceModel.contains(
assertTrue(!jcrNamespaceModel.contains(
createResource(REPOSITORY_NAMESPACE), HAS_NAMESPACE_PREFIX,
"fcrepo"));
"fedora"));
assertTrue(!jcrNamespaceModel.contains(
createResource("http://www.jcp.org/jcr/1.0"), HAS_NAMESPACE_PREFIX,
"jcr"));

final Resource nsSubject = createResource(mockUri);
assertTrue(jcrNamespaceModel.contains(nsSubject, RDF.type,
Expand Down Expand Up @@ -128,7 +133,7 @@ public void setUp() throws RepositoryException {

private final static String testUri = "http://example.com";

private final static String prefix = "jcr";
private final static String prefix = "testprefix";

private static Predicate<Triple> hasTestUriAsObject =
new Predicate<Triple>() {
Expand Down
@@ -1,4 +1,4 @@
@prefix fcrepo : <http://fedora.info/definitions/v4/repository#>
@prefix fedora : <http://fedora.info/definitions/v4/repository#>
id = . :: xsd:string ;
title = dc:title :: xsd:string;
uuid = fcrepo:uuid :: xsd:string ;
uuid = fedora:uuid :: xsd:string ;

0 comments on commit e33f20c

Please sign in to comment.