/** * Constructor used for unit testing and mocking * * @param atsAgent the address of the remote ATS agent where the entity is located on * @param absolutePath the absolute path and name of the entity, e.g. /root/file.ext * @param osType the operating system of the machine */ FilePackage( String atsAgent, String absolutePath, OperatingSystemType osType, FileSystemOperations fileSystemOperations, SystemOperations systemOperations ) { this.atsAgent = atsAgent; this.path = IoUtils.getFilePath(absolutePath); this.name = IoUtils.getFileName(absolutePath); this.osType = osType; this.fileSystemOperations = fileSystemOperations; this.systemOperations = systemOperations; }
private void checkIfArchiveFormatIsSupported( String archiveFilePath ) { if (archiveFilePath.endsWith(".zip")) { return; } else if (archiveFilePath.endsWith(".gz") && !archiveFilePath.endsWith(".tar.gz")) { return; } else if (archiveFilePath.endsWith("tar.gz")) { return; } else if (archiveFilePath.endsWith(".tar")) { return; } else { String[] filenameTokens = IoUtils.getFileName(archiveFilePath).split("\\."); if (filenameTokens.length <= 1) { throw new FileSystemOperationException("Archive format was not provided."); } else { throw new FileSystemOperationException("Archive with format '" + filenameTokens[filenameTokens.length - 1] + "' is not supported. Available once are 'zip', 'gz', 'tar' and 'tar.gz' ."); } } }
/** * Extract archive file to local or remote machine. * Supported file formats are Zip, GZip, TAR and TAR GZip * If the machine is UNIX-like it will preserve the permissions * * @param archiveFilePath the archive file path * @param outputDirPath output directory. The directory will be created if it does not exist * @throws FileSystemOperationException */ @Override public void extract( String archiveFilePath, String outputDirPath ) throws FileSystemOperationException { if (archiveFilePath.endsWith(".zip")) { extractZip(archiveFilePath, outputDirPath); } else if (archiveFilePath.endsWith(".gz") && !archiveFilePath.endsWith(".tar.gz")) { extractGZip(archiveFilePath, outputDirPath); } else if (archiveFilePath.endsWith("tar.gz")) { extractTarGZip(archiveFilePath, outputDirPath); } else if (archiveFilePath.endsWith(".tar")) { extractTar(archiveFilePath, outputDirPath); } else { String[] filenameTokens = IoUtils.getFileName(archiveFilePath).split("\\."); if (filenameTokens.length <= 1) { throw new FileSystemOperationException("Archive format was not provided."); } else { throw new FileSystemOperationException("Archive with format '" + filenameTokens[filenameTokens.length - 1] + "' is not supported. Available once are 'zip', 'gz', 'tar' and 'tar.gz' ."); } } }
boolean fileRestored = new FileEnvironmentUnit(originalFilePath, IoUtils.getFilePath(backupFilePath), IoUtils.getFileName(backupFilePath)).restore(); updateRestoredFlag(fileRestored);
FileSnapshot fileSnapshot = FileSnapshot.fromFile(fileNode); dirSnapshot.fileSnapshots.put(IoUtils.getFileName(fileSnapshot.getPath()), fileSnapshot);
String fileName = IoUtils.getFileName(sourceFile); if (hidden) { if (fileName.startsWith(".")) {
/** * Constructor * * @param atsAgent the address of the remote ATS agent where the entity is located on * @param absolutePath the absolute path and name of the entity, e.g. /root/file.ext * @param osType the operating system of the machine */ public FilePackage( String atsAgent, String absolutePath, OperatingSystemType osType ) { this.atsAgent = atsAgent; this.path = IoUtils.getFilePath(absolutePath); this.name = IoUtils.getFileName(absolutePath); if (this.atsAgent == null) { this.fileSystemOperations = new FileSystemOperations(); this.systemOperations = new SystemOperations(); } else { this.fileSystemOperations = new FileSystemOperations(this.atsAgent); this.systemOperations = new SystemOperations(this.atsAgent); } if (osType == null) { this.osType = this.systemOperations.getOperatingSystemType(); } else { this.osType = osType; } }
if( !sftpClient.isRemoteFileOrDirectoryExisting( pathInfo.getSftpPath() ) ) { String fileName = IoUtils.getFileName( pathInfo.getSftpPath() ); String filePath = projectConfiguration.getSourceProject().findFile( fileName ); if( filePath == null ) {
String fileName = IoUtils.getFileName(pathInfo.getSftpPath()); String filePath = sourceProjectInfo.findFile(fileName); if (filePath == null) {
String fileName = IoUtils.getFileName( pathInfo.getSftpPath() ); String filePath = projectConfiguration.getSourceProject().findFile( fileName ); if( filePath == null ) {
String fileName = IoUtils.getFileName( pathInfo.getSftpPath() ); String filePath = projectConfiguration.getSourceProject().findFile( fileName ); if( filePath == null ) {