TachyonURI currentPath = new TachyonURI(requestPath);
request.setAttribute("currentPath", currentPath.toString());
request.setAttribute("viewingOffset", 0);
try {
ClientFileInfo clientFileInfo = mMasterInfo.getClientFileInfo(currentPath);
UiFileInfo currentFileInfo = new UiFileInfo(clientFileInfo);
if (null == currentFileInfo.getAbsolutePath()) {
throw new FileDoesNotExistException(currentPath.toString());
}
request.setAttribute("currentDirectory", currentFileInfo);
request.setAttribute("blockSizeByte", currentFileInfo.getBlockSizeBytes());
if (!currentFileInfo.getIsDirectory()) {
String tmpParam = request.getParameter("offset");
long offset = 0;
try {
if (tmpParam != null) {
offset = Long.valueOf(tmpParam);
}
} catch (NumberFormatException nfe) {
offset = 0;
}
if (offset < 0) {
offset = 0;
} else if (offset > clientFileInfo.getLength()) {
offset = clientFileInfo.getLength();
}
displayFile(new TachyonURI(currentFileInfo.getAbsolutePath()), request, offset);
request.setAttribute("viewingOffset", offset);
getServletContext().getRequestDispatcher("/viewFile.jsp").forward(request, response);
return;