@Override
protected void folderBody(ITransaction transaction, String path,
HttpServletResponse resp, HttpServletRequest req)
throws IOException {
StoredObject so = _store.getStoredObject(transaction, path);
if (so == null) {
resp.sendError(HttpServletResponse.SC_NOT_FOUND, req
.getRequestURI());
} else {
if (so.isNullResource()) {
String methodsAllowed = DeterminableMethod
.determineMethodsAllowed(so);
resp.addHeader("Allow", methodsAllowed);
resp.sendError(WebdavStatus.SC_METHOD_NOT_ALLOWED);
return;
}
if (so.isFolder()) {
// TODO some folder response (for browsers, DAV tools
// use propfind) in html?
DateFormat shortDF= getDateTimeFormat(req.getLocale());
resp.setContentType("text/html");
resp.setCharacterEncoding("UTF8");
OutputStream out = resp.getOutputStream();
String[] children = _store.getChildrenNames(transaction, path);
children = children == null ? new String[] {} : children;
StringBuilder childrenTemp = new StringBuilder();
childrenTemp.append("<html><head><title>Content of folder");
childrenTemp.append(path);
childrenTemp.append("</title><style type=\"text/css\">");
childrenTemp.append(getCSS());
childrenTemp.append("</style></head>");
childrenTemp.append("<body>");
childrenTemp.append(getHeader(transaction, path, resp, req));
childrenTemp.append("<table>");
childrenTemp.append("<tr><th>Name</th><th>Size</th><th>Created</th><th>Modified</th></tr>");
childrenTemp.append("<tr>");
childrenTemp.append("<td colspan=\"4\"><a href=\"../\">Parent</a></td></tr>");
boolean isEven= false;
for (String child : children) {
isEven= !isEven;
childrenTemp.append("<tr class=\"");
childrenTemp.append(isEven ? "even" : "odd");
childrenTemp.append("\">");
childrenTemp.append("<td>");
childrenTemp.append("<a href=\"");
childrenTemp.append(child);
StoredObject obj= _store.getStoredObject(transaction, path+"/"+child);
if (obj.isFolder())
{
childrenTemp.append("/");
}
childrenTemp.append("\">");
childrenTemp.append(child);
childrenTemp.append("</a></td>");
if (obj.isFolder())
{
childrenTemp.append("<td>Folder</td>");
}
else
{
childrenTemp.append("<td>");
childrenTemp.append(obj.getResourceLength());
childrenTemp.append(" Bytes</td>");
}
if (obj.getCreationDate() != null)
{
childrenTemp.append("<td>");
childrenTemp.append(shortDF.format(obj.getCreationDate()));
childrenTemp.append("</td>");
}
else
{
childrenTemp.append("<td></td>");
}
if (obj.getLastModified() != null)
{
childrenTemp.append("<td>");
childrenTemp.append(shortDF.format(obj.getLastModified()));
childrenTemp.append("</td>");
}
else
{
childrenTemp.append("<td></td>");