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); }
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; }
public String respond(Reader requestData) { long startTime = clock.currentTime(); Gson gson = new Gson(); List<String> checks = null; try { checks = gson.fromJson(GetPostData(requestData), requestType()); } catch (Exception ex) { System.err.println(ex.getMessage()); } LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>(); if (checks != null) { for (String amount : checks) { if (clock.IsOverTime(startTime)) { break; } Long parsedValue = checkParser.parseExpression(amount); if (parsedValue == null) { System.err.println("could not parse amount " + amount); } else { map.put(amount, parsedValue); } // don't save when upload google appengine // it will cause timeout issue !!! // dataStore.saveRow("Checks", amount); } } // if we want to display "&" rather than "\u0026" // return new GsonBuilder().disableHtmlEscaping().create().toString(map); return gson.toJson(map); }