/** * Check the provided filename and currentPath parameters and raises an error if one of these * parameters are invalid * * @return INPUT one or more errors are found. Otherwise null. */ protected String validateFullPath() { if (!StorageManagerUtil.isValidFilenameNoExtension(this.getFilename())) { this.addActionError(this.getText("error.filebrowser.filename.invalid")); return INPUT; } if (!StorageManagerUtil.isValidDirName(this.getCurrentPath())) { this.addActionError(this.getText("error.filebrowser.filepath.invalid")); return INPUT; } return null; }
public String createDir() { try { if (!StorageManagerUtil.isValidDirName(this.getCurrentPath())) { this.addActionError(this.getText("error.filebrowser.filepath.invalid")); return INPUT; } if (!StorageManagerUtil.isValidDirName(this.getDirname()) || this.getDirname().trim().length() == 0) { this.addActionError(this.getText("error.filebrowser.dirname.invalid")); return INPUT; } this.getStorageManager() .createDirectory( this.getCurrentPath() + this.getDirname(), this.getProtectedFolderBoolean()); } catch (Throwable t) { _logger.error( "error creating dir, fullPath: {} text: {}", this.getCurrentPath(), this.getDirname(), t); return FAILURE; } return SUCCESS; }
public String upload() { try { if (!StorageManagerUtil.isValidDirName(this.getCurrentPath())) { this.addActionError(this.getText("error.filebrowser.filepath.invalid")); return INPUT; } String result = this.checkExistingFileExtension(this.getCurrentPath(), this.getUploadFileName(), false); if (null != result) return result; this.getStorageManager() .saveFile( this.getCurrentPath() + this.getUploadFileName(), this.getProtectedFolderBoolean(), this.getInputStream()); } catch (Throwable t) { _logger.error("error in upload", t); return FAILURE; } return SUCCESS; }
public BasicFileAttributeView[] getFilesAttributes() { try { if (!StorageManagerUtil.isValidDirName(this.getCurrentPath())) { _logger.info("invalid path specified: {}", this.getCurrentPath()); this.setCurrentPath(""); } if (null == this.getProtectedFolder()) { BasicFileAttributeView[] bfav = new BasicFileAttributeView[2]; bfav[0] = this.getRootFolder(false); bfav[1] = this.getRootFolder(true); return bfav; } else { return this.getStorageManager() .listAttributes(this.getCurrentPath(), this.getProtectedFolderBoolean()); } } catch (Throwable t) { _logger.error("error extraction file attributes, fullPath: {} ", this.getCurrentPath(), t); return null; } }