Skip to content

Commit

Permalink
Added first simple conneg example at /rest/objects/{pid}
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Feb 26, 2013
1 parent 80dcb7e commit fa8191f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 29 deletions.
8 changes: 2 additions & 6 deletions fcrepo-http-api/pom.xml
Expand Up @@ -16,6 +16,7 @@
<name>fcrepo 4.x HTTP API</name>

<dependencies>

<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-kernel</artifactId>
Expand All @@ -28,12 +29,7 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.googlecode.htmleasy</groupId>
<artifactId>htmleasy</artifactId>
<version>0.7</version>
</dependency>


<dependency>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>enunciate-cxf-rt</artifactId>
Expand Down
Expand Up @@ -33,16 +33,13 @@
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.fcrepo.AbstractResource;
import org.fcrepo.jaxb.responses.ObjectProfile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.googlecode.htmleasy.ViewWith;

@Path("/objects")
public class FedoraObjects extends AbstractResource {

Expand Down Expand Up @@ -146,7 +143,6 @@ public Response ingest(@PathParam("pid")
@GET
@Path("/{pid}")
@Produces({TEXT_XML, APPLICATION_JSON, TEXT_HTML})
@ViewWith("/views/objectProfile")
public ObjectProfile getObject(@PathParam("pid")
final String pid) throws RepositoryException, IOException {

Expand Down
31 changes: 31 additions & 0 deletions fcrepo-http-api/src/main/resources/views/object.xslt
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fedora-access="http://www.fedora.info/definitions/1/0/access/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/1999/XSL/Transform http://www.w3.org/2007/schema-for-xslt20.xsd
http://www.w3.org/1999/xhtml http://www.w3.org/2002/08/xhtml/xhtml1-transitional.xsd"
exclude-result-prefixes="xs" version="2.0">

<!-- transforms an objectProfile into an HTML page -->

<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
<xsl:value-of select="/fedora-access:objectProfile/@pid"/>
</title>
</head>
<body>
<h3>Fedora object <xsl:value-of
select="/fedora-access:objectProfile/fedora-access:objLabel"/></h3>
<div>
<span></span>
</div>
</body>

</html>

</xsl:template>

</xsl:stylesheet>
19 changes: 0 additions & 19 deletions fcrepo-http-api/src/main/resources/views/objectProfile

This file was deleted.

12 changes: 12 additions & 0 deletions fcrepo-webapp/src/main/resources/spring/rest.xml
Expand Up @@ -61,6 +61,18 @@
<ref bean="wildcardExceptionMapper"/>
<ref bean="jaxbElementProvider"/>
<ref bean="jsonProvider"/>
<bean class="org.apache.cxf.jaxrs.provider.XSLTJaxbProvider">
<property name="outMediaTemplates">
<map>
<entry key="text/html" value="classpath:/views/object.xslt"/>
</map>
</property>
<!--
<property name="resolver">
<bean class="org.apache.xml.resolver.helpers.BootstrapResolver"/>
</property>
-->
</bean>
</jaxrs:providers>
</jaxrs:server>

Expand Down

0 comments on commit fa8191f

Please sign in to comment.