diff --git a/pom.xml b/pom.xml index 2006b39..fb11db6 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId} https://code-repo.d4science.org/gCubeSystem/${project.artifactId} - + 2.7.0 6.2.5 @@ -39,7 +39,7 @@ UTF-8 UTF-8 - + localRun @@ -72,7 +72,7 @@ org.gcube.distribution maven-portal-bom - 3.6.4-SNAPSHOT + 3.7.0-SNAPSHOT pom import @@ -276,6 +276,13 @@ 3.1.7 compile + + + org.json + json + 20220320 + + diff --git a/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/RegistryClientRequester.java b/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/RegistryClientRequester.java index b0e4f53..000d55f 100644 --- a/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/RegistryClientRequester.java +++ b/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/RegistryClientRequester.java @@ -6,18 +6,13 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; import org.gcube.common.authorization.library.provider.AccessTokenProvider; import org.gcube.common.keycloak.KeycloakClient; import org.gcube.common.keycloak.KeycloakClientFactory; -import org.gcube.common.keycloak.model.AccessToken.Access; -import org.gcube.common.keycloak.model.ModelUtils; import org.gcube.common.keycloak.model.TokenResponse; import org.gcube.common.scope.api.ScopeProvider; -import org.gcube.common.scope.impl.ScopeBean; -import org.gcube.informationsystem.contexts.reference.entities.Context; import org.gcube.informationsystem.model.reference.entities.Resource; import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache; import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient; @@ -107,15 +102,17 @@ public class RegistryClientRequester { val = "GenericResource"; if (t.getName().equals("HostingNode")) val = "GHN"; - try { - if (val!=null) { - ArrayList subtrees = UtilityResource.getSubResourcesTreeQuery(resourceRegistryClient, t.getName()); - if (!subtrees.isEmpty()) - retval.put(val, subtrees); + + if (val!=null) { + ArrayList subtrees = new ArrayList(); + try { + subtrees = UtilityResource.getSubResourcesTreeQuery(resourceRegistryClient, t.getName()); + }catch (Exception e) { + e.printStackTrace(); } - }catch (Exception e) { - e.printStackTrace(); + retval.put(val, subtrees); } + } } catch (Exception e) { diff --git a/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/ServiceProxyImpl.java b/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/ServiceProxyImpl.java index a67b953..eb25c60 100644 --- a/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/ServiceProxyImpl.java +++ b/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/ServiceProxyImpl.java @@ -287,6 +287,10 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro HashMap> results = RegistryClientRequester.getResourcesTree(scope); + System.out.println("get result type tree: ("+results.size()+") /n" + + results.keySet() ); + + return results; } catch (Exception e) { ServerConsole.error(LOG_PREFIX, "applying resource get", e); diff --git a/src/main/java/org/gcube/portlets/admin/resourcemanagement/shared/resource/UtilityResource.java b/src/main/java/org/gcube/portlets/admin/resourcemanagement/shared/resource/UtilityResource.java index a59106a..b1ed7db 100644 --- a/src/main/java/org/gcube/portlets/admin/resourcemanagement/shared/resource/UtilityResource.java +++ b/src/main/java/org/gcube/portlets/admin/resourcemanagement/shared/resource/UtilityResource.java @@ -38,9 +38,9 @@ import org.gcube.resourcemanagement.model.reference.entities.resources.HostingNo import org.gcube.resourcemanagement.model.reference.relations.consistsof.HasPersistentMemory; import org.gcube.resourcemanagement.model.reference.relations.consistsof.HasVolatileMemory; import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy; +import org.json.JSONArray; +import org.json.JSONObject; -import com.google.gwt.thirdparty.json.JSONArray; -import com.google.gwt.thirdparty.json.JSONObject; @@ -50,8 +50,8 @@ import com.google.gwt.thirdparty.json.JSONObject; * */ public class UtilityResource { - - + + public static ArrayList getSubResourcesTree(ResourceRegistryClient resourceRegistryClient, String entity, String scope) throws Exception{ ArrayList list = new ArrayList<>(); @@ -132,21 +132,27 @@ public class UtilityResource { default: return new ArrayList<>(0); - + } - - - String query="SELECT DISTINCT("+field+") AS "+field+" " - + "FROM (TRAVERSE outE('IsIdentifiedBy'),inV('"+identifiedFacet+"') FROM "+entity+")"; - System.out.println("------------query----------->"+query); + try { + String query="SELECT DISTINCT("+field+") AS "+field+" " + + "FROM (TRAVERSE outE('IsIdentifiedBy'),inV('"+identifiedFacet+"') FROM "+entity+")"; - String result=resourceRegistryClient.rawQuery(query, 1000, null); - JSONObject jsonObj = new JSONObject(result); - JSONArray jsonArray=jsonObj.getJSONArray("result"); + System.out.println("------------query----------->"+query); - for(int i=0;i < jsonArray.length();i++){ - list.add(jsonArray.getJSONObject(i).getString(field)); + String result=resourceRegistryClient.rawQuery(query, 1000, null); + + if (!result.isEmpty()) { + JSONObject jsonObj = new JSONObject(result); + JSONArray jsonArray=jsonObj.getJSONArray("result"); + + for(int i=0;i < jsonArray.length();i++){ + list.add(jsonArray.getJSONObject(i).getString(field)); + } + } + }catch (Exception e) { + e.printStackTrace(); } return list;