This is an automated email from the ASF dual-hosted git repository.

yasith pushed a commit to branch worktree-cleanup+lean-core
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit 641abb48dca7b8ac34fc86fb5cbd9dbe5b7c576d
Author: yasithdev <[email protected]>
AuthorDate: Mon Mar 30 07:37:29 2026 -0400

    cleanup: remove @Deprecated from credential summary methods, refactor 
implementations
    
    - Remove @Deprecated annotations from getAllCredentialSummaryForGateway,
      getAllCredentialSummaryForUserInGateway, and 
getAllPWDCredentialsForGateway
    - Fix getAllCredentialSummaryForUserInGateway: was scanning all credentials
      globally instead of per-gateway (correctness bug)
    - Refactor all three methods to reuse existing isSSHCredential,
      isPasswordCredential, and convertToCredentialSummary helpers
    - Return Collections.emptyList() instead of null for unsupported types
    - Remove unused sshKeyMap local variables
    
    No replacement API exists for the "get all without token filter" use case;
    these methods remain as valid implementations of 
CredentialStoreService.Iface.
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
---
 .../handler/CredentialStoreServerHandler.java      | 55 +++++-----------------
 1 file changed, 13 insertions(+), 42 deletions(-)

diff --git 
a/airavata-api/src/main/java/org/apache/airavata/credential/handler/CredentialStoreServerHandler.java
 
b/airavata-api/src/main/java/org/apache/airavata/credential/handler/CredentialStoreServerHandler.java
index 6ce03b7b34..c1e4a4b2cc 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/credential/handler/CredentialStoreServerHandler.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/credential/handler/CredentialStoreServerHandler.java
@@ -405,28 +405,17 @@ public class CredentialStoreServerHandler implements 
CredentialStoreService.Ifac
     }
 
     @Override
-    @Deprecated
     public List<CredentialSummary> 
getAllCredentialSummaryForGateway(SummaryType type, String gatewayId)
             throws 
org.apache.airavata.credential.store.exception.CredentialStoreException, 
TException {
         if (type.equals(SummaryType.SSH)) {
-            Map<String, String> sshKeyMap = new HashMap<>();
             List<CredentialSummary> summaryList = new ArrayList<>();
             try {
                 List<Credential> allCredentials = 
credentialReader.getAllCredentialsPerGateway(gatewayId);
                 if (allCredentials != null && !allCredentials.isEmpty()) {
                     for (Credential credential : allCredentials) {
-                        if (credential instanceof 
org.apache.airavata.credential.model.SSHCredential
-                                && !(credential instanceof 
org.apache.airavata.credential.model.PasswordCredential)) {
-                            org.apache.airavata.credential.model.SSHCredential 
sshCredential =
-                                    
(org.apache.airavata.credential.model.SSHCredential) credential;
-                            CredentialSummary sshCredentialSummary = new 
CredentialSummary();
-                            sshCredentialSummary.setType(SummaryType.SSH);
-                            
sshCredentialSummary.setToken(sshCredential.getToken());
-                            
sshCredentialSummary.setUsername(sshCredential.getPortalUserName());
-                            
sshCredentialSummary.setGatewayId(sshCredential.getGateway());
-                            
sshCredentialSummary.setDescription(sshCredential.getDescription());
-                            sshCredentialSummary.setPublicKey(new 
String(sshCredential.getPublicKey()));
-                            summaryList.add(sshCredentialSummary);
+                        if (isSSHCredential(credential)) {
+                            summaryList.add(convertToCredentialSummary(
+                                    
(org.apache.airavata.credential.model.SSHCredential) credential));
                         }
                     }
                 }
@@ -437,43 +426,26 @@ public class CredentialStoreServerHandler implements 
CredentialStoreService.Ifac
             }
             return summaryList;
         } else {
-            log.info("Summay Type" + type.toString() + " not supported for 
gateway id - " + gatewayId);
-            return null;
+            log.info("Summary type " + type + " not supported for gateway id - 
" + gatewayId);
+            return Collections.emptyList();
         }
     }
 
     @Override
-    @Deprecated
     public List<CredentialSummary> getAllCredentialSummaryForUserInGateway(
             SummaryType type, String gatewayId, String userId)
             throws 
org.apache.airavata.credential.store.exception.CredentialStoreException, 
TException {
         if (type.equals(SummaryType.SSH)) {
-            Map<String, String> sshKeyMap = new HashMap<>();
             List<CredentialSummary> summaryList = new ArrayList<>();
             try {
-                List<Credential> allCredentials = 
credentialReader.getAllCredentials();
+                List<Credential> allCredentials = 
credentialReader.getAllCredentialsPerGateway(gatewayId);
                 if (allCredentials != null && !allCredentials.isEmpty()) {
                     for (Credential credential : allCredentials) {
-                        if (credential instanceof 
org.apache.airavata.credential.model.SSHCredential
-                                && !(credential instanceof 
org.apache.airavata.credential.model.PasswordCredential)) {
+                        if (isSSHCredential(credential)) {
                             org.apache.airavata.credential.model.SSHCredential 
sshCredential =
                                     
(org.apache.airavata.credential.model.SSHCredential) credential;
-                            String portalUserName = 
sshCredential.getPortalUserName();
-                            String gateway = sshCredential.getGateway();
-                            if (portalUserName != null && gateway != null) {
-                                if (portalUserName.equals(userId)
-                                        && gateway.equals(gatewayId)) {
-                                    
org.apache.airavata.credential.model.SSHCredential sshCredentialKey =
-                                            
(org.apache.airavata.credential.model.SSHCredential) credential;
-                                    CredentialSummary sshCredentialSummary = 
new CredentialSummary();
-                                    
sshCredentialSummary.setType(SummaryType.SSH);
-                                    
sshCredentialSummary.setToken(sshCredentialKey.getToken());
-                                    
sshCredentialSummary.setUsername(sshCredentialKey.getPortalUserName());
-                                    
sshCredentialSummary.setGatewayId(sshCredentialKey.getGateway());
-                                    
sshCredentialSummary.setDescription(sshCredentialKey.getDescription());
-                                    sshCredentialSummary.setPublicKey(new 
String(sshCredentialKey.getPublicKey()));
-                                    summaryList.add(sshCredentialSummary);
-                                }
+                            if 
(userId.equals(sshCredential.getPortalUserName())) {
+                                
summaryList.add(convertToCredentialSummary(sshCredential));
                             }
                         }
                     }
@@ -485,14 +457,13 @@ public class CredentialStoreServerHandler implements 
CredentialStoreService.Ifac
             }
             return summaryList;
         } else {
-            log.info("Summay Type" + type.toString() + " not supported for 
user Id - " + userId + " and "
-                    + "gateway id - " + gatewayId);
-            return null;
+            log.info("Summary type " + type + " not supported for user id - " 
+ userId + " and gateway id - "
+                    + gatewayId);
+            return Collections.emptyList();
         }
     }
 
     @Override
-    @Deprecated
     public Map<String, String> getAllPWDCredentialsForGateway(String gatewayId)
             throws 
org.apache.airavata.credential.store.exception.CredentialStoreException, 
TException {
         Map<String, String> pwdCredMap = new HashMap<>();
@@ -500,7 +471,7 @@ public class CredentialStoreServerHandler implements 
CredentialStoreService.Ifac
             List<Credential> allCredentials = 
credentialReader.getAllCredentialsPerGateway(gatewayId);
             if (allCredentials != null && !allCredentials.isEmpty()) {
                 for (Credential credential : allCredentials) {
-                    if (credential instanceof 
org.apache.airavata.credential.model.PasswordCredential) {
+                    if (isPasswordCredential(credential)) {
                         
org.apache.airavata.credential.model.PasswordCredential pwdCredential =
                                 
(org.apache.airavata.credential.model.PasswordCredential) credential;
                         pwdCredMap.put(

Reply via email to