@Service public class DefaultFileSystemService extends Object implements FileSystemService
| Modifier and Type | Field and Description |
|---|---|
static double |
REQUIRED_DISK_SPACE_SLACK_MULTIPLIER |
| Constructor and Description |
|---|
DefaultFileSystemService() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
areHashesBetweenFilesEqual(byte[] fileContentA,
byte[] fileContentB) |
boolean |
areHashesBetweenFilesEqual(Path fileA,
Path fileB) |
void |
checkEnoughUsableSpace(Path oldMule,
Path newMule,
List<Path> paths)
Validates whether there is potentially enough writable space on the file system for the upgrade.
|
void |
checkIsADirectory(Path path)
Checks whether a given path corresponds to a directory.
|
void |
checkReadingAccess(Path parentPath,
List<Path> relativePaths)
Checks whether the JVM has reading access to all file trees determined by the given relative paths when resolved against the
given parent path.
|
void |
checkWritingAccess(Path parentPath,
List<Path> relativePaths)
Checks whether the JVM has writing access to all file trees determined by the given relative paths when resolved against the
given parent path.
|
void |
copyFile(File source,
File dest,
boolean isDryRunMode)
Copy the file from the given source file to the destination file.
|
void |
copyFiles(Path srcDir,
Path destDir,
List<Path> includedPathsArg,
List<Path> excludedPathsArg,
boolean isDryRunMode)
Recursively copy all the files and directories determined by the given relative includedPaths from the given source directory
to the given destination directory.
|
void |
copyFilesInsideADistro(Path sourceMuleDistroPath,
Path destMuleDistroPath,
List<String> fileNamesList,
boolean isDryRunMode)
Copies a list of files from a Mule Runtime Distribution to another.
|
void |
deleteFilesInsideADistro(Path distroPath,
List<String> fileNamesList,
boolean isDryRunMode)
Deletes a list of files from a Mule Runtime Distribution.
|
void |
deleteUpgradeFolderIfEmpty(Path muleHome,
boolean dryRun)
Deletes the upgrade-tool folder inside a distro if the folder is empty to try to clean the environment after an upgrade or a
backup
|
String |
getSha256(byte[] content) |
String |
getSha256(InputStream stream) |
String |
getSha256(Path filePath) |
boolean |
isWindowsOs()
Checks whether the underlying OS is Windows.
|
public static final double REQUIRED_DISK_SPACE_SLACK_MULTIPLIER
public void checkIsADirectory(Path path) throws NotDirectoryException
checkIsADirectory in interface FileSystemServicepath - the path to an expected directory.NotDirectoryException - if given path is not a directory.public void checkWritingAccess(Path parentPath, List<Path> relativePaths) throws IOException
checkWritingAccess in interface FileSystemServiceparentPath - the parent path which is used for resolving the relative paths.relativePaths - list of all paths whose underlying tree will be validated for writing access.AccessDeniedException - if any path does not have writing accessibility.IOException - if any I/O error occurs.public void checkReadingAccess(Path parentPath, List<Path> relativePaths) throws IOException
checkReadingAccess in interface FileSystemServiceparentPath - the parent path which is used for resolving the relative paths.relativePaths - list of all paths whose underlying tree will be validated for reading access.AccessDeniedException - if any path does not have reading accessibility.IOException - if any I/O error occurs.public void checkEnoughUsableSpace(Path oldMule, Path newMule, List<Path> paths) throws IOException
checkEnoughUsableSpace in interface FileSystemServiceoldMule - the directory where the old Mule distro is located.newMule - the directory where the new Mule distro is located.paths - the relative paths of files involved in the upgrade process.{@link - IOException} In case of not finding enough usable space.IOExceptionpublic boolean isWindowsOs()
isWindowsOs in interface FileSystemServicepublic void copyFiles(Path srcDir, Path destDir, List<Path> includedPathsArg, List<Path> excludedPathsArg, boolean isDryRunMode) throws IOException
copyFiles in interface FileSystemServicesrcDir - the directory where the files will be copied from.destDir - the directory where the files will be copied to.includedPathsArg - the relative includedPaths that will be resolved against the source dir for copying them to the
destination directory. In case it is empty all the paths inside the srcDir are going to be copied.excludedPathsArg - the relative excluded includedPaths that will be resolved against the source dir for avoid copying
them to the destination directory. In case it is empty no paths from the srdDir will be excluded.isDryRunMode - if isDryRunMode is true, the method logs in debug level the files and directories that would be
copied without actually copying them.IOException - if any I/O error occurs.public void copyFile(File source, File dest, boolean isDryRunMode) throws IOException
FileSystemServicecopyFile in interface FileSystemServicesource - the source file.dest - the destination file where it will be copied to.isDryRunMode - if isDryRunMode is true, the method logs in trace level the files and directories that would be copied
without actually copying them.IOException - if any I/O error occurs.public void deleteFilesInsideADistro(Path distroPath, List<String> fileNamesList, boolean isDryRunMode) throws IOException
deleteFilesInsideADistro in interface FileSystemServicedistroPath - Current Mule Runtime Distribution.fileNamesList - List of files names.isDryRunMode - Dry Run Mode flag.IOException - if an I/O exception error occurs different that a file not found exception.public void copyFilesInsideADistro(Path sourceMuleDistroPath, Path destMuleDistroPath, List<String> fileNamesList, boolean isDryRunMode) throws IOException
copyFilesInsideADistro in interface FileSystemServicesourceMuleDistroPath - New Mule Runtime Distribution.destMuleDistroPath - Old Mule Runtime Distribution.fileNamesList - List of files names.isDryRunMode - Dry Run Mode flag.IOException - IOException.public void deleteUpgradeFolderIfEmpty(Path muleHome, boolean dryRun) throws IOException
deleteUpgradeFolderIfEmpty in interface FileSystemServicemuleHome - Mule Home path where it is going to try to delete the empty upgrade-tool folderdryRun - Dry Run flag, if is in true don't delete the folder and only do the loggingIOException - IOException.public boolean areHashesBetweenFilesEqual(Path fileA, Path fileB) throws IOException
areHashesBetweenFilesEqual in interface FileSystemServicefileA - First file to compare the sha256fileB - Second file to compare the sha256IOException - IOException.public boolean areHashesBetweenFilesEqual(byte[] fileContentA,
byte[] fileContentB)
throws IOException
areHashesBetweenFilesEqual in interface FileSystemServicefileContentA - First byte[] to compare the sha256fileContentB - Second byte[] to compare the sha256IOException - IOException.public String getSha256(Path filePath) throws IOException
IOExceptionpublic String getSha256(InputStream stream) throws IOException
IOExceptionpublic String getSha256(byte[] content)
Copyright © 2022 MuleSoft, Inc.. All rights reserved.