fivetran-arunsuri commented on code in PR #2197: URL: https://github.com/apache/polaris/pull/2197#discussion_r2294918316
########## polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java: ########## @@ -892,6 +892,45 @@ private void revokeGrantRecord( : new PrincipalSecretsResult(secrets); } + @Override + public @Nonnull PrincipalSecretsResult resetPrincipalSecrets( + @Nonnull PolarisCallContext callCtx, + @Nonnull String clientId, + long principalId, + @Nonnull String oldSecretHash, + String customClientId, + String customClientSecret) { + // get metastore we should be using + BasePersistence ms = callCtx.getMetaStore(); + + // if not found, the principal must have been dropped + EntityResult loadEntityResult = + loadEntity( + callCtx, PolarisEntityConstants.getNullId(), principalId, PolarisEntityType.PRINCIPAL); + if (loadEntityResult.getReturnStatus() != BaseResult.ReturnStatus.SUCCESS) { + return new PrincipalSecretsResult(BaseResult.ReturnStatus.ENTITY_NOT_FOUND, null); + } + + PolarisBaseEntity principal = loadEntityResult.getEntity(); + PolarisPrincipalSecrets secrets = + ((IntegrationPersistence) ms) + .resetPrincipalSecrets( + callCtx, clientId, principalId, customClientId, customClientSecret); + + PolarisBaseEntity.Builder principalBuilder = new PolarisBaseEntity.Builder(principal); + var newEntityVersion = + (customClientId != null) ? principal.getEntityVersion() : principal.getEntityVersion() + 1; + + principalBuilder.entityVersion(newEntityVersion); + // Only write if version changed + if (customClientId == null) { + ms.writeEntity(callCtx, principalBuilder.build(), true, principal); Review Comment: That said, you raise a fair point — if the only intent is to reflect the version bump, maybe there’s a lighter approach than writing back the full PolarisBaseEntity -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org