use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class PipelineRepository method findPipelineSelectionsById.
public PipelineSelections findPipelineSelectionsById(long id) {
PipelineSelections pipelineSelections;
String key = pipelineSelectionForCookieKey(id);
if (goCache.isKeyInCache(key)) {
return (PipelineSelections) goCache.get(key);
}
synchronized (key) {
if (goCache.isKeyInCache(key)) {
return (PipelineSelections) goCache.get(key);
}
pipelineSelections = getHibernateTemplate().get(PipelineSelections.class, id);
goCache.put(key, pipelineSelections);
return pipelineSelections;
}
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class DashboardControllerDelegate method index.
public Object index(Request request, Response response) throws IOException {
if (goDashboardService.isFeatureToggleDisabled()) {
response.status(424);
return FEATURE_NOT_ENABLED;
}
if (!goDashboardService.hasEverLoadedCurrentState()) {
response.status(202);
return BEING_PROCESSED;
}
String selectedPipelinesCookie = request.cookie("selected_pipelines");
Long userId = currentUserId(request);
Username userName = currentUsername();
PipelineSelections selectedPipelines = pipelineSelectionsService.getPersistedSelectedPipelines(selectedPipelinesCookie, userId);
List<GoDashboardPipelineGroup> pipelineGroups = goDashboardService.allPipelineGroupsForDashboard(selectedPipelines, userName);
String etag = DigestUtils.md5Hex(pipelineGroups.stream().map(GoDashboardPipelineGroup::etag).collect(Collectors.joining("/")));
if (fresh(request, etag)) {
return notModified(response);
}
setEtagHeader(response, etag);
return writerForTopLevelObject(request, response, outputWriter -> PipelineGroupsRepresenter.toJSON(outputWriter, new DashboardFor(pipelineGroups, userName)));
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class PipelineSelectionsRepresenter method fromJSON.
public static PipelineSelectionResponse fromJSON(JsonReader reader) {
List<String> selections = reader.readStringArrayIfPresent("selections").orElse(Collections.emptyList());
Boolean blacklist = reader.optBoolean("blacklist").orElse(true);
return new PipelineSelectionResponse(new PipelineSelections(selections, new Date(), -1L, blacklist), null);
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class PipelineRepositoryIntegrationTest method shouldSaveSelectedPipelinesWithUserId.
@Test
public void shouldSaveSelectedPipelinesWithUserId() {
User user = createUser();
List<String> unSelected = Arrays.asList("pipeline1", "pipeline2");
long id = pipelineRepository.saveSelectedPipelines(new PipelineSelections(unSelected, new Date(), user.getId(), true));
assertThat(pipelineRepository.findPipelineSelectionsById(id).userId(), is(user.getId()));
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class PipelineRepositoryIntegrationTest method shouldFindSelectedPipelinesByUserId.
@Test
public void shouldFindSelectedPipelinesByUserId() {
User user = createUser();
List<String> unSelected = Arrays.asList("pipeline1", "pipeline2");
long id = pipelineRepository.saveSelectedPipelines(new PipelineSelections(unSelected, new Date(), user.getId(), true));
assertThat(pipelineRepository.findPipelineSelectionsByUserId(user.getId()).getId(), is(id));
}
Aggregations