use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class StackV4RequestToTemplatePreparationObjectConverter method convert.
public TemplatePreparationObject convert(StackV4Request source) {
try {
CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
User user = userService.getOrCreate(cloudbreakUser);
Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
DetailedEnvironmentResponse environment = environmentClientService.getByCrn(source.getEnvironmentCrn());
Credential credential = getCredential(source, environment);
LdapView ldapConfig = getLdapConfig(source, environment);
BaseFileSystemConfigurationsView fileSystemConfigurationView = getFileSystemConfigurationView(source, credential.getAttributes());
Set<RDSConfig> rdsConfigs = getRdsConfigs(source, workspace);
Blueprint blueprint = getBlueprint(source, workspace);
Set<HostgroupView> hostgroupViews = getHostgroupViews(source);
Gateway gateway = source.getCluster().getGateway() == null ? null : stackV4RequestToGatewayConverter.convert(source);
BlueprintView blueprintView = blueprintViewProvider.getBlueprintView(blueprint);
Optional<String> version = Optional.ofNullable(blueprintView.getVersion());
GeneralClusterConfigs generalClusterConfigs = generalClusterConfigsProvider.generalClusterConfigs(source, cloudbreakUser.getEmail(), blueprintService.getBlueprintVariant(blueprint));
String gatewaySignKey = null;
if (gateway != null) {
gatewaySignKey = gateway.getSignKey();
}
String envCrnForVirtualGroups = getEnvironmentCrnForVirtualGroups(environment);
VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(envCrnForVirtualGroups, ldapConfig != null ? ldapConfig.getAdminGroup() : "");
Builder builder = Builder.builder().withCloudPlatform(source.getCloudPlatform()).withRdsConfigs(rdsConfigs).withHostgroupViews(hostgroupViews).withGateway(gateway, gatewaySignKey, exposedServiceCollector.getAllKnoxExposed(version)).withBlueprintView(blueprintView).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigs).withLdapConfig(ldapConfig).withCustomInputs(source.getInputs()).withKerberosConfig(getKerberosConfig(source, environment)).withStackType(source.getType()).withVirtualGroupView(virtualGroupRequest);
decorateBuilderWithPlacement(source, builder);
decorateBuilderWithAccountMapping(source, environment, credential, builder);
decorateBuilderWithProductDetails(source, builder);
decorateDatalakeView(source, builder);
return builder.build();
} catch (BlueprintProcessingException | IOException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class GatewayV4RequestToGatewayConverter method convert.
public Gateway convert(GatewayV4Request source) {
ValidationResult validationResult = gatewayJsonValidator.validate(source);
if (validationResult.hasError()) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
if (CollectionUtils.isEmpty(source.getTopologies())) {
return null;
}
Gateway gateway = new Gateway();
gatewayConvertUtil.setBasicProperties(source, gateway);
gatewayConvertUtil.setTopologies(source, gateway);
gatewayConvertUtil.setGatewayPathAndSsoProvider(source, gateway);
CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
User user = userService.getOrCreate(cloudbreakUser);
Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
gateway.setWorkspace(workspace);
return gateway;
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class AuditEventService method getAuditEventsByWorkspaceId.
public List<AuditEventV4Response> getAuditEventsByWorkspaceId(Long workspaceId, String resourceType, Long resourceId, String resourceCrn) {
User user = userService.getOrCreate(legacyRestRequestThreadLocalService.getCloudbreakUser());
Workspace workspace = getWorkspaceService().get(workspaceId, user);
List<AuditEventV4Response> auditEventV4Responses = getEventsForUserWithTypeAndResourceIdByWorkspace(workspace, resourceType, resourceId, resourceCrn);
auditEventV4Responses.sort(new AuditEventComparator().reversed());
return auditEventV4Responses;
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class BlueprintService method createWithInternalUser.
public Blueprint createWithInternalUser(Blueprint blueprint, Long workspaceId, String accountId) {
validate(blueprint, true);
blueprint.setResourceCrn(createCRN(accountId));
try {
return transactionService.required(() -> {
Workspace workspace = getWorkspaceService().getByIdWithoutAuth(workspaceId);
blueprint.setWorkspace(workspace);
blueprint.setStatus(ResourceStatus.SERVICE_MANAGED);
return super.pureSave(blueprint);
});
} catch (TransactionService.TransactionExecutionException e) {
throw new TransactionService.TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class BlueprintService method findAllByWorkspaceId.
@Override
public Set<Blueprint> findAllByWorkspaceId(Long workspaceId) {
User user = getLoggedInUser();
Workspace workspace = getWorkspaceService().get(workspaceId, user);
return getAllAvailableInWorkspace(workspace);
}
Aggregations