Skip to content

Commit

Permalink
Three tests for multiple-datastream update and projected node still f…
Browse files Browse the repository at this point in the history
…ailing
  • Loading branch information
ajs6f committed May 17, 2013
1 parent fdcce01 commit 731ecad
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Expand Up @@ -29,7 +29,7 @@

import org.fcrepo.AbstractResource;
import org.fcrepo.FedoraResource;
import org.fcrepo.responses.GraphStreamingOutput;
import org.fcrepo.responses.GraphStoreStreamingOutput;
import org.slf4j.Logger;
import org.springframework.stereotype.Component;

Expand All @@ -53,7 +53,7 @@ public Response getVersionList(@PathParam("path")
try {
final FedoraResource resource = nodeService.getObject(session, path);

return Response.ok(new GraphStreamingOutput(resource.getVersionGraphStore(),
return Response.ok(new GraphStoreStreamingOutput(resource.getVersionGraphStore(),
bestPossibleResponse.getMediaType())).build();

} finally {
Expand Down Expand Up @@ -98,7 +98,7 @@ public Response getVersion(@PathParam("path")
return Response.status(Response.Status.NOT_FOUND).build();
} else {

return Response.ok(new GraphStreamingOutput(resource.getGraphStore(),
return Response.ok(new GraphStoreStreamingOutput(resource.getGraphStore(),
bestPossibleResponse.getMediaType())).build();
}

Expand Down
2 changes: 1 addition & 1 deletion fcrepo-http-api/src/test/resources/spring-test/rest.xml
Expand Up @@ -14,7 +14,7 @@
<context:annotation-config/>

<context:component-scan
base-package="org.fcrepo.api, org.fcrepo.serialization, org.fcrepo.responses"/>
base-package="org.fcrepo.api, org.fcrepo.serialization, org.fcrepo.responses, org.fcrepo.exceptionhandlers"/>

<util:map id="serializers" key-type="java.lang.String" map-class="java.util.HashMap"
value-type="org.fcrepo.serialization.FedoraObjectSerializer">
Expand Down
Expand Up @@ -10,6 +10,6 @@
<bean id="containerWrapper" class="org.fcrepo.test.util.ContainerWrapper" init-method="start" destroy-method="stop" >
<property name="port" value="${test.port:8080}"/>
<property name="contextConfigLocations" value="classpath:spring-test/master.xml" />
<property name="packagesToScan" value="org.fcrepo.api, org.fcrepo.responses"/>
<property name="packagesToScan" value="org.fcrepo.api, org.fcrepo.responses, org.fcrepo.exceptionhandlers"/>
</bean>
</beans>
Expand Up @@ -14,16 +14,16 @@

import com.hp.hpl.jena.update.GraphStore;

public class GraphStreamingOutput implements StreamingOutput {
public class GraphStoreStreamingOutput implements StreamingOutput {

private final static Logger LOGGER = LoggerFactory
.getLogger(GraphStreamingOutput.class);
.getLogger(GraphStoreStreamingOutput.class);

private final GraphStore m_graphStore;

private final String m_format;

public GraphStreamingOutput(final GraphStore graphStore,
public GraphStoreStreamingOutput(final GraphStore graphStore,
final MediaType mediaType) {
m_graphStore = graphStore;
m_format =
Expand Down
Expand Up @@ -27,18 +27,18 @@
import org.springframework.stereotype.Component;

import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.update.GraphStore;
import com.hp.hpl.jena.sparql.modify.GraphStoreBasic;

@Provider
@Component
public class RdfProvider implements MessageBodyWriter<GraphStore> {
public class RdfProvider implements MessageBodyWriter<Dataset> {

private static final Set<String> rdfMimeTypes = copyOf(new String[] {
TEXT_HTML, N3, N3_ALT1, N3_ALT2, TURTLE, RDF_XML, RDF_JSON,
NTRIPLES});

@Override
public void writeTo(final GraphStore t, final Class<?> type,
public void writeTo(final Dataset rdf, final Class<?> type,
final Type genericType, final Annotation[] annotations,
final MediaType mediaType,
final MultivaluedMap<String, Object> httpHeaders,
Expand All @@ -48,7 +48,8 @@ public void writeTo(final GraphStore t, final Class<?> type,
// add a Content-type header
httpHeaders.put("Content-type", of((Object) mediaType.toString()));

new GraphStreamingOutput(t, mediaType).write(entityStream);
new GraphStoreStreamingOutput(new GraphStoreBasic(rdf), mediaType)
.write(entityStream);

}

Expand All @@ -57,12 +58,11 @@ public boolean isWriteable(final Class<?> type, final Type genericType,
final Annotation[] annotations, final MediaType mediaType) {

return rdfMimeTypes.contains(mediaType.toString()) &&
(type.equals(Dataset.class) || genericType.getClass().equals(
Dataset.class));
Dataset.class.isAssignableFrom(type);
}

@Override
public long getSize(final GraphStore t, final Class<?> type,
public long getSize(final Dataset rdf, final Class<?> type,
final Type genericType, final Annotation[] annotations,
final MediaType mediaType) {
// we don't know in advance how large the result might be
Expand Down
Expand Up @@ -11,7 +11,7 @@
import javax.jcr.RepositoryException;
import javax.ws.rs.WebApplicationException;

import org.fcrepo.responses.GraphStreamingOutput;
import org.fcrepo.responses.GraphStoreStreamingOutput;
import org.junit.Test;
import org.slf4j.Logger;

Expand All @@ -38,8 +38,8 @@ public void testStuff() throws WebApplicationException, IOException,
g.add(new Triple(createURI("test:subject"),
createURI("test:predicate"), createURI("test:object")));
graphStore.setDefaultGraph(g);
final GraphStreamingOutput test =
new GraphStreamingOutput(graphStore, NTRIPLES_TYPE);
final GraphStoreStreamingOutput test =
new GraphStoreStreamingOutput(graphStore, NTRIPLES_TYPE);
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
test.write(out);
final String serialized = out.toString();
Expand Down

0 comments on commit 731ecad

Please sign in to comment.