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);
}
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());
}
}
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);
}
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);
}
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);
}
Aggregations