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));
}
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;
}
Aggregations