public static String getFriendlyURI( FileObject fileObject ) { return fileObject.getName().getFriendlyURI(); }
protected boolean handleOpenFileException( Exception e ) { String errorMsg = "Couldn't open file #" + data.currentFileIndex + " : " + data.file.getName().getFriendlyURI(); if ( !failAfterBadFile( errorMsg ) ) { // !meta.isSkipBadFiles()) stopAll(); return true; } stopAll(); setErrors( getErrors() + 1 ); logError( errorMsg, e ); return false; }
logBasic( "Opening file: " + data.file.getName().getFriendlyURI() );
public void openFileVFSFile() { FileObject initialFile; FileObject rootFile; try { initialFile = KettleVFS.getFileObject( getLastFileOpened() ); rootFile = initialFile.getFileSystem().getRoot(); } catch ( Exception e ) { String message = Const.getStackTracker( e ); new ErrorDialog( shell, BaseMessages.getString( PKG, "Spoon.Error" ), message, e ); return; } FileObject selectedFile = getVfsFileChooserDialog( rootFile, initialFile ).open( shell, null, Const.STRING_TRANS_AND_JOB_FILTER_EXT, Const.getTransformationAndJobFilterNames(), VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE ); if ( selectedFile != null ) { setLastFileOpened( selectedFile.getName().getFriendlyURI() ); openFile( selectedFile.getName().getFriendlyURI(), rep != null ); } }
String errorMsg = "Couldn't close file : " + data.file.getName().getFriendlyURI() + " --> " + e.toString(); log.logError( errorMsg ); if ( step.failAfterBadFile( errorMsg ) ) { // ( !meta.isSkipBadFiles() || data.isLastFile ){
String errorMsg = "Couldn't close file : " + data.file.getName().getFriendlyURI() + " --> " + e.toString(); logError( errorMsg ); if ( failAfterBadFile( errorMsg ) ) { // ( !meta.isSkipBadFiles() || data.isLastFile ){
String zipFilename = "zip:" + sourceFileObject.getName().getFriendlyURI(); FileObject zipFile = KettleVFS.getFileObject( zipFilename, this ); FileObject[] items = zipFile.findFiles( new AllFileSelector() {
VfsFileChooserDialog.VFS_DIALOG_SAVEAS ); if ( selectedFile != null ) { filename = selectedFile.getName().getFriendlyURI();
logBasic( "Opening file: " + data.file.getName().getFriendlyURI() ); } catch ( Exception e ) { String errorMsg = "Couldn't open file #" + data.filenr + " : " + data.file.getName().getFriendlyURI() + " --> " + e.toString(); logError( errorMsg ); if ( failAfterBadFile( errorMsg ) ) { // !meta.isSkipBadFiles()) stopAll();
public boolean onNewFile( FileObject file ) throws FileSystemException { if ( file == null ) { String errMsg = BaseMessages.getString( PKG, "JsonInput.Log.IsNotAFile", "null" ); logError( errMsg ); inputError( errMsg ); return false; } else if ( !file.exists() ) { String errMsg = BaseMessages.getString( PKG, "JsonInput.Log.IsNotAFile", file.getName().getFriendlyURI() ); logError( errMsg ); inputError( errMsg ); return false; } if ( hasAdditionalFileFields() ) { fillFileAdditionalFields( data, file ); } if ( file.getContent().getSize() == 0 ) { // log only basic as a warning (was before logError) if ( meta.isIgnoreEmptyFile() ) { logBasic( BaseMessages.getString( PKG, "JsonInput.Error.FileSizeZero", "" + file.getName() ) ); } else { logError( BaseMessages.getString( PKG, "JsonInput.Error.FileSizeZero", "" + file.getName() ) ); incrementErrors(); return false; } } return true; }
@Override public InputStream getInputStream(final URL url) throws ConfigurationException { FileObject file; try { final FileSystemOptions opts = getOptions(url.getProtocol()); file = (opts == null) ? VFS.getManager().resolveFile(url.toString()) : VFS.getManager().resolveFile(url.toString(), opts); if (file.getType() != FileType.FILE) { throw new ConfigurationException("Cannot load a configuration from a directory"); } final FileContent content = file.getContent(); if (content == null) { final String msg = "Cannot access content of " + file.getName().getFriendlyURI(); throw new ConfigurationException(msg); } return content.getInputStream(); } catch (final FileSystemException fse) { final String msg = "Unable to access " + url.toString(); throw new ConfigurationException(msg, fse); } }
private String getTooltip() { StringBuilder sb = new StringBuilder(); sb.append("<html>Multiple files:<br>"); for (FileObject fo : fileObjects) { sb.append(fo.getName().getFriendlyURI()); sb.append("<BR>"); } sb.append("</html>"); return sb.toString(); }
private void handleInvalidImporter(final FileObject file) { LOGGER.error("Error loading log (" + file.getName().getFriendlyURI() + "): no suitable log parser found"); String errorMessage = "Error loading log file: no suitable log parser found for " + file.getName().getFriendlyURI() + "\n" + "Go https://github.com/otros-systems/otroslogviewer/wiki/Log4jPatternLayout to check how to parse log4j custom pattern."; JOptionPane.showMessageDialog(null, errorMessage, "Error", JOptionPane.ERROR_MESSAGE); }
public static void closeQuietly(FileObject fileObject) { if (fileObject != null) { String friendlyURI = fileObject.getName().getFriendlyURI(); try { LOGGER.info(String.format("Closing file %s", friendlyURI)); fileObject.close(); LOGGER.info(String.format("File %s closed", friendlyURI)); } catch (FileSystemException ignore) { LOGGER.error(String.format("File %s is not closed: %s", friendlyURI, ignore.getMessage())); } } }
/** * @see * org.apache.commons.vfs2.FileSelector#includeFile(org.apache.commons.vfs2.FileSelectInfo) */ public boolean includeFile(FileSelectInfo fileInfo) throws Exception { File folder = archiveFile.getParentFile(); String name = fileInfo.getFile().getName().getFriendlyURI(); return filter.accept(folder, name); } };
@Override public boolean includeFile(FileSelectInfo fileInfo) { LOGGER.fine( "Uncompressing " + fileInfo.getFile().getName().getFriendlyURI()); return true; } };
@Override public String createPath(Resource resource) { final VfsResource vfsResource = (VfsResource) resource; return vfsResource.getFileObject().getName().getFriendlyURI(); }
@Override public String createPath(final Resource resource) { final VfsResource vfsResource = (VfsResource) resource; return vfsResource.getFileObject().getName().getFriendlyURI(); }
@Override public void actionPerformed(ActionEvent actionEvent) { if (JOtrosVfsBrowserDialog.ReturnValue.Approve.equals(jOtrosVfsBrowserDialog.showOpenDialog(TestDialog.this,"title"))){ textField.setText(jOtrosVfsBrowserDialog.getSelectedFile().getName().getFriendlyURI()); } } };
private void importFromFile(FileObject file) throws ConfigurationException, IOException { try (InputStream is = file.getContent().getInputStream()) { final XMLConfiguration xmlConfiguration = new XMLConfiguration(); xmlConfiguration.load(is); final List<ColumnLayout> columnLayouts = loadColumnLayouts(xmlConfiguration); importColumnLayouts(columnLayouts); otrosApplication.getStatusObserver().updateStatus(String.format("Column layouts have been imported from %s", file.getName().getFriendlyURI())); } finally { Utils.closeQuietly(file); } }