private JobMeta getJobMetaFromRepository( Repository rep, CurrentDirectoryResolver r, String transPath ) throws KettleException { String realJobName = ""; String realDirectory = "/"; int index = transPath.lastIndexOf( RepositoryFile.SEPARATOR ); if ( index != -1 ) { realJobName = transPath.substring( index + 1 ); realDirectory = index == 0 ? RepositoryFile.SEPARATOR : transPath.substring( 0, index ); } realDirectory = r.normalizeSlashes( realDirectory ); RepositoryDirectoryInterface repositoryDirectory = rep.loadRepositoryDirectoryTree().findDirectory( realDirectory ); if ( repositoryDirectory == null ) { throw new KettleException( "Unable to find repository directory [" + Const.NVL( realDirectory, "" ) + "]" ); } return rep.loadJob( realJobName, repositoryDirectory, null, null ); // reads }
private TransMeta getTransMetaFromRepository( Repository rep, CurrentDirectoryResolver r, String transPath ) throws KettleException { String realTransName = ""; String realDirectory = "/"; if ( StringUtils.isBlank( transPath ) ) { throw new KettleException( BaseMessages.getString( PKG, "JobTrans.Exception.MissingTransFileName" ) ); } int index = transPath.lastIndexOf( RepositoryFile.SEPARATOR ); if ( index != -1 ) { realTransName = transPath.substring( index + 1 ); realDirectory = index == 0 ? RepositoryFile.SEPARATOR : transPath.substring( 0, index ); } realDirectory = r.normalizeSlashes( realDirectory ); RepositoryDirectoryInterface repositoryDirectory = rep.loadRepositoryDirectoryTree().findDirectory( realDirectory ); if ( repositoryDirectory == null ) { throw new KettleException( "Unable to find repository directory [" + Const.NVL( realDirectory, "" ) + "]" ); } return rep.loadTransformation( realTransName, repositoryDirectory, null, true, null ); }
@Before public void setUp() throws Exception { doReturn( true ).when( repository ).isConnected(); doReturn( null ).when( repository ).getJobEntryAttributeString( any( ObjectId.class ), anyString() ); doReturn( rdi ).when( repository ).loadRepositoryDirectoryTree(); doReturn( directory ).when( rdi ).findDirectory( JOB_ENTRY_FILE_DIRECTORY ); doReturn( directory ).when( rdi ).findDirectory( "/home/admin/folder" ); doReturn( null ).when( space ).environmentSubstitute( anyString() ); doReturn( "" ).when( space ).environmentSubstitute( "" ); doReturn( JOB_ENTRY_FILE_PATH ).when( space ).environmentSubstitute( JOB_ENTRY_FILE_PATH ); doReturn( JOB_ENTRY_FILE_NAME ).when( space ).environmentSubstitute( JOB_ENTRY_FILE_NAME ); doReturn( JOB_ENTRY_FILE_DIRECTORY ).when( space ).environmentSubstitute( JOB_ENTRY_FILE_DIRECTORY ); doReturn( "hdfs://server/path/" ).when( space ).environmentSubstitute( "${hdfs}" ); doReturn( "/home/admin/folder/job.kjb" ).when( space ).environmentSubstitute( "${repositoryfullfilepath}" ); doReturn( "/home/admin/folder/" ).when( space ).environmentSubstitute( "${repositorypath}" ); doReturn( "job.kjb" ).when( space ).environmentSubstitute( "${jobname}" ); doReturn( "job" ).when( space ).environmentSubstitute( "job" ); doCallRealMethod().when( resolver ).normalizeSlashes( anyString() ); doReturn( space ).when( resolver ).resolveCurrentDirectory( any( ObjectLocationSpecificationMethod.class ), any( VariableSpace.class ), any( Repository.class ), any( Job.class ), anyString() ); whenNew( CurrentDirectoryResolver.class ).withNoArguments().thenReturn( resolver ); whenNew( JobMeta.class ).withAnyArguments().thenReturn( mock( JobMeta.class ) ); }
realFilename = r.normalizeSlashes( realFilename ); realDirectory = r.normalizeSlashes( realDirectory ); RepositoryDirectoryInterface repdir = rep.findDirectory( realDirectory ); if ( repdir != null ) {
realFilename = r.normalizeSlashes( realFilename ); try { String dirStr = realFilename.substring( 0, realFilename.lastIndexOf( "/" ) ); realDirectory = r.normalizeSlashes( realDirectory ); RepositoryDirectoryInterface repdir = rep.findDirectory( realDirectory ); if ( repdir != null ) {
realFilename = resolver.normalizeSlashes( realFilename ); try { String dirStr = realFilename.substring( 0, realFilename.lastIndexOf( "/" ) );