Search in sources :

Example 21 with CheckPermissionByResourceName

use of com.sequenceiq.authorization.annotation.CheckPermissionByResourceName in project cloudbreak by hortonworks.

the class BlueprintV4Controller method deleteByName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DELETE_CLUSTER_TEMPLATE)
public BlueprintV4Response deleteByName(Long workspaceId, @NotNull @ResourceName String name) {
    Blueprint deleted = blueprintService.deleteByWorkspace(NameOrCrn.ofName(name), restRequestThreadLocalService.getRequestedWorkspaceId());
    notify(ResourceEvent.BLUEPRINT_DELETED);
    return blueprintToBlueprintV4ResponseConverter.convert(deleted);
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 22 with CheckPermissionByResourceName

use of com.sequenceiq.authorization.annotation.CheckPermissionByResourceName in project cloudbreak by hortonworks.

the class ClusterTemplateV4Controller method getByName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_CLUSTER_DEFINITION)
public ClusterTemplateV4Response getByName(Long workspaceId, @ResourceName String name) {
    try {
        ClusterTemplate clusterTemplate = transactionService.required(() -> clusterTemplateService.getByNameForWorkspaceId(name, threadLocalService.getRequestedWorkspaceId()));
        ClusterTemplateV4Response response = transactionService.required(() -> clusterTemplateToClusterTemplateV4ResponseConverter.convert(clusterTemplate));
        Optional.ofNullable(response.getEnvironmentCrn()).ifPresent(crn -> environmentServiceDecorator.prepareEnvironment(response));
        return response;
    } catch (TransactionExecutionException cse) {
        LOGGER.warn("Unable to find cluster definition due to " + cse.getMessage(), cse.getCause());
        throw new CloudbreakServiceException("Unable to obtain cluster definition!", cse.getCause());
    }
}
Also used : ClusterTemplateV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateV4Response) ClusterTemplate(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 23 with CheckPermissionByResourceName

use of com.sequenceiq.authorization.annotation.CheckPermissionByResourceName in project cloudbreak by hortonworks.

the class CustomImageCatalogV4Controller method createCustomImage.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.EDIT_IMAGE_CATALOG)
public CustomImageCatalogV4CreateImageResponse createCustomImage(@ResourceName String name, @Valid CustomImageCatalogV4CreateImageRequest request, @AccountId String accountId) {
    String creator = ThreadBasedUserCrnProvider.getUserCrn();
    CustomImage customImage = customImageCatalogV4CreateImageRequestToCustomImageConverter.convert(request);
    CustomImage savedCustomImage = customImageCatalogService.createCustomImage(restRequestThreadLocalService.getRequestedWorkspaceId(), accountId, creator, name, customImage);
    return customImageToCustomImageCatalogV4CreateImageResponseConverter.convert(savedCustomImage);
}
Also used : CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 24 with CheckPermissionByResourceName

use of com.sequenceiq.authorization.annotation.CheckPermissionByResourceName in project cloudbreak by hortonworks.

the class CredentialV1Controller method verifyByName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_CREDENTIAL)
public CredentialResponse verifyByName(@ResourceName String name) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    Credential credential = credentialService.getByNameForAccountId(name, accountId, ENVIRONMENT);
    Credential verifiedCredential = credentialService.verify(credential);
    return credentialConverter.convert(verifiedCredential);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 25 with CheckPermissionByResourceName

use of com.sequenceiq.authorization.annotation.CheckPermissionByResourceName in project cloudbreak by hortonworks.

the class CredentialV1Controller method deleteByName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DELETE_CREDENTIAL)
public CredentialResponse deleteByName(@ResourceName String name) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    Credential deleted = credentialDeleteService.deleteByName(name, accountId, ENVIRONMENT);
    notify(ResourceEvent.CREDENTIAL_DELETED);
    return credentialConverter.convert(deleted);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Aggregations

CheckPermissionByResourceName (com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)29 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)7 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)6 Credential (com.sequenceiq.environment.credential.domain.Credential)4 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)3 CustomImage (com.sequenceiq.cloudbreak.domain.CustomImage)3 CheckPermissionByRequestProperty (com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty)2 Images (com.sequenceiq.cloudbreak.cloud.model.catalog.Images)2 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)2 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)2 SdxDatabaseBackupResponse (com.sequenceiq.sdx.api.model.SdxDatabaseBackupResponse)2 SdxDatabaseBackupStatusResponse (com.sequenceiq.sdx.api.model.SdxDatabaseBackupStatusResponse)2 ClusterTemplateV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateV4Response)1 CustomImageCatalogV4GetImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4GetImageResponse)1 ImageCatalogV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response)1 StackScaleV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request)1 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)1 ParametersQueryV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ParametersQueryV4Response)1 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1