From 4a3ff9a531d90c37f1433fa17540ff16e3635ba2 Mon Sep 17 00:00:00 2001 From: "nikolas.laskaris" Date: Thu, 6 Feb 2014 15:44:51 +0000 Subject: [PATCH] Fix for https://support.d4science.research-infrastructures.eu/ticket/769 git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerCore@90987 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../framework/core/util/GenericResource.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/gcube/application/framework/core/util/GenericResource.java b/src/main/java/org/gcube/application/framework/core/util/GenericResource.java index fe0218b..a6ea22d 100644 --- a/src/main/java/org/gcube/application/framework/core/util/GenericResource.java +++ b/src/main/java/org/gcube/application/framework/core/util/GenericResource.java @@ -142,7 +142,10 @@ public class GenericResource implements GenericResourceInfoI { */ protected List getGenericResource(QueryString query) { - return (List) (CachesManager.getInstance().getGenericResourceCache().get(query).getValue()); + List resList = (List) (CachesManager.getInstance().getGenericResourceCache().get(query).getValue()); + if(resList.isEmpty()) + logger.debug("no generic resources in cache "+query.get("name")); + return resList; } /** @@ -344,7 +347,7 @@ public class GenericResource implements GenericResourceInfoI { // } /** - * @return a list containing pairs of (name, id) of the available generic resources + * @return a list containing all generic resources * @throws RemoteException when an error has occurred while communicating with IS */ public List getAllGenericResources() throws RemoteException { @@ -462,18 +465,21 @@ public class GenericResource implements GenericResourceInfoI { query.put(CacheEntryConstants.vre, getDLName()); return getGenericResource(query); } - + + /** * @param name the name of the generic resource * @return a list containing the generic resources that have as name the given * @throws RemoteException when an error has occurred while communicating with IS */ - public List getGenericResourceByName(String name) - throws RemoteException { - QueryString query = new QueryString(); - query.put(CacheEntryConstants.name, name); - query.put(CacheEntryConstants.vre, getDLName()); - return getGenericResource(query); + public List getGenericResourceByName(String name) throws RemoteException{ + //caching is done by (id,vre) as key pairs. so we cannot use cache to retrieve objects. + List allRes = getAllGenericResources(); + List results = new ArrayList(); + for(org.gcube.common.resources.gcore.GenericResource res : allRes) + if(res.profile().name().equalsIgnoreCase(name)) + results.add(new ISGenericResource(res.id(),res.profile().name(),res.profile().description(),res.profile().bodyAsString(),res.profile().type())); + return results; }