List of usage examples for org.apache.commons.vfs FileObject getName
public FileName getName();
From source file:org.pentaho.di.core.playlist.FilePlayListReplay.java
private void initializeCurrent(FileObject file, String filePart) throws KettleException { try {/*from w w w .j av a 2 s.co m*/ FileObject lineFile = AbstractFileErrorHandler.getReplayFilename(lineNumberDirectory, file.getName().getBaseName(), replayDate, lineNumberExtension, filePart); if (lineFile.exists()) { currentLineNumberFile = new FilePlayListReplayLineNumberFile(lineFile, encoding, file, filePart); } else { currentLineNumberFile = new FilePlayListReplayFile(file, filePart); } FileObject errorFile = AbstractFileErrorHandler.getReplayFilename(errorDirectory, file.getName().getURI(), replayDate, errorExtension, AbstractFileErrorHandler.NO_PARTS); if (errorFile.exists()) { currentErrorFile = new FilePlayListReplayErrorFile(errorFile, file); } else { currentErrorFile = new FilePlayListReplayFile(file, AbstractFileErrorHandler.NO_PARTS); } } catch (IOException e) { throw new KettleException(e); } }
From source file:org.pentaho.di.core.playlist.FilePlayListReplayLineNumberFile.java
private void initialize(FileObject lineNumberFile, String encoding) throws KettleException { BufferedReader reader = null; try {/*from w w w . j a v a 2 s.co m*/ if (encoding == null) { reader = new BufferedReader(new InputStreamReader(KettleVFS.getInputStream(lineNumberFile))); } else { reader = new BufferedReader( new InputStreamReader(KettleVFS.getInputStream(lineNumberFile), encoding)); } String line = null; while ((line = reader.readLine()) != null) { if (line.length() > 0) { lineNumbers.add(Long.valueOf(line)); } } } catch (Exception e) { throw new KettleException("Could not read line number file " + lineNumberFile.getName().getURI(), e); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { throw new KettleException( "Could not close line number file " + lineNumberFile.getName().getURI(), e); } } } }
From source file:org.pentaho.di.core.plugins.CartePluginType.java
protected void registerXmlPlugins() throws KettlePluginException { for (PluginFolderInterface folder : pluginFolders) { if (folder.isPluginXmlFolder()) { List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder()); for (FileObject file : pluginXmlFiles) { try { Document document = XMLHandler.loadXMLFile(file); Node pluginNode = XMLHandler.getSubNode(document, "plugin"); if (pluginNode != null) { registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL()); }// w w w . j a v a 2s .com } catch (Exception e) { // We want to report this plugin.xml error, perhaps an XML typo or // something like that... // log.logError("Error found while reading step plugin.xml file: " + file.getName().toString(), e); } } } } }
From source file:org.pentaho.di.core.plugins.JobEntryPluginType.java
protected void registerXmlPlugins() throws KettlePluginException { for (PluginFolderInterface folder : pluginFolders) { if (folder.isPluginXmlFolder()) { List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder()); for (FileObject file : pluginXmlFiles) { try { Document document = XMLHandler.loadXMLFile(file); Node pluginNode = XMLHandler.getSubNode(document, "plugin"); registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL()); } catch (Exception e) { // We want to report this plugin.xml error, perhaps an XML typo or something like that... // log.logError(/*from ww w .j a va 2 s .c o m*/ "Error found while reading job entry plugin.xml file: " + file.getName().toString(), e); } } } } }
From source file:org.pentaho.di.core.plugins.PartitionerPluginType.java
protected void registerXmlPlugins() throws KettlePluginException { for (PluginFolderInterface folder : pluginFolders) { if (folder.isPluginXmlFolder()) { List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder()); for (FileObject file : pluginXmlFiles) { try { Document document = XMLHandler.loadXMLFile(file); Node pluginNode = XMLHandler.getSubNode(document, "partitioner-plugin"); if (pluginNode != null) { registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL()); }// w ww. j a v a 2 s .c o m } catch (Exception e) { // We want to report this plugin.xml error, perhaps an XML typo or something like that... // log.logError("Error found while reading partitioning plugin.xml file: " + file.getName().toString(), e); } } } } }
From source file:org.pentaho.di.core.plugins.PluginFolder.java
public FileObject[] findJarFiles(final boolean includeLibJars) throws KettleFileException { try {/* w w w . j a va2 s .c om*/ // Find all the jar files in this folder... // FileObject folderObject = KettleVFS.getFileObject(this.getFolder()); FileObject[] fileObjects = folderObject.findFiles(new FileSelector() { @Override public boolean traverseDescendents(FileSelectInfo fileSelectInfo) throws Exception { FileObject fileObject = fileSelectInfo.getFile(); String folder = fileObject.getName().getBaseName(); FileObject kettleIgnore = fileObject.getChild(".kettle-ignore"); return includeLibJars || (kettleIgnore == null && !"lib".equals(folder)); } @Override public boolean includeFile(FileSelectInfo fileSelectInfo) throws Exception { return fileSelectInfo.getFile().toString().endsWith(".jar"); } }); return fileObjects; } catch (Exception e) { throw new KettleFileException("Unable to list jar files in plugin folder '" + toString() + "'", e); } }
From source file:org.pentaho.di.core.plugins.RepositoryPluginType.java
protected void registerXmlPlugins() throws KettlePluginException { for (PluginFolderInterface folder : pluginFolders) { if (folder.isPluginXmlFolder()) { List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder()); for (FileObject file : pluginXmlFiles) { try { Document document = XMLHandler.loadXMLFile(file); Node pluginNode = XMLHandler.getSubNode(document, "plugin"); registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL()); } catch (Exception e) { // We want to report this plugin.xml error, perhaps an XML typo or something like that... // log.logError("Error found while reading repository plugin.xml file: " + file.getName().toString(), e); }/* ww w . j av a2 s . c o m*/ } } } }
From source file:org.pentaho.di.core.plugins.StepPluginType.java
protected void registerXmlPlugins() throws KettlePluginException { for (PluginFolderInterface folder : pluginFolders) { if (folder.isPluginXmlFolder()) { List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder()); for (FileObject file : pluginXmlFiles) { try { Document document = XMLHandler.loadXMLFile(file); Node pluginNode = XMLHandler.getSubNode(document, "plugin"); if (pluginNode != null) { registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL()); }/*w ww.j a v a2 s . c o m*/ } catch (Exception e) { // We want to report this plugin.xml error, perhaps an XML typo or something like that... // log.logError("Error found while reading step plugin.xml file: " + file.getName().toString(), e); } } } } }
From source file:org.pentaho.di.core.row.value.ValueMetaPluginType.java
@Override protected void registerXmlPlugins() throws KettlePluginException { for (PluginFolderInterface folder : pluginFolders) { if (folder.isPluginXmlFolder()) { List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder()); for (FileObject file : pluginXmlFiles) { try { Document document = XMLHandler.loadXMLFile(file); Node pluginNode = XMLHandler.getSubNode(document, "plugin"); if (pluginNode != null) { registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL()); }/*from ww w . ja v a 2 s. c om*/ } catch (Exception e) { // We want to report this plugin.xml error, perhaps an XML typo or something like that... // log.logError("Error found while reading step plugin.xml file: " + file.getName().toString(), e); } } } } }
From source file:org.pentaho.di.core.vfs.KettleVFS.java
public static String getFilename(FileObject fileObject) { FileName fileName = fileObject.getName(); String root = fileName.getRootURI(); if (!root.startsWith("file:")) { return fileName.getURI(); // nothing we can do about non-normal files. }//from ww w . ja v a2s . c o m if (root.startsWith("file:////")) { return fileName.getURI(); // we'll see 4 forward slashes for a windows/smb network share } if (root.endsWith(":/")) { // Windows root = root.substring(8, 10); } else { // *nix & OSX root = ""; } String fileString = root + fileName.getPath(); if (!"/".equals(Const.FILE_SEPARATOR)) { fileString = Const.replace(fileString, "/", Const.FILE_SEPARATOR); } return fileString; }