Source:
public Credential create(Credential credential, @Nonnull String accountId, @Nonnull String creatorUserCrn, CredentialType type) { repository.findByNameAndAccountId(credential.getName(), accountId, getEnabledPlatforms(), type) .map(Credential::getName) .ifPresent(name -> { throw new BadRequestException("Credential already exists with name: " + name); }); LOGGER.debug("Validating credential for cloudPlatform and creator {}.", credential.getCloudPlatform(), creatorUserCrn); credentialValidator.validateCredentialCloudPlatform(credential.getCloudPlatform(), creatorUserCrn); LOGGER.debug("Validating credential parameters for cloudPlatform and creator {}.", credential.getCloudPlatform(), creatorUserCrn); credentialValidator.validateParameters(Platform.platform(credential.getCloudPlatform()), new Json(credential.getAttributes())); String credentialCrn = createCRN(accountId); credential.setResourceCrn(credentialCrn); credential.setCreator(creatorUserCrn); credential.setAccountId(accountId); Credential verifiedCredential = credentialAdapter.verify(credential, accountId).getCredential(); if (verifiedCredential.getVerificationStatusText() != null) { throw new BadRequestException(verifiedCredential.getVerificationStatusText()); } try { return transactionService.required(() -> { Credential created = repository.save(verifiedCredential); grpcUmsClient.assignResourceOwnerRoleIfEntitled(creatorUserCrn, credentialCrn, accountId); sendCredentialNotification(credential, ResourceEvent.CREDENTIAL_CREATED); return created; }); } catch (TransactionService.TransactionExecutionException e) { LOGGER.error("Error happened during credential creation: ", e); throw new InternalServerErrorException(e); } }

Target:
public Credential create(Credential credential, @Nonnull String accountId, @Nonnull String creatorUserCrn, CredentialType type) { repository.findByNameAndAccountId(credential.getName(), accountId, getEnabledPlatforms(), type) .map(Credential::getName) .ifPresent(name -> { throw new BadRequestException("Credential already exists with name: " + name); }); LOGGER.debug("Validating credential for cloudPlatform and creator {}.", credential.getCloudPlatform(), creatorUserCrn); credentialValidator.validateCredentialCloudPlatform(credential.getCloudPlatform(), creatorUserCrn); LOGGER.debug("Validating credential parameters for cloudPlatform and creator {}.", credential.getCloudPlatform(), creatorUserCrn); credentialValidator.validateParameters(Platform.platform(credential.getCloudPlatform()), new Json(credential.getAttributes())); String credentialCrn = createCRN(accountId); credential.setResourceCrn(credentialCrn); credential.setCreator(creatorUserCrn); credential.setAccountId(accountId); Credential verifiedCredential = credentialAdapter.verify(credential, accountId).getCredential(); if (verifiedCredential.getVerificationStatusText() != null) { throw new BadRequestException(verifiedCredential.getVerificationStatusText()); } try { Credential createdCredential = transactionService.required(() -> { Credential created = repository.save(verifiedCredential); grpcUmsClient.assignResourceOwnerRoleIfEntitled(creatorUserCrn, credentialCrn, accountId); return created; }); sendCredentialNotification(createdCredential, ResourceEvent.CREDENTIAL_CREATED); return createdCredential; } catch (TransactionService.TransactionExecutionException e) { LOGGER.error("Error happened during credential creation: ", e); throw new InternalServerErrorException(e); } }