Skip to content

Commit

Permalink
Use constant for fcr:metadata suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Oct 4, 2014
1 parent ea410c1 commit 1cd509c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 20 deletions.
Expand Up @@ -77,6 +77,7 @@
import static javax.ws.rs.core.Response.ok;
import static javax.ws.rs.core.Response.status;
import static org.apache.jena.riot.RDFLanguages.contentTypeToLang;
import static org.fcrepo.jcr.FedoraJcrTypes.FCR_METADATA;
import static org.slf4j.LoggerFactory.getLogger;

/**
Expand Down Expand Up @@ -316,7 +317,7 @@ protected URI getUri(final FedoraResource resource) {
final String uri = translator().getSubject(resource.getPath()).getURI();

if (resource instanceof Datastream) {
return new URI(uri + "/fcr:metadata");
return new URI(uri + "/" + FCR_METADATA);
} else {
return new URI(uri);
}
Expand All @@ -340,7 +341,7 @@ protected FedoraResource getResourceFromPath() {
final FedoraResource resource;
try {
final boolean metadata = pathList() != null
&& pathList().get(pathList().size() - 1).getPath().equals("fcr:metadata");
&& pathList().get(pathList().size() - 1).getPath().equals(FCR_METADATA);

final Node node = session().getNode(path());

Expand Down
Expand Up @@ -70,6 +70,7 @@
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_XML;
import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE;
import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE_X;
import static org.fcrepo.jcr.FedoraJcrTypes.FCR_METADATA;
import static org.slf4j.LoggerFactory.getLogger;

/**
Expand Down Expand Up @@ -229,7 +230,7 @@ protected FedoraResource unversionedResource() {
final FedoraResource resource;

try {
final boolean metadata = pathList.get(pathList.size() - 1).getPath().equals("fcr:metadata");
final boolean metadata = pathList.get(pathList.size() - 1).getPath().equals(FCR_METADATA);

final Node node = session.getNode(path);

Expand Down
Expand Up @@ -62,6 +62,7 @@
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_XML;
import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE;
import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE_X;
import static org.fcrepo.jcr.FedoraJcrTypes.FCR_METADATA;
import static org.slf4j.LoggerFactory.getLogger;

/**
Expand Down Expand Up @@ -222,7 +223,7 @@ protected FedoraResource resource() {
}

final boolean metadata = pathListIntoVersion != null &&
pathListIntoVersion.get(pathListIntoVersion.size() - 1).getPath().equals("fcr:metadata");
pathListIntoVersion.get(pathListIntoVersion.size() - 1).getPath().equals(FCR_METADATA);

if (DatastreamImpl.hasMixin(node)) {
final DatastreamImpl datastream = new DatastreamImpl(node);
Expand Down
Expand Up @@ -59,6 +59,7 @@
import static org.apache.jena.riot.WebContent.contentTypeRDFXML;
import static org.apache.jena.riot.WebContent.contentTypeSPARQLUpdate;
import static org.apache.jena.riot.WebContent.contentTypeTurtle;
import static org.fcrepo.jcr.FedoraJcrTypes.FCR_METADATA;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -283,7 +284,7 @@ public void testGetNonRDFSourceDescription() throws Exception {

createDatastream(pid, "x", "some content");

final HttpGet httpGet = new HttpGet(serverAddress + pid + "/x/fcr:metadata");
final HttpGet httpGet = new HttpGet(serverAddress + pid + "/x/" + FCR_METADATA);
final HttpResponse response = execute(httpGet);

final HttpEntity entity = response.getEntity();
Expand Down
Expand Up @@ -45,6 +45,7 @@
import static org.apache.jena.riot.WebContent.contentTypeRDFXML;
import static org.apache.jena.riot.WebContent.contentTypeSPARQLUpdate;
import static org.apache.jena.riot.WebContent.contentTypeTurtle;
import static org.fcrepo.jcr.FedoraJcrTypes.FCR_METADATA;
import static org.fcrepo.jcr.FedoraJcrTypes.ROOT;
import static org.fcrepo.kernel.RdfLexicon.CONTAINS;
import static org.fcrepo.kernel.RdfLexicon.DC_NAMESPACE;
Expand Down Expand Up @@ -335,7 +336,7 @@ public String apply(final Header h) {
}
});
assertTrue("Didn't find 'describedby' link header!",
links.contains("<" + serverAddress + pid + "/ds1/fcr:metadata>;rel=\"describedby\""));
links.contains("<" + serverAddress + pid + "/ds1/" + FCR_METADATA + ">;rel=\"describedby\""));

}

Expand Down Expand Up @@ -544,7 +545,7 @@ public String apply(final Header h) {
assertTrue("Didn't find LDP resource link header!",
links.contains("<" + LDP_NAMESPACE + "Resource>;rel=\"type\""));
assertTrue("Didn't find LDP container link header!",
links.contains("<" + LDP_NAMESPACE + "DirectContainer>;rel=\"type\""));
links.contains("<" + LDP_NAMESPACE + "DirectContainer>;rel=\"type\""));
}

@Test
Expand Down Expand Up @@ -653,12 +654,12 @@ public void testGetObjectReferences() throws Exception {

final BasicHttpEntity e = new BasicHttpEntity();
e.setContent(
new ByteArrayInputStream(
("INSERT { " +
"<" + serverAddress + pid + "/a" + "> <http://fedora.info/definitions/v4/rels-ext#isPartOf> <"
+ serverAddress + pid + "/b" + "> . \n" +
"<" + serverAddress + pid + "/a" + "> <info:xyz#some-other-property> <" + serverAddress + pid + "/b"
+ "> " + "} WHERE {}").getBytes()));
new ByteArrayInputStream(
("INSERT { " +
"<" + serverAddress + pid + "/a" + "> <http://fedora.info/definitions/v4/rels-ext#isPartOf> <"
+ serverAddress + pid + "/b" + "> . \n" +
"<" + serverAddress + pid + "/a" + "> <info:xyz#some-other-property> <" + serverAddress + pid + "/b"
+ "> " + "} WHERE {}").getBytes()));

updateObjectGraphMethod.setEntity(e);
client.execute(updateObjectGraphMethod);
Expand Down Expand Up @@ -716,8 +717,8 @@ 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> " +
"<" + serverAddress + "non-existant> } WHERE {}").getBytes()));
("INSERT { <> <http://fedora.info/definitions/v4/rels-ext#isMemberOfCollection> " +
"<" + serverAddress + "non-existant> } WHERE {}").getBytes()));
patch.setEntity(e);
assertEquals(BAD_REQUEST.getStatusCode(), getStatus(patch));
}
Expand Down Expand Up @@ -945,7 +946,7 @@ public void testRoundTripReplaceGraphForDatastream() throws Exception {

createDatastream(pid, "ds1", "some-content");

final HttpGet getObjMethod = new HttpGet(subjectURI + "/fcr:metadata");
final HttpGet getObjMethod = new HttpGet(subjectURI + "/" + FCR_METADATA);
getObjMethod.addHeader("Accept", "text/turtle");
getObjMethod.addHeader("Prefer", "return=minimal");
final HttpResponse getResponse = client.execute(getObjMethod);
Expand All @@ -962,7 +963,7 @@ public void testRoundTripReplaceGraphForDatastream() throws Exception {
w);
}

final HttpPut replaceMethod = new HttpPut(subjectURI + "/fcr:metadata");
final HttpPut replaceMethod = new HttpPut(subjectURI + "/" + FCR_METADATA);
replaceMethod.addHeader("Content-Type", "text/turtle");

replaceMethod.setEntity(e);
Expand Down Expand Up @@ -1112,7 +1113,7 @@ public void testValidHTMLForObject() throws Exception {
public void testValidHTMLForDS() throws Exception {
final String pid = getRandomUniquePid();
createDatastream(pid, "ds", "content");
validateHTML(pid + "/ds/fcr:metadata");
validateHTML(pid + "/ds/" + FCR_METADATA);
}

@Test
Expand Down
Expand Up @@ -24,6 +24,7 @@
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static javax.ws.rs.core.Response.Status.NO_CONTENT;
import static javax.ws.rs.core.Response.Status.OK;
import static org.fcrepo.jcr.FedoraJcrTypes.FCR_METADATA;
import static org.fcrepo.kernel.RdfLexicon.DC_TITLE;
import static org.fcrepo.kernel.RdfLexicon.EMBED_CONTAINS;
import static org.fcrepo.kernel.RdfLexicon.HAS_PRIMARY_TYPE;
Expand Down Expand Up @@ -261,7 +262,7 @@ public void isAutoVersionedContentStillAccessible() throws Exception {
createObject(objName);
createDatastream(objName, dsName, firstVersionText);
enableVersioning(objName + "/" + dsName);
setAutoVersioning(serverAddress + objName + "/" + dsName + "/fcr:metadata");
setAutoVersioning(serverAddress + objName + "/" + dsName + "/" + FCR_METADATA);
mutateDatastream(objName, dsName, secondVersionText);

final HttpGet retrieveMutatedDataStreamMethod =
Expand Down
Expand Up @@ -19,6 +19,7 @@
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource;
import static java.util.Collections.singletonList;
import static java.util.UUID.randomUUID;
import static org.fcrepo.jcr.FedoraJcrTypes.FCR_METADATA;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
Expand Down Expand Up @@ -126,7 +127,7 @@ public void testGetNodeFromGraphSubject() throws PathNotFoundException,
when(mockSubject.getURI())
.thenReturn(
"http://localhost:8080/fcrepo/rest" + testPath + "/ds"
+ "/fcr:metadata");
+ "/" + FCR_METADATA);
actual = mockSession.getNode(testObj.getPathFromSubject(mockSubject));
verify(mockSession).getNode(testPath + "/ds");
}
Expand Down

0 comments on commit 1cd509c

Please sign in to comment.