Class SourceManager

java.lang.Object
com.smeup.kokos.sdk.util.SourceManager

public class SourceManager extends Object
Author:
mattia.bonardi
  • Field Details

  • Constructor Details

    • SourceManager

      public SourceManager()
  • Method Details

    • listFiles

      public static Path[] listFiles(Path path) throws IOException
      List all files in a folder
      Parameters:
      path -
      Returns:
      Throws:
      IOException
    • getFileAsStream

      public static InputStream getFileAsStream(Map<String,SourceLibrary> libs, Path filePath) throws Exception
      Find file and return the relative InputStream
      Parameters:
      libs -
      filePath -
      Returns:
      InputStream
      Throws:
      Exception - if file isn't found
    • findFilePath

      public static Path findFilePath(Map<String,SourceLibrary> libs, Path filePath)
      Find a specified file inside a list of libs. Return null if file not exists
      Parameters:
      libs -
      filePath -
      Returns:
      Path
    • findFilePathInResources

      public static Path findFilePathInResources(Path filePath)
      Find a specified file inside resources. Return null if file not exists
      Parameters:
      filePath -
      Returns:
      Path
    • copyAndPasteResource

      public static void copyAndPasteResource(String resourceFileName, Path targetPath) throws IOException, URISyntaxException
      Copy and paste resource if it doesn't exist
      Parameters:
      resourceFileName -
      targetPath -
      Throws:
      IOException
      URISyntaxException
    • getFileFromResource

      public static String getFileFromResource(String resourceFilePath) throws URISyntaxException, IOException
      Return the content of a file located into resources
      Parameters:
      resourceFilePath -
      Returns:
      the content of the file as string
      Throws:
      URISyntaxException
      IOException
    • getFilePathFromResource

      public static Path getFilePathFromResource(String resourceFilePath) throws URISyntaxException, IOException
      Return the path of a file located into resources
      Parameters:
      resourceFilePath -
      Returns:
      the path of the file
      Throws:
      URISyntaxException
      IOException
    • getFileFromResourceAsStream

      public static InputStream getFileFromResourceAsStream(Path filePath) throws Exception
      Return the content of a file located into resources
      Parameters:
      filePath -
      Returns:
      the content of the file as string
      Throws:
      URISyntaxException
      IOException
      Exception
    • listFilesNamesInResourceFolder

      public static List<String> listFilesNamesInResourceFolder(Path folderPath, String ext) throws Exception
      Throws:
      Exception
    • cleanUpTemporaryEnvironmentFiles

      public static void cleanUpTemporaryEnvironmentFiles(String environmentName) throws IOException
      Clean up the kokos tmp folder
      Parameters:
      environmentName - the name of environment
      Throws:
      IOException - Exception
    • deleteDirectoryRecursively

      public static void deleteDirectoryRecursively(Path directory) throws IOException
      Delete a folder recursively. Delete all files and sub folders.
      Parameters:
      directory - path
      Throws:
      IOException - Exception
    • cleanupFolderRecursively

      public static void cleanupFolderRecursively(Path basePath, String folder) throws IOException
      Cleans up a folder recursively by deleting all files and directories under the specified folder name, starting from the base directory.
      Parameters:
      basePath - the base path to start.
      folder - the name of the folder to clean up within the basePath.
      Throws:
      IOException - if an I/O error occurs during the cleanup process.