Skip to content

Commit

Permalink
make turtle the default RDF serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jul 22, 2013
1 parent 60f4f8d commit a6b8ff1
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 8 deletions.
Expand Up @@ -128,7 +128,7 @@ public Dataset searchSubmitHtml(@QueryParam("q")
*/
@GET
@Timed
@Produces({N3, N3_ALT1, N3_ALT2, TURTLE, RDF_XML, RDF_JSON, NTRIPLES})
@Produces({TURTLE, N3, N3_ALT1, N3_ALT2, RDF_XML, RDF_JSON, NTRIPLES})
public Dataset searchSubmitRdf(@QueryParam("q")
final String terms,
@QueryParam("offset")
Expand Down
Expand Up @@ -75,7 +75,7 @@ public class FedoraFixity extends AbstractResource {
*/
@GET
@Timed
@Produces({N3, N3_ALT1, N3_ALT2, TURTLE, RDF_XML, RDF_JSON, NTRIPLES,
@Produces({TURTLE, N3, N3_ALT1, N3_ALT2, RDF_XML, RDF_JSON, NTRIPLES,
TEXT_HTML})
public Dataset getDatastreamFixity(@PathParam("path")
final List<PathSegment> pathList,
Expand Down
Expand Up @@ -83,7 +83,7 @@ public class FedoraIdentifiers extends AbstractResource {
*/
@POST
@Timed
@Produces({N3, N3_ALT1, N3_ALT2, TURTLE, RDF_XML, RDF_JSON, NTRIPLES,
@Produces({TURTLE, N3, N3_ALT1, N3_ALT2, RDF_XML, RDF_JSON, NTRIPLES,
TEXT_HTML})
public Dataset getNextPid(@PathParam("path")
final List<PathSegment> pathList,
Expand Down
Expand Up @@ -108,7 +108,7 @@ public class FedoraNodes extends AbstractResource {
* @throws IOException
*/
@GET
@Produces({N3, N3_ALT1, N3_ALT2, TURTLE, RDF_XML, RDF_JSON, NTRIPLES,
@Produces({TURTLE, N3, N3_ALT1, N3_ALT2, RDF_XML, RDF_JSON, NTRIPLES,
TEXT_HTML})
public Dataset describe(@PathParam("path")
final List<PathSegment> pathList,
Expand Down
Expand Up @@ -82,7 +82,7 @@ public class FedoraVersions extends AbstractResource {
* @throws RepositoryException
*/
@GET
@Produces({N3, N3_ALT1, N3_ALT2, TURTLE, RDF_XML, RDF_JSON, NTRIPLES})
@Produces({TURTLE, N3, N3_ALT1, N3_ALT2, RDF_XML, RDF_JSON, NTRIPLES})
public Response getVersionList(@PathParam("path")
final List<PathSegment> pathList,
@Context
Expand Down Expand Up @@ -150,7 +150,7 @@ public Response addVersionLabel(@PathParam("path")
*/
@Path("/{versionLabel}")
@GET
@Produces({N3, N3_ALT1, N3_ALT2, TURTLE, RDF_XML, RDF_JSON, NTRIPLES})
@Produces({TURTLE, N3, N3_ALT1, N3_ALT2, RDF_XML, RDF_JSON, NTRIPLES})
public Dataset getVersion(@PathParam("path")
final List<PathSegment> pathList,
@PathParam("versionLabel")
Expand Down
Expand Up @@ -98,7 +98,7 @@ public Response updateNamespaces(final InputStream requestBodyStream)
*/
@GET
@Timed
@Produces({N3, N3_ALT1, N3_ALT2, TURTLE, RDF_XML, RDF_JSON, NTRIPLES,
@Produces({TURTLE, N3, N3_ALT1, N3_ALT2, RDF_XML, RDF_JSON, NTRIPLES,
TEXT_HTML})
@HtmlTemplate("jcr:namespaces")
public Dataset getNamespaces() throws RepositoryException, IOException {
Expand Down
Expand Up @@ -43,6 +43,7 @@ public void testCheckDatastreamFixity() throws Exception {
final HttpGet method2 =
new HttpGet(serverAddress +
"objects/FedoraDatastreamsTest11/zxc/fcr:fixity");
method2.setHeader("Accept", "application/n3");
final HttpResponse response = execute(method2);
assertEquals(200, response.getStatusLine().getStatusCode());
final HttpEntity entity = response.getEntity();
Expand Down
Expand Up @@ -46,6 +46,7 @@ public void testGetNextPidResponds() throws Exception {
@Test
public void testGetNextHasAPid() throws IOException {
final HttpPost method = new HttpPost(serverAddress + "fcr:pid");
method.setHeader("Accept", "application/n3");
final HttpResponse response = client.execute(method);
logger.debug("Executed testGetNextHasAPid()");
final GraphStore graphStore =
Expand All @@ -61,6 +62,7 @@ public void testGetNextHasAPid() throws IOException {
public void testGetNextHasTwoPids() throws IOException {
final HttpPost method =
new HttpPost(serverAddress + "fcr:pid?numPids=2");
method.setHeader("Accept", "application/n3");
final HttpResponse response = client.execute(method);
logger.debug("Executed testGetNextHasTwoPids()");
final GraphStore graphStore =
Expand All @@ -82,6 +84,7 @@ public void testGetNextPidRespondsWithPath() throws Exception {
@Test
public void testGetNextHasAPidWithPath() throws IOException {
final HttpPost method = new HttpPost(serverAddress + "objects/fcr:pid");
method.setHeader("Accept", "application/n3");
final HttpResponse response = client.execute(method);
logger.debug("Executed testGetNextHasAPidWithPath()");
final GraphStore graphStore =
Expand All @@ -97,6 +100,7 @@ public void testGetNextHasAPidWithPath() throws IOException {
public void testGetNextHasTwoPidsWithPath() throws IOException {
final HttpPost method =
new HttpPost(serverAddress + "objects/fcr:pid?numPids=2");
method.setHeader("Accept", "application/n3");
final HttpResponse response = client.execute(method);
logger.debug("Executed testGetNextHasTwoPidsWithPath()");
final GraphStore graphStore =
Expand Down
Expand Up @@ -30,6 +30,7 @@
import static org.fcrepo.RdfLexicon.HAS_OBJECT_SIZE;
import static org.fcrepo.RdfLexicon.HAS_PRIMARY_IDENTIFIER;
import static org.fcrepo.RdfLexicon.HAS_PRIMARY_TYPE;
import static org.fcrepo.http.RDFMediaType.TURTLE;
import static org.fcrepo.test.util.TestHelpers.parseTriples;
import static org.fcrepo.utils.FedoraJcrTypes.ROOT;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -124,6 +125,7 @@ public void testGetDatastream() throws Exception {
"objects/FedoraDatastreamsTest4/ds1"));
assertEquals(EntityUtils.toString(response.getEntity()), 200, response
.getStatusLine().getStatusCode());
assertEquals(TURTLE, response.getFirstHeader("Content-Type").getValue() );
}

@Test
Expand Down
Expand Up @@ -119,6 +119,7 @@ public void testCreateDoStuffAndRollbackTransaction() throws Exception {
/* fetch the created tx from the endpoint */
final HttpGet getTx =
new HttpGet(txLocation + "/object-in-tx-rollback");
getTx.setHeader("Accept", "application/n3");
resp = execute(getTx);
assertEquals(
"Expected to find our object within the scope of the transaction",
Expand Down Expand Up @@ -168,6 +169,7 @@ public void testCreateDoStuffAndCommitTransaction() throws Exception {

/* fetch the created tx from the endpoint */
final HttpGet getTx = new HttpGet(txLocation + "/object-in-tx-commit");
getTx.setHeader("Accept", "application/n3");
resp = execute(getTx);
assertEquals(
"Expected to find our object within the scope of the transaction",
Expand Down
Expand Up @@ -51,6 +51,7 @@ public void shouldDemonstratePathsAndWorkspaces() throws IOException,
final HttpGet httpGet =
new HttpGet(serverAddress +
"workspace:some-workspace/FedoraWorkspacesTest");
httpGet.setHeader("Accept", "application/n3");
final HttpResponse profileResponse = execute(httpGet);
assertEquals(200, profileResponse.getStatusLine().getStatusCode());
final GraphStore graphStore =
Expand Down
Expand Up @@ -233,9 +233,14 @@ public static Datastream mockDatastream(final String pid,
}

public static GraphStore parseTriples(final InputStream content) {
return parseTriples(content, "N3");
}

public static GraphStore parseTriples(final InputStream content,
final String contentType) {
final Model model = ModelFactory.createDefaultModel();

model.read(content, "", "N3");
model.read(content, "", contentType);

return GraphStoreFactory.create(model);

Expand Down

0 comments on commit a6b8ff1

Please sign in to comment.