Class FileSystemUtils
java.lang.Object
org.eclipse.dirigible.commons.api.helpers.FileSystemUtils
public class FileSystemUtils extends Object
The File System Utils.
-
Field Summary
Fields Modifier and Type Field Description static StringDOT_GITThe Constant DOT_GIT.static StringPROJECT_METADATA_FILE_NAMEThe Constant PROJECT_METADATA_FILE_NAME. -
Constructor Summary
Constructors Constructor Description FileSystemUtils() -
Method Summary
Modifier and Type Method Description static voidcopyFile(String srcPath, String destPath)Copy file.static voidcopyFolder(String srcPath, String destPath)Copy folder.static booleancreateFile(String workspacePath)Creates the file.static booleancreateFolder(String workspacePath)Creates the folder.static voidcreateFoldersIfNecessary(String workspacePath)Creates the folders if necessary.static voiddeleteDirectory(String firstSegment, String... segments)Delete directory.static booleandirectoryExists(String location)Directory exists.static booleanexists(String location)Exists.static booleanfileExists(String location)File exists.static List<String>find(String root, String pattern)Find.static FileforceCreateDirectory(String firstSegment, String... segments)Force create directory and all its parents.static StringgenerateGitRepositoryName(String repositoryURI)Generate the local repository name.static FilegetDirectory(String firstSegment, String... segments)Returns the directory by segments.static StringgetExtension(String workspacePath)Gets the extension.static FilegetGitDeepDirectoryByRepositoryName(String user, String workspace, String repositoryName)Get the directory for git for deep projects.static FilegetGitDirectory(String user, String workspace)Get the directory for git.static FilegetGitDirectory(String user, String workspace, String repositoryURI)Get the directory for git.static FilegetGitDirectoryByRepositoryName(String user, String workspace, String repositoryName)Get the directory for git.static List<String>getGitRepositories(String user, String workspace)Gets the git repositories.static List<File>getGitRepositoryProjects(File gitRepository)Gets the git repository projects.static List<String>getGitRepositoryProjects(String user, String workspace, String repositoryName)Gets the git repository projects.static List<File>getGitRepositoryProjectsFiles(String user, String workspace, String repositoryName)Gets the git repository projects files.static DategetModifiedAt(String workspacePath)Gets the modified at.static StringgetOwner(String workspacePath)Gets the owner.static booleanisDirectory(String location)Checks if is directory.static File[]listFiles(File directory)List files including symbolic links.static byte[]loadFile(String workspacePath)Load file.static voidmoveFile(String workspacePathOld, String workspacePathNew)Move file.static voidremoveFile(String workspacePath)Removes the file.static voidsaveFile(String workspacePath, byte[] content)Save file.
-
Field Details
-
DOT_GIT
The Constant DOT_GIT.- See Also:
- Constant Field Values
-
PROJECT_METADATA_FILE_NAME
The Constant PROJECT_METADATA_FILE_NAME.- See Also:
- Constant Field Values
-
-
Constructor Details
-
FileSystemUtils
public FileSystemUtils()
-
-
Method Details
-
saveFile
public static void saveFile(String workspacePath, byte[] content) throws FileNotFoundException, IOExceptionSave file.- Parameters:
workspacePath- the workspace pathcontent- the content- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
loadFile
Load file.- Parameters:
workspacePath- the workspace path- Returns:
- the byte[]
- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
moveFile
public static void moveFile(String workspacePathOld, String workspacePathNew) throws FileNotFoundException, IOExceptionMove file.- Parameters:
workspacePathOld- the workspace path oldworkspacePathNew- the workspace path new- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
copyFile
public static void copyFile(String srcPath, String destPath) throws FileNotFoundException, IOExceptionCopy file.- Parameters:
srcPath- the src pathdestPath- the dest path- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
copyFolder
public static void copyFolder(String srcPath, String destPath) throws FileNotFoundException, IOExceptionCopy folder.- Parameters:
srcPath- the src pathdestPath- the dest path- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
removeFile
Removes the file.- Parameters:
workspacePath- the workspace path- Throws:
FileNotFoundException- the file not found exceptionIOException- Signals that an I/O exception has occurred.
-
createFolder
Creates the folder.- Parameters:
workspacePath- the workspace path- Returns:
- true, if successful
-
createFile
Creates the file.- Parameters:
workspacePath- the workspace path- Returns:
- true, if successful
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getExtension
Gets the extension.- Parameters:
workspacePath- the workspace path- Returns:
- the extension
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getOwner
Gets the owner.- Parameters:
workspacePath- the workspace path- Returns:
- the owner
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getModifiedAt
Gets the modified at.- Parameters:
workspacePath- the workspace path- Returns:
- the modified at
- Throws:
IOException- Signals that an I/O exception has occurred.
-
createFoldersIfNecessary
Creates the folders if necessary.- Parameters:
workspacePath- the workspace path
-
exists
Exists.- Parameters:
location- the location- Returns:
- true, if successful
-
directoryExists
Directory exists.- Parameters:
location- the location- Returns:
- true, if successful
-
fileExists
File exists.- Parameters:
location- the location- Returns:
- true, if successful
-
isDirectory
Checks if is directory.- Parameters:
location- the location- Returns:
- true, if is directory
-
listFiles
List files including symbolic links.- Parameters:
directory- the source directory- Returns:
- the list of files
- Throws:
IOException- IO error
-
forceCreateDirectory
public static File forceCreateDirectory(String firstSegment, String... segments) throws IOExceptionForce create directory and all its parents.- Parameters:
firstSegment- the first segmentsegments- the rest segments- Returns:
- the resulting path
- Throws:
IOException- IO error
-
deleteDirectory
Delete directory.- Parameters:
firstSegment- the first segmentsegments- the segments- Throws:
IOException- Signals that an I/O exception has occurred.
-
getDirectory
Returns the directory by segments.- Parameters:
firstSegment- the first segmentsegments- the rest segments- Returns:
- the resulting path
-
generateGitRepositoryName
Generate the local repository name.- Parameters:
repositoryURI- the URI odf the repository- Returns:
- the generated local name
-
getGitDirectory
Get the directory for git.- Parameters:
user- logged-in userworkspace- the workspace- Returns:
- the directory
-
getGitRepositories
Gets the git repositories.- Parameters:
user- the userworkspace- the workspace- Returns:
- the git repositories
-
getGitDirectory
Get the directory for git.- Parameters:
user- logged-in userworkspace- the workspacerepositoryURI- the repository URI- Returns:
- the directory
-
getGitDirectoryByRepositoryName
public static File getGitDirectoryByRepositoryName(String user, String workspace, String repositoryName)Get the directory for git.- Parameters:
user- logged-in userworkspace- the workspacerepositoryName- the repository URI- Returns:
- the directory
-
getGitDeepDirectoryByRepositoryName
public static File getGitDeepDirectoryByRepositoryName(String user, String workspace, String repositoryName)Get the directory for git for deep projects.- Parameters:
user- logged-in userworkspace- the workspacerepositoryName- the repository URI- Returns:
- the directory
-
getGitRepositoryProjects
public static List<String> getGitRepositoryProjects(String user, String workspace, String repositoryName)Gets the git repository projects.- Parameters:
user- the userworkspace- the workspacerepositoryName- the repository name- Returns:
- the git repository projects
-
getGitRepositoryProjectsFiles
public static List<File> getGitRepositoryProjectsFiles(String user, String workspace, String repositoryName)Gets the git repository projects files.- Parameters:
user- the userworkspace- the workspacerepositoryName- the repository name- Returns:
- the git repository projects files
-
getGitRepositoryProjects
Gets the git repository projects.- Parameters:
gitRepository- the git repository- Returns:
- the git repository projects
-
find
Find.- Parameters:
root- the rootpattern- the pattern- Returns:
- the list
- Throws:
IOException- Signals that an I/O exception has occurred.
-