Search in sources :

Example 1 with PipelineSelectionResponse

use of com.thoughtworks.go.apiv1.pipelineselection.representers.PipelineSelectionResponse in project gocd by gocd.

the class PipelineSelectionControllerDelegate method show.

public String show(Request request, Response response) throws IOException {
    String fromCookie = request.cookie("selected_pipelines");
    PipelineSelections selectedPipelines = pipelineSelectionsService.getSelectedPipelines(fromCookie, currentUserId(request));
    List<PipelineConfigs> pipelineConfigs = pipelineConfigService.viewableGroupsFor(currentUsername());
    PipelineSelectionResponse pipelineSelectionResponse = new PipelineSelectionResponse(selectedPipelines, pipelineConfigs);
    return writerForTopLevelObject(request, response, writer -> PipelineSelectionsRepresenter.toJSON(writer, pipelineSelectionResponse));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) PipelineSelectionResponse(com.thoughtworks.go.apiv1.pipelineselection.representers.PipelineSelectionResponse)

Example 2 with PipelineSelectionResponse

use of com.thoughtworks.go.apiv1.pipelineselection.representers.PipelineSelectionResponse in project gocd by gocd.

the class PipelineSelectionControllerDelegate method update.

public String update(Request request, Response response) {
    String fromCookie = request.cookie("selected_pipelines");
    JsonReader jsonReader = GsonTransformer.getInstance().jsonReaderFrom(request.body());
    PipelineSelectionResponse selectionResponse = PipelineSelectionsRepresenter.fromJSON(jsonReader);
    Long recordId = pipelineSelectionsService.persistSelectedPipelines(fromCookie, currentUserId(request), selectionResponse.getSelectedPipelines().pipelineList(), selectionResponse.getSelectedPipelines().isBlacklist());
    if (!apiAuthenticationHelper.securityEnabled()) {
        response.cookie("/go", "selected_pipelines", String.valueOf(recordId), ONE_YEAR, systemEnvironment.isSessionCookieSecure(), true);
    }
    response.status(204);
    return NOTHING;
}
Also used : JsonReader(com.thoughtworks.go.api.representers.JsonReader) PipelineSelectionResponse(com.thoughtworks.go.apiv1.pipelineselection.representers.PipelineSelectionResponse)

Aggregations

PipelineSelectionResponse (com.thoughtworks.go.apiv1.pipelineselection.representers.PipelineSelectionResponse)2 JsonReader (com.thoughtworks.go.api.representers.JsonReader)1 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)1 PipelineSelections (com.thoughtworks.go.server.domain.user.PipelineSelections)1