use of org.rendersnake.HtmlCanvas in project lobcder by skoulouzis.
the class WebDataDirResource method sendContent.
@Override
public void sendContent(OutputStream out, Range range, Map<String, String> params, String contentType) throws IOException, NotAuthorizedException, BadRequestException {
Logger.getLogger(WebDataDirResource.class.getName()).log(Level.FINEST, "sendContent({0}) for {1}", new Object[] { contentType, getPath() });
try (Connection connection = getCatalogue().getConnection()) {
try (PrintStream ps = new PrintStream(out)) {
HtmlCanvas html = new HtmlCanvas();
html.table(border("1")).tr().th().content("Name").th().content("Size").th().content("Modification Date").th().content("Creation Date").th().content("Owner").th().content("Content Type").th().content("Type").th().content("Is Supervised").th().content("Uid");
String ref;
for (LogicalData ld : getCatalogue().getChildrenByParentRef(getLogicalData().getUid(), connection)) {
if (ld.isFolder()) {
ref = "../dav" + getPath() + "/" + ld.getName();
// if (ld.getUid() != 1) {
// } else {
// }
} else {
ref = "../dav" + getPath() + "/" + ld.getName();
}
html._tr().tr().td().a(href(ref)).img(src("").alt(ld.getName()))._a()._td().td().content(String.valueOf(ld.getLength())).td().content(new Date(ld.getModifiedDate()).toString()).td().content(new Date(ld.getCreateDate()).toString()).td().content(ld.getOwner()).td().content(ld.getContentTypesAsString()).td().content(ld.getType()).td().content(ld.getSupervised().toString()).td().content(ld.getUid().toString());
}
html._tr()._table();
ps.println(html.toHtml());
getCatalogue().addViewForRes(getLogicalData().getUid(), connection);
connection.commit();
connection.close();
} catch (Exception e) {
if (connection != null && !connection.isClosed()) {
connection.rollback();
connection.close();
}
throw e;
}
} catch (Exception e) {
Logger.getLogger(WebDataDirResource.class.getName()).log(Level.SEVERE, null, e);
throw new BadRequestException(this);
}
}
Aggregations