use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class StageService method feed.
public FeedEntries feed(String pipelineName, Username username) {
String key = cacheKeyForLatestStageFeedForPipeline(pipelineName);
List<StageFeedEntry> feedEntries = (List<StageFeedEntry>) goCache.get(key);
if (feedEntries == null) {
synchronized (key) {
// Double check locking is done because the query is expensive (takes about 2 seconds)
feedEntries = (List<StageFeedEntry>) goCache.get(key);
if (feedEntries == null) {
feedEntries = stageDao.findCompletedStagesFor(pipelineName, FeedModifier.Latest, -1, FEED_PAGE_SIZE);
populateAuthors(feedEntries, pipelineName, username);
goCache.put(key, feedEntries);
}
}
}
return cloner.deepClone(new FeedEntries(new ArrayList<>(feedEntries)));
}
use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class StageService method findStageFeedBy.
public FeedEntries findStageFeedBy(String pipelineName, Integer pipelineCounter, FeedModifier feedModifier, Username username) {
if (pipelineCounter != null) {
List<StageFeedEntry> feedBasedOnPipelineCounter = stageDao.findStageFeedBy(pipelineName, pipelineCounter, feedModifier, FEED_PAGE_SIZE);
return cloner.deepClone(new FeedEntries(new ArrayList<>(feedBasedOnPipelineCounter)));
}
String key = cacheKeyForLatestStageFeedForPipelineSortedByPipelineCounter(pipelineName);
List<StageFeedEntry> feedEntries = (List<StageFeedEntry>) goCache.get(key);
if (feedEntries == null) {
synchronized (key) {
feedEntries = (List<StageFeedEntry>) goCache.get(key);
if (feedEntries == null) {
feedEntries = stageDao.findStageFeedBy(pipelineName, pipelineCounter, null, FEED_PAGE_SIZE);
populateAuthors(feedEntries, pipelineName, username);
goCache.put(key, feedEntries);
}
}
}
return cloner.deepClone(new FeedEntries(new ArrayList<>(feedEntries)));
}
use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class PipelineStagesFeedServiceTest method shouldReturnUnauthorizedIfUserDoesNotHaveViewPermissionOnThePipeline.
@Test
public void shouldReturnUnauthorizedIfUserDoesNotHaveViewPermissionOnThePipeline() {
when(securityService.hasViewPermissionForPipeline(user, "cruise")).thenReturn(false);
FeedEntries feedEntries = pipelineStagesFeedResolver.feed(user, operationResult);
assertThat(feedEntries, is(nullValue()));
verifyThatUserIsUnauthorized();
verifyNoMoreInteractions(stageService);
}
use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class PipelineStagesFeedServiceTest method setUp.
@BeforeEach
public void setUp() throws Exception {
user = new Username(new CaseInsensitiveString("barrow"));
expected = new FeedEntries();
stageService = mock(StageService.class);
securityService = mock(SecurityService.class);
operationResult = new HttpLocalizedOperationResult();
pipelineStagesFeedResolver = new PipelineStagesFeedService(stageService, securityService).feedResolverFor("cruise");
}
use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class StageServiceIntegrationTest method shouldLoadStageAuthors_forFirstPageOfFeed.
@Test
public void shouldLoadStageAuthors_forFirstPageOfFeed() throws Exception {
PipelineConfig downstream = setup2DependentInstances();
FeedEntries feed = stageService.feed(downstream.name().toString(), new Username(new CaseInsensitiveString("loser")));
assertStageEntryAuthor(feed);
}
Aggregations