protected ActionForward doExecute(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
Session hibernateSession = getSession(request);
FileManagerForm fform = (FileManagerForm)form;
try {
if (fform.getAction() == null) {
fform.setAction("list");
fform.setDirectoryId(Integer.toString(
fileSystem.getRootDirectory().getId()));
}
if (fform.getAction().equals("upload")) {
FormFile formFile = fform.getFormFile();
fileSystem.createFile(hibernateSession, Integer.parseInt(fform.getDirectoryId()), formFile.getFileName(),
formFile.getContentType(), formFile.getFileSize(), formFile.getInputStream());
} else if (fform.getAction().equals("download")) {
File file = fileSystem.getFile(hibernateSession, Integer.parseInt(fform.getFileId()));
writeFileToResponse(response, file);
} else if (fform.getAction().equals("delete")) {
fileSystem.deleteFile(hibernateSession, Integer.parseInt(fform.getFileId()));
} else if (fform.getAction().equals("mkdir")) {
int parentDirectoryId = Integer.parseInt(fform.getDirectoryId());
fileSystem.createDirectory(hibernateSession, parentDirectoryId, fform.getName());
} else if (fform.getAction().equals("rmdir")) {
Directory directory = fileSystem.getDirectory(hibernateSession, Integer.parseInt(fform.getDirectoryId()));
Directory parent = directory.getParent();
if (parent == null) {
parent = fileSystem.getRootDirectory();
}
fform.setDirectoryId(Integer.toString(parent.getId()));
fileSystem.deleteDirectory(hibernateSession, directory.getId());
}
hibernateSession.flush();
hibernateSession.connection().commit();
if (fform.getDirectoryId() != null) {
Directory directory = fileSystem.getDirectory(hibernateSession, Integer.parseInt(fform.getDirectoryId()));
request.setAttribute("directory", directory);
}
request.setAttribute("root", fileSystem.getRootDirectory());
return mapping.findForward("display");
} catch (ObjectNotFoundException ex) {