Class LPVSGitHubService

java.lang.Object
com.lpvs.service.LPVSGitHubService

@Service public class LPVSGitHubService extends Object
Service class for interacting with GitHub repositories and managing license-related actions.
  • Constructor Details

    • LPVSGitHubService

      @Autowired public LPVSGitHubService(LPVSPullRequestRepository pullRequestRepository, LPVSDetectedLicenseRepository lpvsDetectedLicenseRepository, LPVSLicenseRepository lpvsLicenseRepository, LPVSLicenseConflictRepository lpvsLicenseConflictRepository, LPVSGitHubConnectionService gitHubConnectionService)
      Constructs an instance of LPVSGitHubService with the specified repositories and connection service.
      Parameters:
      pullRequestRepository - Repository for managing LPVS pull requests.
      lpvsDetectedLicenseRepository - Repository for managing detected licenses.
      lpvsLicenseRepository - Repository for managing licenses.
      lpvsLicenseConflictRepository - Repository for managing license conflicts.
      gitHubConnectionService - Service for establishing and managing connections to the GitHub API.
  • Method Details

    • getPullRequestFiles

      public String getPullRequestFiles(LPVSQueue webhookConfig)
      Retrieves the file differences for a given pull request from GitHub.
      Parameters:
      webhookConfig - LPVSQueue configuration for the pull request.
      Returns:
      String representation of the pull request files or null if an error occurs.
    • setPendingCheck

      public void setPendingCheck(LPVSQueue webhookConfig)
      Sets the commit status to pending for the specified pull request.
      Parameters:
      webhookConfig - LPVSQueue configuration for the pull request.
    • setErrorCheck

      public void setErrorCheck(LPVSQueue webhookConfig)
      Sets the commit status to error for the specified pull request.
      Parameters:
      webhookConfig - LPVSQueue configuration for the pull request.
    • commentResults

      public void commentResults(LPVSQueue webhookConfig, List<LPVSFile> scanResults, List<LPVSLicenseService.Conflict<String,String>> conflicts, LPVSPullRequest lpvsPullRequest) throws Exception
      Comments on the pull request with the scan results and detected issues.
      Parameters:
      webhookConfig - LPVSQueue configuration for the pull request.
      scanResults - List of detected files and licenses.
      conflicts - List of license conflicts.
      lpvsPullRequest - LPVS entity representing the pull request.
      Throws:
      Exception
    • getRepositoryLicense

      public String getRepositoryLicense(LPVSQueue webhookConfig)
      Retrieves the license of the GitHub repository associated with the pull request.
      Parameters:
      webhookConfig - LPVSQueue configuration for the pull request.
      Returns:
      License key of the GitHub repository or null if not available.
    • getInternalQueueByPullRequest

      public LPVSQueue getInternalQueueByPullRequest(String pullRequest)
      Retrieves the LPVSQueue configuration for a given GitHub pull request URL.
      Parameters:
      pullRequest - The GitHub pull request URL.
      Returns:
      LPVSQueue configuration for the given pull request.