diff --git a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/CkanUtilsFactory.java b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/CkanUtilsFactory.java index 2a947f7..8171f9b 100644 --- a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/CkanUtilsFactory.java +++ b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/CkanUtilsFactory.java @@ -16,6 +16,12 @@ public class CkanUtilsFactory { private static CkanUtilsFactory instance = new CkanUtilsFactory(); private static ConcurrentHashMap cache; + /** + * Private constructor for the hashmap's object values + * @author Costantino Perciante at ISTI-CNR + * (costantino.perciante@isti.cnr.it) + * + */ private class CacheBean{ CKanUtilsImpl utils; long ttl; @@ -26,6 +32,9 @@ public class CkanUtilsFactory { } } + /** + * Private constructor + */ private CkanUtilsFactory(){ logger.debug("Ckan factory object build"); @@ -42,6 +51,12 @@ public class CkanUtilsFactory { return instance; } + /** + * Retrieve the ckan utils information for the given scope + * @param scope + * @return + * @throws Exception + */ public CKanUtilsImpl getUtilsPerScope(String scope) throws Exception{ if(scope == null || scope.isEmpty()) throw new IllegalArgumentException("Invalid scope given!"); @@ -57,6 +72,11 @@ public class CkanUtilsFactory { } } + /** + * Check if the ckan information must be retrieved again. + * @param cacheBean + * @return + */ private boolean expired(CacheBean cacheBean) { boolean expired = (cacheBean.ttl + MAX_LIFETIME <= System.currentTimeMillis()); logger.debug("expired is " + expired);