Package com.lpvs.util

Class LPVSFileUtil

java.lang.Object
com.lpvs.util.LPVSFileUtil

public class LPVSFileUtil extends Object
Utility class providing methods for handling files, directories, and file-related operations in the context of LPVS application processing. It includes functionality to save files, generate pretty patches, and manage local directory paths.
  • Constructor Details

    • LPVSFileUtil

      public LPVSFileUtil()
  • Method Details

    • saveFile

      public static void saveFile(String fileName, String directoryPath, List<String> patchedLines)
      Saves a file with the specified content in a given directory.
      Parameters:
      fileName - The name of the file to be saved.
      directoryPath - The path to the directory where the file will be saved.
      patchedLines - The content to be written to the file.
    • saveGithubDiffs

      public static String saveGithubDiffs(Iterable<org.kohsuke.github.GHPullRequestFileDetail> files, LPVSQueue webhookConfig)
      Saves the GitHub pull request file details, including the file patches, to a local directory.
      Parameters:
      files - The iterable of GitHub pull request file details.
      webhookConfig - The LPVSQueue configuration for the webhook.
      Returns:
      The path to the directory where the files are saved.
    • deleteIfExists

      public static void deleteIfExists(String path)
      Deletes the specified directory if it exists.
      Parameters:
      path - The path of the directory to be deleted.
    • getLocalDirectoryPath

      public static String getLocalDirectoryPath(LPVSQueue webhookConfig)
      Retrieves the local directory path based on the provided webhook configuration.
      Parameters:
      webhookConfig - The LPVSQueue configuration for the webhook.
      Returns:
      The local directory path.
    • getScanResultsJsonFilePath

      public static String getScanResultsJsonFilePath(LPVSQueue webhookConfig)
      Retrieves the file path for storing scan results in JSON format based on the provided webhook configuration.
      Parameters:
      webhookConfig - The LPVSQueue configuration for the webhook.
      Returns:
      The file path for storing scan results in JSON format.
    • getScanResultsDirectoryPath

      public static String getScanResultsDirectoryPath(LPVSQueue webhookConfig)
      Retrieves the directory path for storing scan results based on the provided webhook configuration.
      Parameters:
      webhookConfig - The LPVSQueue configuration for the webhook.
      Returns:
      The directory path for storing scan results.
    • getPathByPullRequest

      public static String getPathByPullRequest(LPVSQueue webhookConfig)
      Retrieves the local directory path for a given LPVSQueue configuration.
      Parameters:
      webhookConfig - LPVSQueue configuration.
      Returns:
      Local directory path for the given LPVSQueue.