@Override public String[] getJobNames( ObjectId id_directory, boolean includeDeleted ) throws KettleException { try { List<String> list = new ArrayList<String>(); RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree(); RepositoryDirectoryInterface directory = tree.findDirectory( id_directory ); String folderName = calcDirectoryName( directory ); FileObject folder = KettleVFS.getFileObject( folderName ); for ( FileObject child : folder.getChildren() ) { if ( child.getType().equals( FileType.FILE ) ) { if ( !child.isHidden() || !repositoryMeta.isHidingHiddenFiles() ) { String name = child.getName().getBaseName(); if ( name.endsWith( EXT_JOB ) ) { String jobName = name.substring( 0, name.length() - 4 ); list.add( jobName ); } } } } return list.toArray( new String[list.size()] ); } catch ( Exception e ) { throw new KettleException( "Unable to get list of transformations names in folder with id : " + id_directory, e ); } }
@Override public String[] getTransformationNames( ObjectId id_directory, boolean includeDeleted ) throws KettleException { try { List<String> list = new ArrayList<String>(); RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree(); RepositoryDirectoryInterface directory = tree.findDirectory( id_directory ); String folderName = calcDirectoryName( directory ); FileObject folder = KettleVFS.getFileObject( folderName ); for ( FileObject child : folder.getChildren() ) { if ( child.getType().equals( FileType.FILE ) ) { if ( !child.isHidden() || !repositoryMeta.isHidingHiddenFiles() ) { String name = child.getName().getBaseName(); if ( name.endsWith( EXT_TRANSFORMATION ) ) { String transName = name.substring( 0, name.length() - 4 ); list.add( transName ); } } } } return list.toArray( new String[list.size()] ); } catch ( Exception e ) { throw new KettleException( "Unable to get list of transformations names in folder with id : " + id_directory, e ); } }
private ObjectId[] getRootObjectIDs( String extension ) throws KettleException { try { // Get all the files in the root directory with a certain extension... // List<ObjectId> list = new ArrayList<ObjectId>(); String folderName = repositoryMeta.getBaseDirectory(); FileObject folder = KettleVFS.getFileObject( folderName ); for ( FileObject child : folder.getChildren() ) { if ( child.getType().equals( FileType.FILE ) ) { if ( !child.isHidden() || !repositoryMeta.isHidingHiddenFiles() ) { String name = child.getName().getBaseName(); if ( name.endsWith( extension ) ) { list.add( new StringObjectId( name ) ); } } } } return list.toArray( new ObjectId[list.size()] ); } catch ( Exception e ) { throw new KettleException( "Unable to get root object ids for extension [" + extension + "]", e ); } }
@Override public List<RepositoryElementMetaInterface> getTransformationObjects( ObjectId idDirectory, boolean includeDeleted ) throws KettleException { try { List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>(); RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree(); RepositoryDirectoryInterface directory = tree.findDirectory( idDirectory ); String folderName = calcDirectoryName( directory ); FileObject folder = KettleVFS.getFileObject( folderName ); for ( FileObject child : folder.getChildren() ) { if ( child.getType().equals( FileType.FILE ) ) { if ( !child.isHidden() || !repositoryMeta.isHidingHiddenFiles() ) { String name = child.getName().getBaseName(); if ( name.endsWith( EXT_TRANSFORMATION ) ) { String transName = name.substring( 0, name.length() - 4 ); ObjectId id = new StringObjectId( calcObjectId( directory, transName, EXT_TRANSFORMATION ) ); Date date = new Date( child.getContent().getLastModifiedTime() ); list.add( new RepositoryObject( id, transName, directory, "-", date, RepositoryObjectType.TRANSFORMATION, "", false ) ); } } } } return list; } catch ( Exception e ) { throw new KettleException( "Unable to get list of transformations in folder with id : " + idDirectory, e ); } }
@Override public List<RepositoryElementMetaInterface> getJobObjects( ObjectId id_directory, boolean includeDeleted ) throws KettleException { try { List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>(); RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree(); RepositoryDirectoryInterface directory = tree.findDirectory( id_directory ); String folderName = calcDirectoryName( directory ); FileObject folder = KettleVFS.getFileObject( folderName ); for ( FileObject child : folder.getChildren() ) { if ( child.getType().equals( FileType.FILE ) ) { if ( !child.isHidden() || !repositoryMeta.isHidingHiddenFiles() ) { String name = child.getName().getBaseName(); if ( name.endsWith( EXT_JOB ) ) { String jobName = name.substring( 0, name.length() - 4 ); ObjectId id = new StringObjectId( calcObjectId( directory, jobName, EXT_JOB ) ); Date date = new Date( child.getContent().getLastModifiedTime() ); list.add( new RepositoryObject( id, jobName, directory, "-", date, RepositoryObjectType.JOB, "", false ) ); } } } } return list; } catch ( Exception e ) { throw new KettleException( "Unable to get list of jobs in folder with id : " + id_directory, e ); } }
/** * Lists all content entities stored in this content-location. This method filters out all files that have an invalid * name (according to the repository rules). * * @return the content entities for this location. * @throws ContentIOException if an repository error occured. */ public ContentEntity[] listContents() throws ContentIOException { try { final FileObject file = getBackend(); final FileObject[] files = file.getChildren(); final ContentEntity[] entities = new ContentEntity[files.length]; for ( int i = 0; i < files.length; i++ ) { final FileObject child = files[i]; if ( RepositoryUtilities.isInvalidPathName( child.getPublicURIString() ) ) { continue; } if ( child.isFolder() ) { entities[i] = new FileObjectContentLocation( this, child ); } else if ( child.isFile() ) { entities[i] = new FileObjectContentLocation( this, child ); } } return entities; } catch ( FileSystemException e ) { throw new RuntimeException( e ); } }
FileObject[] children = fileObject.getChildren();
public RepositoryDirectoryInterface loadRepositoryDirectoryTree( RepositoryDirectoryInterface dir ) throws KettleException { try { String folderName = calcDirectoryName( dir ); FileObject folder = KettleVFS.getFileObject( folderName ); for ( FileObject child : folder.getChildren() ) { if ( child.getType().equals( FileType.FOLDER ) ) { if ( !child.isHidden() || !repositoryMeta.isHidingHiddenFiles() ) { if ( !".meta".equals( child.getName().getBaseName() ) ) { RepositoryDirectory subDir = new RepositoryDirectory( dir, child.getName().getBaseName() ); subDir.setObjectId( new StringObjectId( calcObjectId( subDir ) ) ); dir.addSubdirectory( subDir ); loadRepositoryDirectoryTree( subDir ); } } } } return dir; } catch ( Exception e ) { throw new KettleException( "Unable to load the directory tree from this file repository", e ); } }
fileList = sourceFileOrFolder.findFiles( new ZipJobEntryPatternFileSelector( pattern, patternExclude ) ); } else { fileList = sourceFileOrFolder.getChildren();
FileObject[] children = localFiles.getChildren(); if ( children != null ) { for ( int i = 0; i < children.length; i++ ) {
FileObject[] children = directoryFileObject.getChildren(); for ( int j = 0; j < children.length; j++ ) {
extraData[outputIndex++] = new Long( data.file.getChildren().length );
FileObject[] children = fo.getParent().getChildren(); for (FileObject child : children) { if (child.getType() == FileType.FILE && child.getName().getBaseName().matches(pattern)) {
FileObject[] children = fo.getParent().getChildren(); for (FileObject child : children) { if (child.getType() == FileType.FILE
@Override public FileObject[] getChildren() throws FileSystemException { return decoratedFileObject.getChildren(); }
public static FileObject getLatest(final FileObject parent) throws FileSystemException { try { final FileObject[] children = parent.getChildren(); if (children == null || children.length == 0) return null; return Arrays.stream(children).reduce(null, findLatest, findLatest); } catch (final FileNotFoundException | FileNotFolderException afnfe) { if (parent.exists()) throw afnfe; return null; } }
protected List<FileObject> listFiles(final FileObject file) { try { FileObject[] files = file.getType().hasChildren() ? file.getChildren() : null; return files != null ? Arrays.asList(files) : new ArrayList<FileObject>(); } catch (FileSystemException e) { throw new RuntimeException(e); } } }
@Test public void testLargeFile() throws Exception { final File realFile = new File(largeFilePath + largeFileName + ".tar.gz"); final FileObject file = manager.resolveFile("tgz:file://" + realFile.getCanonicalPath() + "!/"); assertNotNull(file); final List<FileObject> files = Arrays.asList(file.getChildren()); assertNotNull(files); assertEquals(1, files.size()); final FileObject f = files.get(0); assertTrue("Expected file not found: " + largeFileName + ".txt", f.getName().getBaseName().equals(largeFileName + ".txt")); }
protected void fileCheck(final String[] expectedFiles, final String tarFile) throws Exception { assertNotNull(manager); final FileObject file = manager.resolveFile(tarFile); assertNotNull(file); final List<FileObject> files = Arrays.asList(file.getChildren()); assertNotNull(files); for (final String expectedFile : expectedFiles) { assertTrue("Expected file not found: " + expectedFile, fileExists(expectedFile, files)); } }
/** * Tests the contents of root of file system can be listed. */ public void testRoot() throws FileSystemException { if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } final FileSystem fs = getFileSystem(); final String uri = fs.getRootURI(); final FileObject file = getManager().resolveFile(uri, fs.getFileSystemOptions()); file.getChildren(); }