Search in sources :

Example 1 with User

use of com.sequenceiq.cloudbreak.workspace.model.User in project cloudbreak by hortonworks.

the class ImageCatalogService method getImagesFromDefault.

public Images getImagesFromDefault(Long workspaceId, String stackName, String platform, Set<String> operatingSystems) throws CloudbreakImageCatalogException {
    if (isNotEmpty(platform) && isNotEmpty(stackName)) {
        throw new BadRequestException("Platform or stackName cannot be filled in the same request.");
    }
    if (isNotEmpty(platform)) {
        User user = getLoggedInUser();
        ImageFilter imageFilter = new ImageFilter(getDefaultImageCatalog(user), Set.of(platform), null, baseImageEnabled(), operatingSystems, null);
        return getStatedImagesFilteredByOperatingSystems(imageFilter, image -> true).getImages();
    } else if (isNotEmpty(stackName)) {
        return stackImageFilterService.getApplicableImages(workspaceId, stackName);
    } else {
        throw new BadRequestException("Either platform or stackName should be filled in request.");
    }
}
Also used : EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) UserProfileService(com.sequenceiq.cloudbreak.service.user.UserProfileService) LoggerFactory(org.slf4j.LoggerFactory) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException) StringUtils(org.apache.commons.lang3.StringUtils) CloudbreakRestRequestThreadLocalService(com.sequenceiq.cloudbreak.structuredevent.CloudbreakRestRequestThreadLocalService) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) Map(java.util.Map) AuthorizationResourceType(com.sequenceiq.authorization.resource.AuthorizationResourceType) Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) EnumSet(java.util.EnumSet) ResourceWithId(com.sequenceiq.authorization.service.list.ResourceWithId) ImmutableSet(com.google.common.collect.ImmutableSet) ImageCatalogRepository(com.sequenceiq.cloudbreak.repository.ImageCatalogRepository) WorkspaceResourceRepository(com.sequenceiq.cloudbreak.workspace.repository.workspace.WorkspaceResourceRepository) Collections.emptyList(java.util.Collections.emptyList) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) Collectors(java.util.stream.Collectors) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) List(java.util.List) MDCUtils(com.sequenceiq.cloudbreak.logger.MDCUtils) CollectionUtils(org.springframework.util.CollectionUtils) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) PreferencesService(com.sequenceiq.cloudbreak.service.account.PreferencesService) Optional(java.util.Optional) UserProfileHandler(com.sequenceiq.cloudbreak.service.user.UserProfileHandler) Collectors.partitioningBy(java.util.stream.Collectors.partitioningBy) OwnerAssignmentService(com.sequenceiq.authorization.service.OwnerAssignmentService) HashMap(java.util.HashMap) BooleanUtils(org.apache.commons.lang3.BooleanUtils) CompositeAuthResourcePropertyProvider(com.sequenceiq.authorization.service.CompositeAuthResourcePropertyProvider) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) Strings(com.google.common.base.Strings) CrnResourceDescriptor(com.sequenceiq.cloudbreak.auth.crn.CrnResourceDescriptor) StatedImage.statedImage(com.sequenceiq.cloudbreak.service.image.StatedImage.statedImage) ImageType(com.sequenceiq.common.api.type.ImageType) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Nonnull(javax.annotation.Nonnull) NotFoundException.notFound(com.sequenceiq.cloudbreak.common.exception.NotFoundException.notFound) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Logger(org.slf4j.Logger) Collections.emptySet(java.util.Collections.emptySet) StatedImages.statedImages(com.sequenceiq.cloudbreak.service.image.StatedImages.statedImages) RegionAwareCrnGenerator(com.sequenceiq.cloudbreak.auth.crn.RegionAwareCrnGenerator) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) ImageCatalogServiceProxy(com.sequenceiq.cloudbreak.service.image.catalog.ImageCatalogServiceProxy) Collectors.toList(java.util.stream.Collectors.toList) Component(org.springframework.stereotype.Component) User(com.sequenceiq.cloudbreak.workspace.model.User) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) NameUtil.generateArchiveName(com.sequenceiq.cloudbreak.util.NameUtil.generateArchiveName) Comparator(java.util.Comparator) AbstractWorkspaceAwareResourceService(com.sequenceiq.cloudbreak.service.AbstractWorkspaceAwareResourceService) User(com.sequenceiq.cloudbreak.workspace.model.User) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException)

Example 2 with User

use of com.sequenceiq.cloudbreak.workspace.model.User in project cloudbreak by hortonworks.

the class ClusterDecoratorTest method testAutoTlsSettingByParentEnvironmentCloudPlatform.

@Test
void testAutoTlsSettingByParentEnvironmentCloudPlatform() {
    Cluster expectedClusterInstance = new Cluster();
    Blueprint blueprint = getBlueprint();
    when(sharedServiceConfigProvider.configureCluster(any(Cluster.class), any(User.class), any(Workspace.class))).thenReturn(expectedClusterInstance);
    ArgumentCaptor<Platform> platformArgumentCaptor = ArgumentCaptor.forClass(Platform.class);
    when(cloudPlatformConnectors.get(platformArgumentCaptor.capture(), any())).thenReturn(connector);
    when(embeddedDatabaseService.isEmbeddedDatabaseOnAttachedDiskEnabled(stack, expectedClusterInstance)).thenReturn(false);
    String platform = CloudPlatform.YARN.name();
    underTest.decorate(expectedClusterInstance, createClusterV4Request(), blueprint, user, new Workspace(), stack, platform);
    assertEquals(platform, platformArgumentCaptor.getValue().value());
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with User

use of com.sequenceiq.cloudbreak.workspace.model.User in project cloudbreak by hortonworks.

the class InstanceGroupV4RequestToHostGroupConverter method convert.

public HostGroup convert(InstanceGroupV4Request source) {
    HostGroup hostGroup = new HostGroup();
    hostGroup.setName(source.getName().toLowerCase());
    hostGroup.setRecoveryMode(source.getRecoveryMode());
    Set<String> recipeNames = source.getRecipeNames();
    if (!CollectionUtils.isEmpty(recipeNames)) {
        CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
        User user = userService.getOrCreate(cloudbreakUser);
        Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
        hostGroup.setRecipes(recipeService.getRecipesByNamesForWorkspace(workspace, recipeNames));
    }
    return hostGroup;
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 4 with User

use of com.sequenceiq.cloudbreak.workspace.model.User in project cloudbreak by hortonworks.

the class ImageCatalogToImageCatalogV4ResponseConverter method isDefault.

private boolean isDefault(String imageCatalogName) {
    CloudbreakUser cloudbreakUser = legacyRestRequestThreadLocalService.getCloudbreakUser();
    User user = userService.getOrCreate(cloudbreakUser);
    String defaultImageCatalogName = imageCatalogService.getDefaultImageCatalogName(user);
    return imageCatalogName.equals(defaultImageCatalogName) || (defaultImageCatalogName == null && imageCatalogService.isEnvDefault(imageCatalogName));
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser)

Example 5 with User

use of com.sequenceiq.cloudbreak.workspace.model.User in project cloudbreak by hortonworks.

the class BlueprintService method updateDefaultBlueprintCollection.

public void updateDefaultBlueprintCollection(Long workspaceId) {
    User user = getLoggedInUser();
    Workspace workspace = getWorkspaceService().get(workspaceId, user);
    updateDefaultBlueprintCollection(workspace);
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Aggregations

User (com.sequenceiq.cloudbreak.workspace.model.User)63 CloudbreakUser (com.sequenceiq.cloudbreak.common.user.CloudbreakUser)32 Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)28 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)17 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)13 Test (org.junit.jupiter.api.Test)9 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)8 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)8 Tenant (com.sequenceiq.cloudbreak.workspace.model.Tenant)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 Optional (java.util.Optional)6 Set (java.util.Set)6 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)5 List (java.util.List)5 Inject (javax.inject.Inject)5 Before (org.junit.Before)5 Test (org.junit.Test)5 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)4 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)4