{
log.debug("Created Capability map for agent: " + agent);
}
MediaType mediaType = cm.getPreferredMediaType();
MimeType mimeType = cm.getPreferredType();
if (mediaType == null)
{
log.error("CapabilityMap returned a null media type");
throw new PipelineException("CapabilityMap returned a null media type");
}
if (mimeType == null)
{
log.error("CapabilityMap returned a null mime type");
throw new PipelineException("CapabilityMap returned a null mime type");
}
String encoding = request.getRequest().getCharacterEncoding();
if (encoding == null)
{
if (mediaType != null && mediaType.getCharacterSet() != null)
{
encoding = mediaType.getCharacterSet();
}
}
if (log.isDebugEnabled())
{
log.debug("MediaType: " + mediaType.getName());
log.debug("Encoding: " + encoding);
log.debug("Mimetype: " + mimeType.getName());
}
// Put the encoding in the request
request.setCharacterEncoding(encoding);
// Put the CapabilityMap into the request
request.setCapabilityMap(cm);
// Put the Media Type into the request
request.setMediaType(mediaType.getName());
// Put the Mime Type into the request
request.setMimeType(mimeType.getName());
// Put the Mime Type and Charset into the response
StringBuffer contentType = new StringBuffer(mimeType.getName());
if (encoding != null)
{
contentType.append("; charset=" + encoding);
}
request.getResponse().setContentType(contentType.toString());