Search in sources :

Example 46 with PipelineSelections

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;
    }
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections)

Example 47 with 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)));
}
Also used : DashboardFor(com.thoughtworks.go.apiv2.dashboard.representers.DashboardFor) PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Username(com.thoughtworks.go.server.domain.Username) GoDashboardPipelineGroup(com.thoughtworks.go.server.dashboard.GoDashboardPipelineGroup)

Example 48 with PipelineSelections

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);
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date)

Example 49 with PipelineSelections

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()));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Test(org.junit.Test)

Example 50 with PipelineSelections

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));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Test(org.junit.Test)

Aggregations

PipelineSelections (com.thoughtworks.go.server.domain.user.PipelineSelections)57 Test (org.junit.Test)44 DateTime (org.joda.time.DateTime)12 Username (com.thoughtworks.go.server.domain.Username)9 User (com.thoughtworks.go.domain.User)8 Date (java.util.Date)8 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)5 BaseMatcher (org.hamcrest.BaseMatcher)4 Description (org.hamcrest.Description)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 Permissions (com.thoughtworks.go.config.security.Permissions)2 PipelineInstanceModels.createPipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 PipelineSelectionResponse (com.thoughtworks.go.apiv1.pipelineselection.representers.PipelineSelectionResponse)1 DashboardFor (com.thoughtworks.go.apiv2.dashboard.representers.DashboardFor)1 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)1 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)1 GoDashboardPipelineGroup (com.thoughtworks.go.server.dashboard.GoDashboardPipelineGroup)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1