use of org.jaffa.applications.jaffa.modules.admin.components.fileexplorer.ui.exceptions.FileExplorerException in project jaffa-framework by jaffa-projects.
the class FileExplorerComponent method retrieveFiles.
/**
* This retrieves the files for the base directory
* @throws ApplicationExceptions if any error occurs while reading the files.
* @throws FrameworkException if any error occurs.
*/
protected FileExplorerBean retrieveFiles(File path) throws FrameworkException, ApplicationExceptions {
// Path relative to the document root folder
String relPath = null;
if (path == null) {
path = m_root;
relPath = "";
} else {
if (!path.getAbsolutePath().startsWith(m_root.getAbsolutePath()))
throw new ApplicationExceptions(new FileExplorerException(FileExplorerException.ILLEGAL_ACCESS, path.getAbsolutePath()));
else
relPath = path.getAbsolutePath().substring(m_root.getAbsolutePath().length() + 1);
}
if (log.isDebugEnabled())
log.debug("Get List of Folders/Files For " + relPath + "[" + path.getAbsolutePath() + "]");
FileExplorerBean bean = new FileExplorerBean();
// @todo - implement uploads
// bean.setUploadAllowed(canUpload(relPath,path));
// Add in sub-folders
File[] dirs = path.listFiles(new FolderFilter(m_root));
if (dirs != null)
for (int i = 0; i < dirs.length; i++) {
String name = relPath + "/" + dirs[i].getName();
if (log.isDebugEnabled())
log.debug(i + ") Found Folder " + name + " -> " + dirs[i].getAbsolutePath());
bean.addFolder(dirs[i], canDownload(name, dirs[i]), false, /* @todo canRename(name,dirs[i])*/
canDelete(name, dirs[i]));
}
// Add in files
File[] files = path.listFiles(new FileFilter(m_root));
if (files != null)
for (int i = 0; i < files.length; i++) {
String name = relPath + "/" + files[i].getName();
if (log.isDebugEnabled())
log.debug(i + ") Found File " + name + " -> " + files[i].getAbsolutePath());
bean.addFile(files[i], canDownload(name, files[i]), false, /* @todo canRename(name,files[i]) */
canDelete(name, files[i]));
}
return bean;
}
use of org.jaffa.applications.jaffa.modules.admin.components.fileexplorer.ui.exceptions.FileExplorerException in project jaffa-framework by jaffa-projects.
the class FileExplorerComponent method display.
/**
* This will retrieve the file contents of the log4j xml file and return the FormKey for rendering the component.
* @return the FormKey for rendering the component.
* @throws FrameworkException if any error ocurrs in obtaining the contents of the log4j xml file.
*/
public FormKey display() throws FrameworkException, ApplicationExceptions {
if (m_docRoot == null) {
m_docRoot = System.getProperty("user.home");
m_pathName = "Home";
}
if (m_docRoot != null && m_root == null)
m_root = new File(m_docRoot);
if (m_docRoot == null || m_root == null || !m_root.exists())
throw new ApplicationExceptions(new FileExplorerException(FileExplorerException.INVALID_ROOT, m_root));
if (!m_root.isDirectory())
throw new ApplicationExceptions(new FileExplorerException(FileExplorerException.ROOT_NOT_FOLDER, m_root));
return getCurrentFormKey();
}
Aggregations