Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add RDF representation for explicit namespace -> prefix registration …
…and changes; remove old JAX-B version.
- Loading branch information
Showing
14 changed files
with
435 additions
and
474 deletions.
There are no files selected for viewing
150 changes: 0 additions & 150 deletions
150
fcrepo-http-api/src/main/java/org/fcrepo/api/FedoraNamespaces.java
This file was deleted.
Oops, something went wrong.
100 changes: 100 additions & 0 deletions
100
fcrepo-http-api/src/main/java/org/fcrepo/api/repository/FedoraRepositoryNamespaces.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
|
||
package org.fcrepo.api.repository; | ||
|
||
import static javax.ws.rs.core.MediaType.TEXT_HTML; | ||
import static org.apache.jena.riot.WebContent.contentTypeSPARQLUpdate; | ||
import static org.fcrepo.http.RDFMediaType.N3; | ||
import static org.fcrepo.http.RDFMediaType.N3_ALT1; | ||
import static org.fcrepo.http.RDFMediaType.N3_ALT2; | ||
import static org.fcrepo.http.RDFMediaType.NTRIPLES; | ||
import static org.fcrepo.http.RDFMediaType.RDF_JSON; | ||
import static org.fcrepo.http.RDFMediaType.RDF_XML; | ||
import static org.fcrepo.http.RDFMediaType.TURTLE; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import javax.jcr.RepositoryException; | ||
import javax.jcr.Session; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.Response; | ||
|
||
import com.hp.hpl.jena.query.Dataset; | ||
import com.hp.hpl.jena.update.GraphStore; | ||
import com.hp.hpl.jena.update.UpdateAction; | ||
import org.apache.commons.io.IOUtils; | ||
import org.apache.http.HttpStatus; | ||
import org.fcrepo.AbstractResource; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.codahale.metrics.annotation.Timed; | ||
|
||
/** | ||
* The purpose of this class is to allow clients to manipulate the JCR | ||
* namespaces in play in a repository. This is necessary to allow the use of | ||
* traditional Fedora namespaced PIDs. Unlike Fedora Classic, a JCR requires | ||
* that namespaces be registered before use. The catalog of namespaces is very | ||
* simple, just a set of prefix-URI pairs. | ||
* | ||
* @author ajs6f | ||
* | ||
*/ | ||
@Component | ||
@Path("/rest/fcr:namespaces") | ||
public class FedoraRepositoryNamespaces extends AbstractResource { | ||
/** | ||
* Register multiple object namespaces. | ||
* | ||
* @return 204 | ||
* @throws RepositoryException | ||
*/ | ||
@POST | ||
@Timed | ||
@Consumes({contentTypeSPARQLUpdate}) | ||
public Response updateNamespaces(final InputStream requestBodyStream) | ||
throws RepositoryException, IOException { | ||
|
||
final Session session = getAuthenticatedSession(); | ||
try { | ||
|
||
final GraphStore graph = nodeService.getNamespaceRegistryGraph(session); | ||
|
||
UpdateAction.parseExecute(IOUtils.toString(requestBodyStream), graph); | ||
|
||
session.save(); | ||
|
||
return Response.status(HttpStatus.SC_NO_CONTENT).build(); | ||
} finally { | ||
session.logout(); | ||
} | ||
} | ||
|
||
/** | ||
* @return | ||
* @throws RepositoryException | ||
* @throws IOException | ||
*/ | ||
@GET | ||
@Timed | ||
@Produces({N3, N3_ALT1, N3_ALT2, TURTLE, RDF_XML, RDF_JSON, | ||
NTRIPLES, TEXT_HTML}) | ||
public Dataset getNamespaces() throws RepositoryException, | ||
IOException { | ||
|
||
final Session session = getAuthenticatedSession(); | ||
try { | ||
|
||
final GraphStore graph = nodeService.getNamespaceRegistryGraph(session); | ||
|
||
return graph.toDataset(); | ||
} finally { | ||
session.logout(); | ||
} | ||
} | ||
|
||
} |
95 changes: 0 additions & 95 deletions
95
fcrepo-http-api/src/test/java/org/fcrepo/api/FedoraNamespacesTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.