yasithdev commented on code in PR #577:
URL: https://github.com/apache/airavata/pull/577#discussion_r2569789265
##########
airavata-api/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java:
##########
@@ -1157,50 +895,24 @@ public List<Project> getUserProjects(
AuthzToken authzToken, String gatewayId, String userName, int
limit, int offset)
throws InvalidRequestException, AiravataClientException,
AiravataSystemException, AuthorizationException,
TException {
- RegistryService.Client regClient = registryClientPool.getResource();
SharingRegistryService.Client sharingClient =
sharingClientPool.getResource();
try {
- if (ServerSettings.isEnableSharing()) {
- // user projects + user accessible projects
- List<String> accessibleProjectIds = new ArrayList<>();
- List<SearchCriteria> filters = new ArrayList<>();
- SearchCriteria searchCriteria = new SearchCriteria();
-
searchCriteria.setSearchField(EntitySearchField.ENTITY_TYPE_ID);
- searchCriteria.setSearchCondition(SearchCondition.EQUAL);
- searchCriteria.setValue(gatewayId + ":PROJECT");
- filters.add(searchCriteria);
- sharingClient
- .searchEntities(
-
authzToken.getClaimsMap().get(Constants.GATEWAY_ID),
- userName + "@" + gatewayId,
- filters,
- 0,
- -1)
- .stream()
- .forEach(p ->
accessibleProjectIds.add(p.getEntityId()));
- List<Project> result;
- if (accessibleProjectIds.isEmpty()) {
- result = Collections.emptyList();
- } else {
- result = regClient.searchProjects(
- gatewayId, userName, accessibleProjectIds, new
HashMap<>(), limit, offset);
- }
- registryClientPool.returnResource(regClient);
- sharingClientPool.returnResource(sharingClient);
- return result;
- } else {
- List<Project> result = regClient.getUserProjects(gatewayId,
userName, limit, offset);
- registryClientPool.returnResource(regClient);
- sharingClientPool.returnResource(sharingClient);
- return result;
- }
-
+ List<Project> result = airavataService.getUserProjectsWithSharing(
+ sharingClient, authzToken, gatewayId, userName, limit,
offset);
+ sharingClientPool.returnResource(sharingClient);
Review Comment:
@lahirujayathilake thanks! I fixed these. now if services call other
services, they directly call the service function instead of going through
client->server.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]