Larry Touve wrote:
> I'm using Jersey for building OGC compliant Web Services. I'm currently
> working on a Web Coverage Service, and discovered the jersey-multipart code
> that is just what I need. However, I have been unable to figure out how to
> set specific items in the header. Is it possible to set the Content-ID and
> the Content-Description for the BodyParts?
>
>
You can definitely do this ... it will just require creating the body
parts separately before stringing them together.
BodyPart coverageBodyPart = new BodyPart();
coverageBodyPart.setMediaType(MediaType.APPLICATION_XML_TYPE);
coverageBodyPart.setEntity(coverageInfo);
coverageBodyPart.getHeaders().putSingle("Content-ID", "xxx");
coverageBodyPart.getHeaders().putSingle("Content-Description", "yyy");
BodyPart imageBodyPart = new BodyPart();
... set this up in a similar manner ...
MultiPart multiPart = new MultiPart().
bodyPart(coverageBodyPart).
bodyPart(imageBodyPart);
> Thanks,
> Larry
>
>
Craig
> Here's my code:
>
> @Path("/Coverage/{arg1}")
> public class CoverageProvider
> {
> :
>
> @GET
> @Produces("multipart/mixed")
> public Response getCoverage()
> {
> MultivaluedMap<String, String> map = uri.getPathParameters();
> String arg1 = map.getFirst("arg1");
> FileDataSource image = ... (gets the image file)
> String coverageInfo = ... (gets the xml structured coverage
> information)
>
> MultiPart multiPart = new MultiPart().
> bodyPart(new BodyPart(coverageInfo,
> MediaType.APPLICATION_XML_TYPE)).
> bodyPart(new BodyPart(image, new MediaType("image",
> "nitf")));
>
> return Response.ok(multiPart,
> MultiPartMediaTypes.MULTIPART_MIXED_TYPE).build();
> }
> :
> }
>