Skip to content

Commit

Permalink
Collapse #rest-api namespace into #repository
Browse files Browse the repository at this point in the history
- Remove #rels-ext namespace

Partial resolution of: https://www.pivotaltracker.com/story/show/82075356
  • Loading branch information
Andrew Woods committed Nov 8, 2014
1 parent e60cb84 commit 27f9f01
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 79 deletions.
Expand Up @@ -18,6 +18,7 @@
import static java.nio.file.Files.createTempDirectory;
import static java.nio.file.Files.createTempFile;
import static org.fcrepo.jcr.FedoraJcrTypes.CONTENT_DIGEST;
import static org.fcrepo.kernel.RdfLexicon.REPOSITORY_NAMESPACE;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -155,7 +156,7 @@ public void setUp() throws Exception {
setField(mockTranslator, "names", mockNameFactory);
setField(connector, "readonly", true);
connector.initialize(mockRegistry, mockNodeTypeManager);
mockContext.getNamespaceRegistry().register("fedora", "http://fedora.info/definitions/v4/repository#");
mockContext.getNamespaceRegistry().register("fedora", REPOSITORY_NAMESPACE);
mockContext.getNamespaceRegistry().register("premis", "http://www.loc.gov/premis/rdf/v1#");
}

Expand Down
Expand Up @@ -26,6 +26,7 @@
import javax.jcr.RepositoryException;
import javax.jcr.Session;

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 @@ -62,7 +63,7 @@ public void testWriteProperty() throws RepositoryException {
final FedoraResource object = nodeService.find(session, testFilePath());
assertNotNull(object);

final String sparql = "PREFIX fedora: <http://fedora.info/definitions/v4/rest-api#> " +
final String sparql = "PREFIX fedora: <" + REPOSITORY_NAMESPACE + "> " +
"INSERT DATA { " +
"<info:fedora" + testFilePath() + "> " +
"fedora:name " +
Expand All @@ -88,7 +89,7 @@ public void testRemoveProperty() throws RepositoryException {
final FedoraResource object = nodeService.find(session, testFilePath());
assertNotNull(object);

final String sparql = "PREFIX fedora: <http://fedora.info/definitions/v4/rest-api#> " +
final String sparql = "PREFIX fedora: <" + REPOSITORY_NAMESPACE + "> " +
"INSERT DATA { " +
"<info:fedora" + testFilePath() + "> " +
"fedora:remove " +
Expand All @@ -103,7 +104,7 @@ public void testRemoveProperty() throws RepositoryException {
assertNotNull(property);
assertEquals("some-property-to-remove", property.getValues()[0].getString());

final String sparqlRemove = "PREFIX fedora: <http://fedora.info/definitions/v4/rest-api#> " +
final String sparqlRemove = "PREFIX fedora: <" + REPOSITORY_NAMESPACE + "> " +
"DELETE {" +
" <info:fedora" + testFilePath() + "> fedora:remove ?s " +
"} WHERE { " +
Expand Down
2 changes: 1 addition & 1 deletion fcrepo-http-api/src/main/resources/views/common.vsl
Expand Up @@ -31,7 +31,7 @@
#else
<span property="$triple.getPredicate().toString()">$esc.html($triple.getObject())</span>
#end
#if( $triple.getPredicate().toString().equals("http://fedora.info/definitions/v4/rest-api#digest") )
#if( $triple.getPredicate().toString().equals("http://fedora.info/definitions/v4/repository#digest") )
#set ($fixity_service = $helpers.getObjects($rdf, $triple.getSubject(), $rdfLexicon.HAS_FIXITY_SERVICE))

#if($fixity_service.hasNext())
Expand Down
Expand Up @@ -16,6 +16,7 @@
package org.fcrepo.integration.http.api;

import static org.apache.commons.lang.StringUtils.contains;
import static org.fcrepo.kernel.RdfLexicon.REPOSITORY_NAMESPACE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -69,7 +70,7 @@ public void testGetDatastreamNode() throws Exception {
public void testGetTemplate() throws Exception {
final String pid = getRandomUniquePid();
createObject(pid);
addMixin(pid, "http://fedora.info/definitions/v4/rest-api#resource");
addMixin(pid, REPOSITORY_NAMESPACE + "Resource");

final HttpGet method = new HttpGet(serverAddress + pid);
method.addHeader("Accept", "text/html");
Expand Down
Expand Up @@ -72,7 +72,6 @@
import static org.fcrepo.kernel.RdfLexicon.NEXT_PAGE;
import static org.fcrepo.kernel.RdfLexicon.RDF_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.REPOSITORY_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.RESTAPI_NAMESPACE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
Expand Down Expand Up @@ -1221,8 +1220,8 @@ public void verifyFullSetOfRdfTypes() throws Exception {
final Resource nodeUri = createResource(serverAddress + pid);
final Property rdfType = createProperty(RDF_NAMESPACE + "type");

verifyResource(model, nodeUri, rdfType, RESTAPI_NAMESPACE, "Container");
verifyResource(model, nodeUri, rdfType, RESTAPI_NAMESPACE, "Resource");
verifyResource(model, nodeUri, rdfType, REPOSITORY_NAMESPACE, "Container");
verifyResource(model, nodeUri, rdfType, REPOSITORY_NAMESPACE, "Resource");
verifyResource(model, nodeUri, rdfType, MIX_NAMESPACE, "created");
verifyResource(model, nodeUri, rdfType, MIX_NAMESPACE, "lastModified");
verifyResource(model, nodeUri, rdfType, MIX_NAMESPACE, "referenceable");
Expand Down Expand Up @@ -1403,7 +1402,7 @@ public void testGetObjectReferences() throws Exception {
new ByteArrayInputStream(
("INSERT { " +
"<" + serverAddress + pid + "/a"
+ "> <http://fedora.info/definitions/v4/rels-ext#isPartOf> <"
+ "> <http://purl.org/dc/terms/isPartOf> <"
+ serverAddress + pid + "/b" + "> . \n" +
"<" + serverAddress + pid + "/a" + "> <info:xyz#some-other-property> <"
+ serverAddress + pid + "/b"
Expand All @@ -1421,7 +1420,7 @@ public void testGetObjectReferences() throws Exception {

assertTrue(graphStore.contains(Node.ANY,
NodeFactory.createURI(serverAddress + pid + "/a"),
NodeFactory.createURI("http://fedora.info/definitions/v4/rels-ext#isPartOf"),
NodeFactory.createURI("http://purl.org/dc/terms/isPartOf"),
NodeFactory.createURI(serverAddress + pid + "/b")
));

Expand Down Expand Up @@ -1465,7 +1464,7 @@ public void testLinkToNonExistent() throws Exception {
patch.addHeader("Content-Type", "application/sparql-update");
final BasicHttpEntity e = new BasicHttpEntity();
e.setContent(new ByteArrayInputStream(
("INSERT { <> <http://fedora.info/definitions/v4/rels-ext#isMemberOfCollection> " +
("INSERT { <> <http://some-vocabulary#isMemberOfCollection> " +
"<" + serverAddress + "non-existant> } WHERE {}").getBytes()));
patch.setEntity(e);
assertEquals(CONFLICT.getStatusCode(), getStatus(patch));
Expand Down Expand Up @@ -1867,7 +1866,7 @@ public void testFederatedDatastream() throws IOException {
assertEquals(201, getStatus(put));

// link from the object to the content of the file on the federated filesystem
final String sparql = "insert data { <> <http://fedora.info/definitions/v4/rels-ext#hasExternalContent> "
final String sparql = "insert data { <> <http://some-vocabulary#hasExternalContent> "
+ "<" + federationAddress + "> . }";
final HttpPatch patch = new HttpPatch(serverAddress + repoObj);
patch.addHeader("Content-Type", "application/sparql-update");
Expand Down Expand Up @@ -1964,7 +1963,7 @@ public void testLinkedDeletion() throws Exception {
createObject(linkedTo);

final String sparql = "insert data { <" + serverAddress + linkedFrom + "> "
+ "<http://fedora.info/definitions/v4/rels-ext#isMemberOfCollection> "
+ "<http://some-vocabulary#isMemberOfCollection> "
+ "<" + serverAddress + linkedTo + "> . }";
final HttpPatch patch = new HttpPatch(serverAddress + linkedFrom);
patch.addHeader("Content-Type", "application/sparql-update");
Expand Down
Expand Up @@ -27,7 +27,7 @@
import static com.hp.hpl.jena.graph.NodeFactory.createURI;
import static com.hp.hpl.jena.vocabulary.RDF.type;
import static com.hp.hpl.jena.vocabulary.RDFS.Class;
import static org.fcrepo.kernel.RdfLexicon.RESTAPI_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.REPOSITORY_NAMESPACE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

Expand All @@ -45,11 +45,11 @@ public void itShouldContainFcrepoClasses() throws IOException {
httpGet.addHeader("Accept", "application/n-triples");
final GraphStore graphStore = getGraphStore(httpGet);

assertTrue(graphStore.contains(ANY, createURI(RESTAPI_NAMESPACE
assertTrue(graphStore.contains(ANY, createURI(REPOSITORY_NAMESPACE
+ "Resource"), type.asNode(), Class.asNode()));
assertTrue(graphStore.contains(ANY, createURI(RESTAPI_NAMESPACE
assertTrue(graphStore.contains(ANY, createURI(REPOSITORY_NAMESPACE
+ "Container"), type.asNode(), Class.asNode()));
assertTrue(graphStore.contains(ANY, createURI(RESTAPI_NAMESPACE
assertTrue(graphStore.contains(ANY, createURI(REPOSITORY_NAMESPACE
+ "NonRdfSourceDescription"), type.asNode(), Class.asNode()));
}

Expand Down
3 changes: 1 addition & 2 deletions fcrepo-kernel-impl/src/main/resources/fedora-node-types.cnd
Expand Up @@ -21,8 +21,7 @@
/*
* Generic Fedora namespace
*/
<fedora = 'http://fedora.info/definitions/v4/rest-api#'>
<fedorarelsext = 'http://fedora.info/definitions/v4/rels-ext#'>
<fedora = 'http://fedora.info/definitions/v4/repository#'>
<rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<rdfs = 'http://www.w3.org/2000/01/rdf-schema#'>
<premis = 'http://www.loc.gov/premis/rdf/v1#'>
Expand Down
Expand Up @@ -16,7 +16,6 @@
package org.fcrepo.integration.kernel.impl;

import static java.util.regex.Pattern.compile;
import static org.fcrepo.kernel.RdfLexicon.RELATIONS_NAMESPACE;
import static org.fcrepo.kernel.impl.utils.FedoraTypesUtils.getReferencePropertyName;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -123,12 +122,11 @@ public void testObjectGraph() throws Exception {

assertEquals("This is some example data", value.getString());

object.updateProperties(subjects, "PREFIX fedora-rels-ext: <"
+ RELATIONS_NAMESPACE + ">\n" +
"INSERT { <" + graphSubject + "> fedora-rels-ext:" +
object.updateProperties(subjects, "PREFIX dcterms: <http://purl.org/dc/terms/>\n" +
"INSERT { <" + graphSubject + "> dcterms:" +
"isPartOf <" + graphSubject + "> } WHERE {}", object.getTriples(subjects, PropertiesRdfContext.class));

final Value refValue = object.getNode().getProperty("fedorarelsext:isPartOf_ref").getValues()[0];
final Value refValue = object.getNode().getProperty("dcterms:isPartOf_ref").getValues()[0];
assertTrue(refValue.getString(), refValue.getString().equals(object.getNode().getIdentifier()));


Expand All @@ -139,13 +137,12 @@ public void testObjectGraph() throws Exception {
assertFalse("Found unexpected dc:title",
object.getNode().hasProperty("dc:title"));

object.updateProperties(subjects, "PREFIX fedora-rels-ext: <" +
RELATIONS_NAMESPACE + ">\n" +
object.updateProperties(subjects, "PREFIX dcterms: <http://purl.org/dc/terms/>\n" +
"DELETE { <" + graphSubject + "> " +
"fedora-rels-ext:isPartOf <" + graphSubject + "> " +
"dcterms:isPartOf <" + graphSubject + "> " +
"} WHERE {}", object.getTriples(subjects, PropertiesRdfContext.class));
assertFalse("found unexpected reference",
object.getNode().hasProperty("fedorarelsext:isPartOf"));
object.getNode().hasProperty("dcterms:isPartOf"));

session.save();

Expand Down
Expand Up @@ -28,7 +28,6 @@
import static org.fcrepo.jcr.FedoraJcrTypes.FEDORA_TOMBSTONE;
import static org.fcrepo.kernel.RdfLexicon.DC_TITLE;
import static org.fcrepo.kernel.RdfLexicon.RDF_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.RELATIONS_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.REPOSITORY_NAMESPACE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -299,7 +298,7 @@ public void testDatastreamGraph() throws RepositoryException, InvalidChecksumExc
final NonRdfSourceDescription object =
binaryService.findOrCreate(session, "/testDatastreamGraph").getDescription();

object.getNode().setProperty("fedorarelsext:isPartOf",
object.getNode().setProperty("fedora:isPartOf",
session.getNode("/testDatastreamGraphParent"));

final Graph graph = object.getTriples(subjects, PropertiesRdfContext.class).asModel().getGraph();
Expand Down Expand Up @@ -329,7 +328,7 @@ public void testDatastreamGraph() throws RepositoryException, InvalidChecksumExc

//assertTrue(datasetGraph.contains(ANY, s, p, o));
// relations
p = createURI(RELATIONS_NAMESPACE + "isPartOf");
p = createURI(REPOSITORY_NAMESPACE + "isPartOf");
o = createGraphSubjectNode(parentObject);
assertTrue(graph.contains(s, p, o));

Expand Down Expand Up @@ -433,8 +432,8 @@ public void testAddMissingReference() throws RepositoryException, MalformedRdfEx
subjects,
"PREFIX example: <http://example.org/>\n"
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n"
+ "PREFIX fedorarelsext: <http://fedora.info/definitions/v4/rels-ext#>\n"
+ "INSERT { <> fedorarelsext:isPartOf <" + subjects.toDomain("/some-path") + ">}"
+ "PREFIX fedora: <" + REPOSITORY_NAMESPACE + ">\n"
+ "INSERT { <> fedora:isPartOf <" + subjects.toDomain("/some-path") + ">}"
+ "WHERE { }", new RdfStream());
}

Expand Down Expand Up @@ -484,15 +483,15 @@ public void testGetReferences() throws RepositoryException {
final Container subject = containerService.findOrCreate(session, pid + "/a");
final Container object = containerService.findOrCreate(session, pid + "/b");
final Value value = session.getValueFactory().createValue(object.getNode());
subject.getNode().setProperty("fedorarelsext:isPartOf", new Value[] { value });
subject.getNode().setProperty("fedora:isPartOf", new Value[] { value });

session.save();

final Model model = object.getTriples(subjects, ReferencesRdfContext.class).asModel();

assertTrue(
model.contains(subjects.reverse().convert(subject),
ResourceFactory.createProperty("http://fedora.info/definitions/v4/rels-ext#isPartOf"),
ResourceFactory.createProperty(REPOSITORY_NAMESPACE + "isPartOf"),
subjects.reverse().convert(object))
);
}
Expand Down Expand Up @@ -562,7 +561,7 @@ public void testDeleteObjectWithInboundReferences() throws RepositoryException {
final FedoraResource resourceB = containerService.findOrCreate(session, "/" + pid + "/b");

final Value value = session.getValueFactory().createValue(resourceB.getNode());
resourceA.getNode().setProperty("fedorarelsext:hasMember", new Value[] { value });
resourceA.getNode().setProperty("fedora:hasMember", new Value[] { value });

session.save();
containerService.findOrCreate(session, "/" + pid + "/a").delete();
Expand Down
Expand Up @@ -18,7 +18,7 @@
import static com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel;
import static com.hp.hpl.jena.vocabulary.RDF.type;
import static javax.jcr.PropertyType.URI;
import static org.fcrepo.kernel.RdfLexicon.RESTAPI_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.REPOSITORY_NAMESPACE;
import static org.fcrepo.kernel.impl.utils.FedoraTypesUtils.getPropertyType;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
Expand Down Expand Up @@ -198,10 +198,10 @@ public void testAddRdfType() throws RepositoryException {
when(mockWorkspace.getNodeTypeManager()).thenReturn(mockNodeTypeManager);
when(mockNodeTypeManager.hasNodeType("fedora:object")).thenReturn(true);

when(mockSession.getNamespacePrefix(RESTAPI_NAMESPACE))
when(mockSession.getNamespacePrefix(REPOSITORY_NAMESPACE))
.thenReturn("fedora");
final Model model = ModelFactory.createDefaultModel();
final Resource type = model.createResource(RESTAPI_NAMESPACE
final Resource type = model.createResource(REPOSITORY_NAMESPACE
+ "object");
final Statement statement = model.createStatement(mockResource, RDF.type, type);
when(mockSubjectNode.canAddMixin("fedora:object")).thenReturn(true);
Expand All @@ -217,10 +217,10 @@ public void testRemoveRdfType() throws RepositoryException {
when(mockSession.getWorkspace()).thenReturn(mockWorkspace);
when(mockWorkspace.getNodeTypeManager()).thenReturn(mockNodeTypeManager);
when(mockNodeTypeManager.hasNodeType("fedora:object")).thenReturn(true);
when(mockSession.getNamespacePrefix(RESTAPI_NAMESPACE)).thenReturn(
when(mockSession.getNamespacePrefix(REPOSITORY_NAMESPACE)).thenReturn(
"fedora");
final Model model = createDefaultModel();
final Resource type = model.createResource(RESTAPI_NAMESPACE + "object");
final Resource type = model.createResource(REPOSITORY_NAMESPACE + "Container");
model.add(mockResource, RDF.type, type);
testObj.removedStatements(model);
verify(mockJcrRdfTools).removeMixin(resource, type, mockNsMapping);
Expand All @@ -237,12 +237,12 @@ public void testAddRdfTypeForNonMixin() throws RepositoryException {

when(getPropertyType(mockSubjectNode, "rdf:type")).thenReturn(URI);

when(mockSession.getNamespacePrefix(RESTAPI_NAMESPACE))
when(mockSession.getNamespacePrefix(REPOSITORY_NAMESPACE))
.thenReturn("fedora");
final Model model = createDefaultModel();
final Statement statement = model.createStatement(mockResource,
type,
model.createResource(RESTAPI_NAMESPACE + "object"));
model.createResource(REPOSITORY_NAMESPACE + "Container"));
when(mockSubjectNode.canAddMixin("fedora:object")).thenReturn(true);
when(mockJcrRdfTools.skolemize(idTranslator, statement)).thenReturn(statement);
testObj.addedStatement(statement);
Expand All @@ -256,10 +256,10 @@ public void testRemoveRdfTypeForNonMixin() throws RepositoryException {
when(mockSession.getWorkspace()).thenReturn(mockWorkspace);
when(mockWorkspace.getNodeTypeManager()).thenReturn(mockNodeTypeManager);
when(mockNodeTypeManager.hasNodeType("fedora:object")).thenReturn(false);
when(mockSession.getNamespacePrefix(RESTAPI_NAMESPACE)).thenReturn("fedora");
when(mockSession.getNamespacePrefix(REPOSITORY_NAMESPACE)).thenReturn("fedora");
final Model model = createDefaultModel();
model.add(mockResource, type, model.createResource(RESTAPI_NAMESPACE + "object"));
model.add(mockResource, type, model.createResource(REPOSITORY_NAMESPACE + "Container"));
testObj.removedStatements(model);
verify(mockSubjectNode, never()).removeMixin("fedora:object");
verify(mockSubjectNode, never()).removeMixin("fedora:Container");
}
}

0 comments on commit 27f9f01

Please sign in to comment.