use of com.sequenceiq.cloudbreak.service.stack.ShowTerminatedClusterConfigService.ShowTerminatedClustersAfterConfig in project cloudbreak by hortonworks.
the class StackService method getByNameInWorkspaceWithEntries.
public StackV4Response getByNameInWorkspaceWithEntries(String name, Long workspaceId, Set<String> entries, User user, StackType stackType) {
try {
return transactionService.required(() -> {
Workspace workspace = workspaceService.get(workspaceId, user);
ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = showTerminatedClusterConfigService.get();
Optional<Stack> stack = findByNameAndWorkspaceIdWithLists(name, workspace.getId(), stackType, showTerminatedClustersAfterConfig);
if (stack.isEmpty()) {
throw new NotFoundException(format(STACK_NOT_FOUND_BY_NAME_EXCEPTION_MESSAGE, name));
}
StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack.get());
stackResponse = stackResponseDecorator.decorate(stackResponse, stack.get(), entries);
return stackResponse;
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.service.stack.ShowTerminatedClusterConfigService.ShowTerminatedClustersAfterConfig in project cloudbreak by hortonworks.
the class StackService method getStackRequestByNameOrCrnInWorkspaceId.
public StackV4Request getStackRequestByNameOrCrnInWorkspaceId(NameOrCrn nameOrCrn, Long workspaceId) {
try {
return transactionService.required(() -> {
ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = showTerminatedClusterConfigService.get();
Optional<Stack> stack = findByNameOrCrnAndWorkspaceIdWithLists(nameOrCrn, workspaceId);
if (stack.isEmpty()) {
throw new NotFoundException(format(STACK_NOT_FOUND_BY_NAME_OR_CRN_EXCEPTION_MESSAGE, nameOrCrn));
}
StackV4Request request = stackToStackV4RequestConverter.convert(stack.get());
request.getCluster().setName(null);
request.setName(stack.get().getName());
return request;
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.service.stack.ShowTerminatedClusterConfigService.ShowTerminatedClustersAfterConfig in project cloudbreak by hortonworks.
the class ShowTerminatedClustersConfigServiceTest method testGetWhenUserHasPreference.
@Test
public void testGetWhenUserHasPreference() {
init(false);
when(clock.nowMinus(DEFAULT_DURATION)).thenReturn(Instant.ofEpochSecond(0));
ShowTerminatedClustersAfterConfig showTerminatedClustersConfig = underTest.get();
assertFalse(showTerminatedClustersConfig.isActive());
assertEquals(Long.valueOf(0), showTerminatedClustersConfig.showAfterMillisecs());
verify(userProfileService, times(0)).getOrCreateForLoggedInUser();
}
use of com.sequenceiq.cloudbreak.service.stack.ShowTerminatedClusterConfigService.ShowTerminatedClustersAfterConfig in project cloudbreak by hortonworks.
the class ShowTerminatedClustersConfigServiceTest method testGetWhenUserHasNoPreference.
@Test
public void testGetWhenUserHasNoPreference() {
init(false);
when(userProfileService.getOrCreateForLoggedInUser()).thenReturn(new UserProfileBuilder().withNullClusterPrefs().build());
when(clock.nowMinus(any())).thenReturn(Instant.ofEpochSecond(0));
ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = underTest.get();
assertFalse(showTerminatedClustersAfterConfig.isActive());
assertEquals(0L, showTerminatedClustersAfterConfig.showAfterMillisecs().longValue());
verify(clock).nowMinus(any());
verify(userProfileService, times(0)).getOrCreateForLoggedInUser();
}
use of com.sequenceiq.cloudbreak.service.stack.ShowTerminatedClusterConfigService.ShowTerminatedClustersAfterConfig in project cloudbreak by hortonworks.
the class StackService method getByCrnInWorkspaceWithEntries.
public StackV4Response getByCrnInWorkspaceWithEntries(String crn, Long workspaceId, Set<String> entries, User user, StackType stackType) {
try {
return transactionService.required(() -> {
Workspace workspace = workspaceService.get(workspaceId, user);
ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = showTerminatedClusterConfigService.get();
Optional<Stack> stack = findByCrnAndWorkspaceIdWithLists(crn, workspace.getId(), stackType, showTerminatedClustersAfterConfig);
if (stack.isEmpty()) {
throw new NotFoundException(format("Stack not found by crn '%s'", crn));
}
StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack.get());
stackResponse = stackResponseDecorator.decorate(stackResponse, stack.get(), entries);
return stackResponse;
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
Aggregations