예제 #1
0
  public long persistSelectedPipelines(
      String id, Long userId, List<String> selectedPipelines, boolean isBlacklist) {
    PipelineSelections pipelineSelections = findOrCreateCurrentPipelineSelectionsFor(id, userId);

    if (isBlacklist) {
      List<String> unselectedPipelines = invertSelections(selectedPipelines);
      pipelineSelections.update(unselectedPipelines, clock.currentTime(), userId, isBlacklist);
    } else {
      pipelineSelections.update(selectedPipelines, clock.currentTime(), userId, isBlacklist);
    }

    return pipelineRepository.saveSelectedPipelines(pipelineSelections);
  }
예제 #2
0
 private PipelineSelections findOrCreateCurrentPipelineSelectionsFor(String id, Long userId) {
   PipelineSelections pipelineSelections =
       isSecurityEnabled()
           ? pipelineRepository.findPipelineSelectionsByUserId(userId)
           : pipelineRepository.findPipelineSelectionsById(id);
   if (pipelineSelections == null) {
     pipelineSelections =
         new PipelineSelections(new ArrayList<String>(), clock.currentTime(), userId, true);
   }
   return pipelineSelections;
 }