Refine search
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 ); } }
/** * Prepare file-dependent data for fill additional fields. */ protected void fillFileAdditionalFields( D data, FileObject file ) throws FileSystemException { data.shortFilename = file.getName().getBaseName(); data.path = KettleVFS.getFilename( file.getParent() ); data.hidden = file.isHidden(); data.extension = file.getName().getExtension(); data.uriName = file.getName().getURI(); data.rootUriName = file.getName().getRootURI(); if ( file.getType().hasContent() ) { data.lastModificationDateTime = new Date( file.getContent().getLastModifiedTime() ); data.size = file.getContent().getSize(); } else { data.lastModificationDateTime = null; data.size = null; } } }
extraData[outputIndex++] = data.file.getName().getBaseName(); extraData[outputIndex++] = KettleVFS.getFilename( data.file.getParent() ); extraData[outputIndex++] = data.file.getType().toString(); if ( data.file.getType().equals( FileType.FILE ) ) { size = new Long( data.file.getContent().getSize() ); extraData[outputIndex++] = data.file.getName().getExtension(); extraData[outputIndex++] = data.file.getName().getURI();
msg.append(file.getName().getBaseName()); if (file.exists()) { msg.append(" ("); msg.append(file.getType().getName()); msg.append(")"); } else { if (file.exists()) { final String newPrefix = prefix + INDENT; if (file.getType().hasContent()) { final FileContent content = file.getContent(); log(newPrefix + "Content-Length: " + content.getSize()); if (file.getType().hasChildren()) { final FileObject[] children = file.getChildren(); for (final FileObject child : children) { showFile(child, newPrefix); } else { log(newPrefix + child.getName().getBaseName());
if ( sourcefilefolder.exists() ) { if ( sourcefilefolder.getType().equals( FileType.FOLDER ) && destination_is_a_file ) { if ( destinationfilefolder.getType().equals( FileType.FOLDER ) && sourcefilefolder.getType().equals( FileType.FILE ) ) { String shortfilename = sourcefilefolder.getName().getBaseName(); shortfilename = getDestinationFilename( sourcefilefolder.getName().getBaseName() ); } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "JobPGPDecryptFiles.Error.GettingFilename", sourcefilefolder.getName().getBaseName(), e .toString() ) ); return entrystatus; result ); } else if ( sourcefilefolder.getType().equals( FileType.FILE ) && destination_is_a_file ) {
String shortSourceFilename = sourceFileObject.getName().getBaseName(); int lenstring = shortSourceFilename.length(); int lastindexOfDot = shortSourceFilename.lastIndexOf( '.' ); if ( !rootfolder.exists() ) { try { rootfolder.createFolder(); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobUnZip.Log.RootFolderCreated", foldername ) ); String zipFilename = "zip:" + sourceFileObject.getName().getFriendlyURI(); FileObject zipFile = KettleVFS.getFileObject( zipFilename, this ); FileObject[] items = zipFile.findFiles( new AllFileSelector() { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobUnZip.Log.ProcessingZipEntry", item.getName().getURI(), sourceFileObject.toString() ) ); newFileObject = KettleVFS.getFileObject( newFileName, this ); if ( item.getType().equals( FileType.FOLDER ) ) {
destinationfilefolder = KettleVFS.getFileObject( realDestinationFilefoldername, this ); if ( sourcefilefolder.exists() ) { if ( sourcefilefolder.getType().equals( FileType.FOLDER ) && destination_is_a_file ) { if ( destinationfilefolder.getType().equals( FileType.FOLDER ) && sourcefilefolder.getType().equals( FileType.FILE ) ) { destinationfilefolder.copyFrom( sourcefilefolder.getParent(), new TextOneFileSelector( sourcefilefolder.getParent().toString(), sourcefilefolder.getName().getBaseName(), destinationfilefolder.toString() ) ); if ( isDetailed() ) { } else if ( sourcefilefolder.getType().equals( FileType.FILE ) && destination_is_a_file ) { .getMessage() ) ); Throwable throwable = fse.getCause(); while ( throwable != null ) { logError( BaseMessages.getString( PKG, "JobCopyFiles.Log.CausedBy", throwable.getMessage() ) );
originFile = KettleVFS.getFileObject( realSourceDirectoryOrFile, this ); localSourceFilename = KettleVFS.getFilename( originFile ); orginExist = originFile.exists(); } catch ( Exception e ) { localrealZipfilename = KettleVFS.getFilename( fileObject ); if ( fileObject.exists() ) { Fileexists = true; if ( log.isDebug() ) { boolean isSourceDirectory = sourceFileOrFolder.getType().equals( FileType.FOLDER ); final Pattern pattern; final Pattern patternExclude; filename = fileList[i].getName().getPath(); } else { filename = fileList[i].getName().getBaseName(); if ( sourceFileOrFolder.getType().equals( FileType.FILE ) ) { targetFilename = localSourceFilename; boolean isTargetDirectory = file.exists() && file.getType().equals( FileType.FOLDER ); String fullName = fileList[i].getName().getPath(); String basePath = sourceFileOrFolder.getName().getPath(); if ( isSourceDirectory ) {
folder2 = KettleVFS.getFileObject( realFilename2, this ); if ( folder1.exists() && folder2.exists() ) { if ( !folder1.getType().equals( folder2.getType() ) ) { collection1.put( list1[i].getName().getBaseName(), list1[i].toString() ); collection2.put( list2[i].getName().getBaseName(), list2[i].toString() ); filefolder2 = KettleVFS.getFileObject( collection2.get( entree.getKey() ).toString(), this ); if ( !filefolder2.getType().equals( filefolder1.getType() ) ) {
if ( !Utils.isEmpty( file_previous ) ) { FileObject file = KettleVFS.getFileObject( file_previous, this ); if ( !file.exists() ) { logError( BaseMessages.getString( PKG, "JobSFTPPUT.Log.FilefromPreviousNotFound", file_previous ) ); } else { FileObject file = resultFile.getFile(); if ( file != null ) { if ( !file.exists() ) { logError( BaseMessages.getString( PKG, "JobSFTPPUT.Log.FilefromPreviousNotFound", file.toString() ) ); } else { folder = KettleVFS.getFileObject( realDestinationFolder, this ); if ( !folder.exists() ) { for ( int i = 0; i < children.length; i++ ) { if ( children[i].getType().equals( FileType.FILE ) ) { try { String localFilename = myFile.toString(); String destinationFilename = myFile.getName().getBaseName(); boolean getIt = true;
JsTreeNodeData node = new JsTreeNodeData(); String baseName = file.getName().getBaseName(); FileContent content = file.getContent(); FileType type = file.getType(); node.setAttr(attr); attr.put("id", relativePath); attr.put("rel", type.getName()); attr.put("fileType", type.getName()); if (content != null){ long fileLastModifiedTime = file.getContent().getLastModifiedTime();
attr.put("id", "."); attr.put("rel", "root"); attr.put("fileType", FileType.FOLDER.toString()); rootNode.setChildren(nodes); rootNode.setState(JsTreeNodeData.STATE_OPEN); String path = requestData.getId(); try{ file = rootFile.resolveFile(path, NameScope.DESCENDENT); boolean wasDeleted = false; if (file.getType() == FileType.FILE){ wasDeleted = file.delete(); }else{ wasDeleted = file.delete(ALL_FILES) > 0; file.createFolder(); result.setStatus(true); result.setId(rootFile.getName().getRelativeName(file.getName())); } catch (Exception e){ result.setStatus(false); referenceFile = rootFile.resolveFile(originalPath, NameScope.DESCENDENT); file = rootFile.resolveFile(newParentPath, NameScope.DESCENDENT_OR_SELF) .resolveFile(referenceFile.getName().getBaseName(), NameScope.CHILD); if (requestData.isCopy()){ file.copyFrom(referenceFile, ALL_FILES);
public static boolean pointToItself(FileObject fileObject) throws FileSystemException { if (!fileObject.getURL().getProtocol().equalsIgnoreCase("file") && FileType.FILE.equals(fileObject.getType())) { LOGGER.debug("Checking if {} is pointing to itself", fileObject.getName().getFriendlyURI()); FileObject[] children = VFSUtils.getChildren(fileObject); LOGGER.debug("Children number of {} is {}", fileObject.getName().getFriendlyURI(), children.length); if (children.length == 1) { FileObject child = children[0]; if (child.getContent().getSize() != child.getContent().getSize()) { return false; } if (child.getName().getBaseName().equals(fileObject.getName().getBaseName())) { return true; } } } return false; }
public boolean includeFile( FileSelectInfo fileInfo ) throws Exception { boolean include; // Only include files in the sub-folders... // When we include sub-folders we match the whole filename, not just the base-name // if ( fileInfo.getFile().getType().equals( FileType.FILE ) ) { include = true; if ( pattern != null ) { String name = fileInfo.getFile().getName().getBaseName(); include = pattern.matcher( name ).matches(); } if ( include && patternExclude != null ) { String name = fileInfo.getFile().getName().getBaseName(); include = !patternExclude.matcher( name ).matches(); } } else { include = false; } return include; } }
private void resetChildrenList() { try { if (this.file.getType().hasChildren()) { this.children = new HashMap<>(); final FileObject[] childrenList = this.file.getChildren(); for (final FileObject element : childrenList) { this.children.put(element.getName(), new Object()); // null? } } } catch (final FileSystemException fse) { this.children = null; } }
public LoadingInfo(FileObject fileObject, boolean tailing, OpenMode openMode) throws IOException { this.fileObject = fileObject; this.tailing = tailing; friendlyUrl = fileObject.getName().getFriendlyURI(); fileObject.refresh(); InputStream inputStream = fileObject.getContent().getInputStream(); byte[] probe = loadProbe(inputStream, 10000); gzipped = checkIfIsGzipped(probe, probe.length); inputStreamBufferedStart = gzipped ? ungzip(probe) : probe; if (openMode == FROM_START || gzipped) { PushbackInputStream pushBackInputStream = new PushbackInputStream(inputStream, probe.length + 1); // +1 to support empty files pushBackInputStream.unread(probe); observableInputStreamImpl = new ObservableInputStreamImpl(pushBackInputStream); contentInputStream = gzipped ? new GZIPInputStream(observableInputStreamImpl) : observableInputStreamImpl; } else { RandomAccessContent randomAccessContent = fileObject.getContent().getRandomAccessContent(READ); randomAccessContent.seek(randomAccessContent.length()); observableInputStreamImpl = new ObservableInputStreamImpl(randomAccessContent.getInputStream()); contentInputStream = observableInputStreamImpl; } if (fileObject.getType().hasContent()) { lastFileSize = fileObject.getContent().getSize(); } }
FileObject[] children = remoteFile.getChildren(); if (children[i].getType().toString().equals("file") && new FilePattenMatcher(FILE_PATTERN).validate(children[i].getName().getBaseName() .toLowerCase())) { sb.append("<file>" + children[i].getName().getBaseName() + "</file>"); if (log.isDebugEnabled()) { log.info(children[i].getName().getBaseName()); } else if (children[i].getType().toString().equals("folder") && new FilePattenMatcher(DIR_PATTERN).validate(children[i].getName() .getBaseName()
/** * Populate a node. * @param root Relative root directory. * @param file The file object. * @return The node data structure which presents the file. * @throws FileSystemException */ protected JsTreeNodeData populateTreeNodeData(FileObject root, FileObject file) throws FileSystemException { boolean noChild = true; FileType type = file.getType(); if (type.equals(FileType.FOLDER) || type.equals(FileType.FILE_OR_FOLDER)){ noChild = file.getChildren().length == 0; } String relativePath = root.getName().getRelativeName(file.getName()); return populateTreeNodeData(file, noChild, relativePath); } /**