List of usage examples for org.apache.commons.vfs FileName getURI
public String getURI();
From source file:org.kalypso.simulation.grid.SimpleGridProcess.java
/** * @see org.kalypso.commons.process.IProcess#getSandboxDirectory() *///w w w . jav a 2s.co m @Override public String getSandboxDirectory() { final FileName name = m_workingDir.getName(); return name.getURI(); }
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. }/* w w w . ja v a 2 s . co 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; }
From source file:org.pentaho.di.job.Job.java
/** * Sets the internal kettle variables./* w w w .ja va 2 s . c om*/ * * @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/*w w w . j a 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.steps.accessinput.AccessInputMeta.java
public static String getFilename(FileObject fileObject) { FileName fileName = fileObject.getName(); String root = fileName.getRootURI(); if (!root.startsWith("file:")) { return fileName.getURI(); }//from w ww . j a v a2 s .c o m if (root.endsWith(":/")) { root = root.substring(8, 10); } else { root = root.substring(7, root.length() - 1); } String fileString = root + fileName.getPath(); if (!"/".equals(Const.FILE_SEPARATOR)) { fileString = Const.replace(fileString, "/", Const.FILE_SEPARATOR); } return fileString; }
From source file:org.pentaho.di.trans.Trans.java
/** * Sets the internal kettle variables./*from w w w. ja v a 2 s .co 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. }
From source file:org.pentaho.di.trans.TransMeta.java
/** * Sets the internal filename kettle variables. * * @param var/*from w ww . j a va 2s . c o m*/ * the new internal filename kettle variables */ protected void setInternalFilenameKettleVariables(VariableSpace var) { // If we have a filename that's defined, set variables. If not, clear them. // if (!Const.isEmpty(filename)) { try { FileObject fileObject = KettleVFS.getFileObject(filename, var); 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 (KettleFileException e) { log.logError("Unexpected error setting internal filename variables!", 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, ""); } }
From source file:org.pentaho.hdfs.vfs.test.MapRFileNameParserTest.java
@Test public void rootPathNoClusterName() throws FileSystemException { final String URI = "maprfs:///"; FileNameParser parser = new MapRFileNameParser(); FileName name = parser.parseUri(null, null, URI); assertEquals(URI, name.getURI()); assertEquals("maprfs", name.getScheme()); }
From source file:org.pentaho.hdfs.vfs.test.MapRFileNameParserTest.java
@Test public void withPath() throws FileSystemException { final String URI = "maprfs:///my/file/path"; FileNameParser parser = new MapRFileNameParser(); FileName name = parser.parseUri(null, null, URI); assertEquals(URI, name.getURI()); assertEquals("maprfs", name.getScheme()); assertEquals("/my/file/path", name.getPath()); }
From source file:org.pentaho.hdfs.vfs.test.MapRFileNameParserTest.java
@Test public void withPathAndClusterName() throws FileSystemException { final String URI = "maprfs://cluster2/my/file/path"; FileNameParser parser = new MapRFileNameParser(); FileName name = parser.parseUri(null, null, URI); assertEquals(URI, name.getURI()); assertEquals("maprfs", name.getScheme()); assertTrue(name.getURI().startsWith("maprfs://cluster2/")); assertEquals("/my/file/path", name.getPath()); }