Class LPVSQueueService

java.lang.Object
com.lpvs.service.LPVSQueueService

@Service public class LPVSQueueService extends Object
Service for managing LPVSQueue elements and processing webhooks.
  • Constructor Details

    • LPVSQueueService

      public LPVSQueueService(LPVSGitHubService gitHubService, LPVSDetectService detectService, LPVSLicenseService licenseService, LPVSPullRequestRepository lpvsPullRequestRepository, LPVSQueueRepository queueRepository, @Value("${lpvs.attempts:4}") int maxAttempts)
      Constructor for LPVSQueueService.
      Parameters:
      gitHubService - Service for interacting with GitHub.
      detectService - Service for detecting licenses in scanned files.
      licenseService - Service for managing licenses and license conflicts.
      lpvsPullRequestRepository - Repository for storing LPVSPullRequest entities.
      queueRepository - Repository for storing LPVSQueue entities.
      maxAttempts - Maximum attempts for processing LPVSQueue elements.
  • Method Details

    • getQueueFirstElement

      public LPVSQueue getQueueFirstElement() throws InterruptedException
      Gets the first element from the LPVSQueue.
      Returns:
      The first LPVSQueue element.
      Throws:
      InterruptedException - If interrupted while waiting for the element.
    • addFirst

      public void addFirst(LPVSQueue webhookConfig) throws InterruptedException
      Adds the LPVSQueue element to the front of the queue.
      Parameters:
      webhookConfig - The LPVSQueue element to be added.
      Throws:
      InterruptedException - If interrupted while waiting to add the element.
    • add

      public void add(LPVSQueue webhookConfig) throws InterruptedException
      Adds the LPVSQueue element to the end of the queue.
      Parameters:
      webhookConfig - The LPVSQueue element to be added.
      Throws:
      InterruptedException - If interrupted while waiting to add the element.
    • delete

      public void delete(LPVSQueue webhookConfig)
      Deletes the LPVSQueue element from the repository and the queue.
      Parameters:
      webhookConfig - The LPVSQueue element to be deleted.
    • getQueue

      public BlockingDeque<LPVSQueue> getQueue()
      Gets the entire LPVSQueue.
      Returns:
      The BlockingDeque containing LPVSQueue elements.
    • checkForQueue

      public void checkForQueue() throws InterruptedException
      Checks for any previous LPVSQueue elements and processes them.
      Throws:
      InterruptedException - If interrupted while processing the queue.
    • getLatestScan

      public LPVSQueue getLatestScan(List<LPVSQueue> webhookConfigList)
      Gets the LPVSQueue element with the latest scan date.
      Parameters:
      webhookConfigList - The list of LPVSQueue elements.
      Returns:
      The LPVSQueue element with the latest scan date.
    • processWebHook

      @Async("threadPoolTaskExecutor") public void processWebHook(LPVSQueue webhookConfig)
      Asynchronously processes the LPVSQueue element, handling GitHub webhook events.
      Parameters:
      webhookConfig - The LPVSQueue element to be processed.