List of usage examples for org.apache.commons.vfs FileName getParent
public FileName getParent();
From source file:com.github.stephenc.javaisotools.vfs.provider.iso.IsoFileSystem.java
public void init() throws FileSystemException { super.init(); final File file = getParentLayer().getFileSystem().replicateFile(getParentLayer(), Selectors.SELECT_SELF); try {/*from ww w . j a va 2s . c o m*/ this.fileSystem = new Iso9660FileSystem(file, true); } catch (IOException ex) { throw new FileSystemException("vfs.provider.iso/open-iso-file.error", file, ex); } // Build the index final List strongRef = new ArrayList(100); boolean skipRoot = false; for (Iso9660FileEntry entry : this.fileSystem) { String name = entry.getPath(); // skip entries without names (should only be one - the root entry) if ("".equals(name)) { if (!skipRoot) { skipRoot = true; } else { continue; } } final FileName filename = getFileSystemManager().resolveName(getRootName(), UriParser.encode(name)); // Create the file IsoFileObject fileObj; if (entry.isDirectory() && getFileFromCache(filename) != null) { fileObj = (IsoFileObject) getFileFromCache(filename); fileObj.setIsoEntry(entry); continue; } fileObj = new IsoFileObject(filename, entry, this); putFileToCache(fileObj); strongRef.add(fileObj); fileObj.holdObject(strongRef); // Make sure all ancestors exist IsoFileObject parent; for (FileName parentName = filename .getParent(); parentName != null; fileObj = parent, parentName = parentName.getParent()) { // Locate the parent parent = (IsoFileObject) getFileFromCache(parentName); if (parent == null) { parent = new IsoFileObject(parentName, this); putFileToCache(parent); strongRef.add(parent); parent.holdObject(strongRef); } // Attach child to parent parent.attachChild(fileObj.getName()); } } }
From source file:net.didion.loopy.vfs.provider.iso.IsoFileSystem.java
public void init() throws FileSystemException { super.init(); final File file = getParentLayer().getFileSystem().replicateFile(getParentLayer(), Selectors.SELECT_SELF); try {/*from w w w .j a v a 2 s . c om*/ this.fileSystem = new ISO9660FileSystem(file, true); } catch (IOException ex) { throw new FileSystemException("vfs.provider.iso/open-iso-file.error", file, ex); } // Build the index final List strongRef = new ArrayList(100); final Enumeration entries = this.fileSystem.getEntries(); while (entries.hasMoreElements()) { final ISO9660FileEntry entry = (ISO9660FileEntry) entries.nextElement(); String name = entry.getPath(); // skip entries without names (should only be one - the root entry) if ("".equals(name)) { continue; } final FileName filename = getFileSystemManager().resolveName(getRootName(), UriParser.encode(name)); // Create the file IsoFileObject fileObj; if (entry.isDirectory() && getFileFromCache(filename) != null) { fileObj = (IsoFileObject) getFileFromCache(filename); fileObj.setIsoEntry(entry); continue; } fileObj = new IsoFileObject(filename, entry, this); putFileToCache(fileObj); strongRef.add(fileObj); fileObj.holdObject(strongRef); // Make sure all ancestors exist IsoFileObject parent; for (FileName parentName = filename .getParent(); parentName != null; fileObj = parent, parentName = parentName.getParent()) { // Locate the parent parent = (IsoFileObject) getFileFromCache(parentName); if (parent == null) { parent = new IsoFileObject(parentName, this); putFileToCache(parent); strongRef.add(parent); parent.holdObject(strongRef); } // Attach child to parent parent.attachChild(fileObj.getName()); } } }
From source file:com.panet.imeta.job.Job.java
public void setInternalKettleVariables(VariableSpace var) { if (jobMeta != null && jobMeta.getFilename() != null) // we have a // finename//from w w w . j a v a 2 s . c o m // that's // defined. { try { FileObject fileObject = KettleVFS.getFileObject(jobMeta.getFilename()); FileName fileName = fileObject.getName(); // The filename of the transformation var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName()); // The directory of the transformation FileName fileDir = fileName.getParent(); var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI()); } catch (IOException e) { var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); } } else { var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); //$NON-NLS-1$ var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); //$NON-NLS-1$ } // The name of the job var.setVariable(Const.INTERNAL_VARIABLE_JOB_NAME, Const.NVL(jobMeta.getName(), "")); //$NON-NLS-1$ // The name of the directory in the repository var.setVariable(Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, jobMeta.getDirectory() != null ? jobMeta.getDirectory().getPath() : ""); //$NON-NLS-1$ // Undefine the transformation specific variables var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, null); }
From source file:be.ibridge.kettle.job.JobMeta.java
/** * This method sets various internal kettle variables that can be used by the transformation. *///from w w w.j av a 2 s .c o m public void setInternalKettleVariables() { KettleVariables variables = KettleVariables.getInstance(); if (filename != null) // we have a finename that's defined. { try { FileSystemManager fsManager = VFS.getManager(); FileObject fileObject = fsManager.resolveFile(filename); FileName fileName = fileObject.getName(); // The filename of the transformation variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName()); // The directory of the transformation FileName fileDir = fileName.getParent(); variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI()); } catch (IOException e) { variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); } } else { variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); //$NON-NLS-1$ variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); //$NON-NLS-1$ } // The name of the job variables.setVariable(Const.INTERNAL_VARIABLE_JOB_NAME, Const.NVL(name, "")); //$NON-NLS-1$ // The name of the directory in the repository variables.setVariable(Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, directory != null ? directory.getPath() : ""); //$NON-NLS-1$ }
From source file:com.panet.imeta.job.JobMeta.java
/** * This method sets various internal kettle variables that can be used by * the transformation.//from w ww . ja va 2 s .co m */ public void setInternalKettleVariables(VariableSpace var) { if (filename != null) // we have a filename that's defined. { try { FileObject fileObject = KettleVFS.getFileObject(filename); FileName fileName = fileObject.getName(); // The filename of the transformation var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName()); // The directory of the transformation FileName fileDir = fileName.getParent(); var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI()); } catch (IOException e) { var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); } } else { var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); //$NON-NLS-1$ var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); //$NON-NLS-1$ } // The name of the job var.setVariable(Const.INTERNAL_VARIABLE_JOB_NAME, Const.NVL(name, "")); //$NON-NLS-1$ // The name of the directory in the repository var.setVariable(Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, directory != null ? directory.getPath() : ""); //$NON-NLS-1$ // Undefine the transformation specific variables: // transformations can't run jobs, so if you use these they are 99.99% // wrong. var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, null); }
From source file:be.ibridge.kettle.trans.TransMeta.java
/** * This method sets various internal kettle variables that can be used by the transformation. *//*from w ww.j a va2 s . c om*/ public void setInternalKettleVariables() { KettleVariables variables = KettleVariables.getInstance(); if (filename != null) // we have a finename that's defined. { try { FileSystemManager fsManager = VFS.getManager(); FileObject fileObject = fsManager.resolveFile(filename); FileName fileName = fileObject.getName(); // The filename of the transformation variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, fileName.getBaseName()); // The directory of the transformation FileName fileDir = fileName.getParent(); variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, fileDir.getURI()); } catch (IOException e) { variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, ""); variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, ""); } } else { variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, ""); variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, ""); } // The name of the transformation variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, Const.NVL(name, "")); // The name of the directory in the repository variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, directory != null ? directory.getPath() : ""); }
From source file:com.panet.imeta.trans.TransMeta.java
public void setInternalKettleVariables(VariableSpace var) { if (!Const.isEmpty(filename)) // we have a finename that's defined. {//from w w w .j av a2 s. c om try { FileObject fileObject = KettleVFS.getFileObject(filename); FileName fileName = fileObject.getName(); // The filename of the transformation var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, fileName.getBaseName()); // The directory of the transformation FileName fileDir = fileName.getParent(); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, fileDir.getURI()); } catch (IOException e) { var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, ""); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, ""); } } else { var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, ""); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, ""); } // The name of the transformation // var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, Const.NVL(name, "")); // The name of the directory in the repository // var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, directory != null ? directory.getPath() : ""); // Here we don't remove the job specific parameters, as they may come in // handy. // if (var.getVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY) == null) { var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "Parent Job File Directory"); //$NON-NLS-1$ } if (var.getVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME) == null) { var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, "Parent Job Filename"); //$NON-NLS-1$ } if (var.getVariable(Const.INTERNAL_VARIABLE_JOB_NAME) == null) { var.setVariable(Const.INTERNAL_VARIABLE_JOB_NAME, "Parent Job Name"); //$NON-NLS-1$ } if (var.getVariable(Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY) == null) { var.setVariable(Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, "Parent Job Repository Directory"); //$NON-NLS-1$ } }
From source file:org.pentaho.di.job.Job.java
/** * Sets the internal kettle variables./*from w ww. j a v a 2 s. c o m*/ * * @param var * the new internal kettle variables. */ public void setInternalKettleVariables(VariableSpace var) { if (jobMeta != null && jobMeta.getFilename() != null) // we have a finename that's defined. { try { FileObject fileObject = KettleVFS.getFileObject(jobMeta.getFilename(), this); FileName fileName = fileObject.getName(); // The filename of the transformation var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName()); // The directory of the transformation FileName fileDir = fileName.getParent(); var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI()); } catch (Exception e) { var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); } } else { var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); } // The name of the job var.setVariable(Const.INTERNAL_VARIABLE_JOB_NAME, Const.NVL(jobMeta.getName(), "")); // The name of the directory in the repository var.setVariable(Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, jobMeta.getRepositoryDirectory() != null ? jobMeta.getRepositoryDirectory().getPath() : ""); // Undefine the transformation specific variables var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, null); var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, null); }
From source file:org.pentaho.di.job.JobMeta.java
/** * Sets the internal filename kettle variables. * * @param var/*from w w w. ja v a2 s.c o m*/ * the new internal filename kettle variables */ @Override protected void setInternalFilenameKettleVariables(VariableSpace var) { if (filename != null) { // we have a filename that's defined. try { FileObject fileObject = KettleVFS.getFileObject(filename, var); FileName fileName = fileObject.getName(); // The filename of the job var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName()); // The directory of the job FileName fileDir = fileName.getParent(); var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI()); } catch (Exception e) { var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); } } else { var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); } }
From source file:org.pentaho.di.trans.Trans.java
/** * Sets the internal kettle variables.// w ww . j a v a 2 s . c o m * * @param var * the new internal kettle variables */ public void setInternalKettleVariables(VariableSpace var) { if (transMeta != null && !Const.isEmpty(transMeta.getFilename())) // we have a finename that's defined. { try { FileObject fileObject = KettleVFS.getFileObject(transMeta.getFilename(), var); FileName fileName = fileObject.getName(); // The filename of the transformation variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, fileName.getBaseName()); // The directory of the transformation FileName fileDir = fileName.getParent(); variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, fileDir.getURI()); } catch (KettleFileException e) { variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, ""); variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, ""); } } else { variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, ""); variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, ""); } // The name of the transformation variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, Const.NVL(transMeta.getName(), "")); // TODO PUT THIS INSIDE OF THE "IF" // The name of the directory in the repository variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, transMeta.getRepositoryDirectory() != null ? transMeta.getRepositoryDirectory().getPath() : ""); // Here we don't clear the definition of the job specific parameters, as they may come in handy. // A transformation can be called from a job and may inherit the job internal variables // but the other around is not possible. }