Mercurial > dive4elements > framework
diff artifact-database/src/main/java/de/intevation/artifactdatabase/rest/OutRepresentation.java @ 29:22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
artifacts/trunk@69 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 10 Sep 2009 15:49:17 +0000 |
parents | |
children | c4d85a8532d1 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/OutRepresentation.java Thu Sep 10 15:49:17 2009 +0000 @@ -0,0 +1,41 @@ +package de.intevation.artifactdatabase.rest; + +import org.restlet.representation.OutputRepresentation; + +import de.intevation.artifacts.Artifact; + +import org.restlet.data.MediaType; + +import java.io.OutputStream; +import java.io.IOException; + +import org.w3c.dom.Document; + +/** + * @author Sascha L. Teichmann (sascha.teichmann@intevation) + */ +public class OutRepresentation +extends OutputRepresentation +{ + protected Artifact artifact; + protected Document document; + protected Object context; + + public OutRepresentation( + MediaType mediaType, + Artifact artifact, + Document document, + Object context + ) { + super(mediaType); + this.artifact = artifact; + this.document = document; + this.context = context; + } + + public void write(OutputStream outputStream) throws IOException { + byte [] bytes = artifact.out(document, context); + outputStream.write(bytes); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: