List of usage examples for org.apache.commons.vfs2 FileType IMAGINARY
FileType IMAGINARY
To view the source code for org.apache.commons.vfs2 FileType IMAGINARY.
Click Source Link
From source file:org.metaborg.intellij.vfs.IntelliJFileObject.java
/** * {@inheritDoc}//from w ww . j a v a2s. co m */ @Override protected FileType doGetType() throws Exception { assert isAttached(); if (this.file == null || !this.file.exists()) return FileType.IMAGINARY; else if (this.file.isDirectory()) return FileType.FOLDER; else return FileType.FILE; }
From source file:org.obiba.opal.shell.web.ExportCommandOptionsDtoImpl.java
private String addFileExtensionIfMissing(String outputFilePath, String outputFileFormat) { String modifiedPath = outputFilePath; FileObject file = null;//from ww w . j ava2 s. c o m try { file = resolveFileInFileSystem(outputFilePath); // Add the extension if the file object is an existing file (FileType.FILE) // or a new file (FileType.IMAGINARY). We assume here that any "imaginary" file object // is a non-existent folder. if (file.getType() == FileType.FILE) { modifiedPath = addExtension(outputFileFormat, outputFilePath); } else if (file.getType() == FileType.IMAGINARY) { if ("xml".equals(outputFileFormat) && !outputFilePath.endsWith(".zip")) { modifiedPath = addExtension(outputFileFormat, outputFilePath); } else if ("csv".equals(outputFileFormat)) { // Create the directory file.createFolder(); } } } catch (FileSystemException ex) { log.error("Unexpected file system exception in addFileExtensionIfMissing", ex); } return modifiedPath; }
From source file:org.pentaho.big.data.impl.vfs.hdfs.HDFSFileObject.java
@Override protected FileType doGetType() throws Exception { HadoopFileStatus status = null;//from ww w .ja v a2 s.c o m try { status = hdfs.getFileStatus(hdfs.getPath(getName().getPath())); } catch (Exception ex) { // Ignore } if (status == null) { return FileType.IMAGINARY; } else if (status.isDir()) { return FileType.FOLDER; } else { return FileType.FILE; } }
From source file:org.pentaho.big.data.impl.vfs.hdfs.HDFSFileObjectTest.java
@Test public void testDoGetTypeImaginary() throws Exception { assertEquals(FileType.IMAGINARY, hdfsFileObject.doGetType()); }
From source file:org.pentaho.di.job.entries.zipfile.ZipJobEntryPatternFileSelectorTest.java
@Test public void testDifferentFileType() throws Exception { Mockito.when(fileObjectMock.getType()).thenReturn(FileType.IMAGINARY); boolean includeFile = fileSelector.includeFile(fileSelectInfoMock); Assert.assertFalse(includeFile);/*from w ww . ja v a2 s .c o m*/ }
From source file:org.pentaho.googlecloudstorage.vfs.GoogleCloudStorageFileObject.java
/** * Gets the file type/*ww w .j a v a 2 s . co m*/ * * @return The file type * @throws Exception */ @Override protected FileType doGetType() throws Exception { if (getName().getPath().equals(DELIMITER) || getName().getPath().endsWith(DELIMITER) || getName().getPath().equals("")) { return FileType.FOLDER; } Blob blob = getBlob(); if (blob != null) { if (blob.getName().endsWith(DELIMITER)) { return FileType.FOLDER; } else { return FileType.FILE; } } return FileType.IMAGINARY; }
From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.dialogs.RepositoryPublishDialog.java
protected boolean validateInputs(final boolean onConfirm) { if (super.validateInputs(onConfirm) == false) { return false; }//from w ww . j ava 2s . c o m if (onConfirm == false) { return true; } final String reportName = getFileNameTextField().getText(); if (StringUtils.isEmpty(reportName) == false && reportName.endsWith(REPORT_BUNDLE_EXTENSION) == false) { final String safeReportName = reportName + REPORT_BUNDLE_EXTENSION; getFileNameTextField().setText(safeReportName); } try { final FileObject selectedView = getSelectedView(); final String validateName = getSelectedFile(); if (validateName == null || selectedView == null) { return false; } String filename = getFileNameTextField().getText(); if (!PublishUtil.validateName(filename)) { JOptionPane.showMessageDialog(RepositoryPublishDialog.this, Messages.getInstance().formatMessage("PublishToServerAction.IllegalName", filename, PublishUtil.getReservedCharsDisplay()), Messages.getInstance().getString("PublishToServerAction.Error.Title"), JOptionPane.ERROR_MESSAGE); return false; } final FileObject targetFile = selectedView .resolveFile(URLEncoder.encodeUTF8(getFileNameTextField().getText()).replaceAll(":", "%3A") .replaceAll("\\+", "%2B").replaceAll("\\!", "%21")); final FileObject fileObject = selectedView.getFileSystem().resolveFile(targetFile.getName()); if (fileObject.getType() == FileType.IMAGINARY) { return true; } final int result = JOptionPane.showConfirmDialog(this, Messages.getInstance().formatMessage("PublishToServerAction.FileExistsOverride", validateName), Messages.getInstance().getString("PublishToServerAction.Information.Title"), JOptionPane.YES_NO_OPTION); return result == JOptionPane.YES_OPTION; } catch (FileSystemException fse) { UncaughtExceptionsModel.getInstance().addException(fse); return false; } catch (UnsupportedEncodingException uee) { UncaughtExceptionsModel.getInstance().addException(uee); return false; } }
From source file:org.pentaho.reporting.libraries.pensol.WebSolutionFileObject.java
/** * Determines the type of this file. Must not return null. The return value of this method is cached, so the * implementation can be expensive.//from w ww . j a v a 2s.c o m */ protected FileType doGetType() throws Exception { if (getName().getDepth() < 2) { return FileType.FOLDER; } if (fs.exists(getName()) == false) { return FileType.IMAGINARY; } if (fs.isDirectory(getName())) { return FileType.FOLDER; } return FileType.FILE; }
From source file:org.wso2.carbon.inbound.endpoint.protocol.file.MockFile.java
protected FileType doGetType() throws Exception { if (getName().getPath().endsWith(".fail")) { return FileType.IMAGINARY; }/*from w ww. jav a 2s . c o m*/ if (getName().getPath().endsWith(".lock") && !lockFileCreated) { return FileType.IMAGINARY; } //If file name ends with file separator, it is mocked as folder if (getName().getPath().endsWith(File.separator)) { return FileType.FOLDER; } return getName().getType(); }
From source file:org.wso2.carbon.transport.filesystem.connector.server.FileSystemConsumer.java
/** * Determine whether file object is a file or a folder. * * @param fileObject File to get the type of * @return FileType of given file *//*ww w. ja va2s.com*/ private FileType getFileType(FileObject fileObject) throws FileSystemServerConnectorException { try { return fileObject.getType(); } catch (FileSystemException e) { errorHandler.handleError( new FileSystemServerConnectorException("Error occurred when determining whether file: " + FileTransportUtils.maskURLPassword(fileObject.getName().getURI()) + " is a file or a folder", e), null, null); } return FileType.IMAGINARY; }