use of com.sequenceiq.cloudbreak.auth.security.internal.AccountId in project cloudbreak by hortonworks.
the class EventV4Controller method download.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public Response download(String name, @AccountId String accountId) {
StructuredEventContainer events = legacyStructuredEventService.getStructuredEventsForStack(name, workspaceService.getForCurrentUser().getId());
StreamingOutput streamingOutput = output -> {
try (ZipOutputStream zipOutputStream = new ZipOutputStream(output)) {
zipOutputStream.putNextEntry(new ZipEntry("struct-events.json"));
zipOutputStream.write(JsonUtil.writeValueAsString(events).getBytes());
zipOutputStream.closeEntry();
}
};
return Response.ok(streamingOutput).header("content-disposition", "attachment; filename = struct-events.zip").build();
}
use of com.sequenceiq.cloudbreak.auth.security.internal.AccountId in project cloudbreak by hortonworks.
the class AuditCredentialV1Controller method post.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_AUDIT_CREDENTIAL)
public CredentialResponse post(@Valid CredentialRequest request) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
String creator = ThreadBasedUserCrnProvider.getUserCrn();
Credential credential = credentialConverter.convert(request);
credential.setType(AUDIT);
credential.setVerifyPermissions(false);
notify(ResourceEvent.CREDENTIAL_CREATED);
Set<Credential> auditCredentialsByPlatfom = credentialService.listAvailablesByAccountId(accountId, AUDIT).stream().filter(c -> c.getCloudPlatform().equals(credential.getCloudPlatform())).collect(Collectors.toSet());
if (auditCredentialsByPlatfom.isEmpty()) {
return credentialConverter.convert(credentialService.create(credential, accountId, creator, AUDIT));
} else {
throw new BadRequestException(String.format("Audit credential already exist for %s cloud.", credential.getCloudPlatform()));
}
}
Aggregations