public Representation represent(Variant variant) throws ResourceException {
if (cj == null) {
throw new ResourceException(404);
}
Representation representation = null;
if (variant.getMediaType() == MediaType.APPLICATION_XML) {
representation = new WriterRepresentation(MediaType.APPLICATION_XML) {
public void write(Writer writer) throws IOException {
CrawlJobModel model = makeDataModel();
model.put("heapReport", getEngine().heapReportData());
XmlMarshaller.marshalDocument(writer, "job", model);
}
};
} else {
representation = new WriterRepresentation(MediaType.TEXT_HTML) {
public void write(Writer writer) throws IOException {
JobResource.this.writeHtml(writer);
}
};
}
// TODO: remove if not necessary in future?
// honor requested charset?
representation.setCharacterSet(CharacterSet.UTF_8);
return representation;
}