Class ContextCache
- java.lang.Object
-
- org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache
-
public class ContextCache extends Object
The Class ContextCache.- Author:
- Luca Frosini (ISTI - CNR)
-
-
Field Summary
Fields Modifier and Type Field Description protected ContextCacheRenewalcontextCacheRenewalThe context cache renewal.protected Map<String,UUID>contextFullNameToUUIDThe context full name to UUID.protected List<org.gcube.informationsystem.contexts.reference.entities.Context>contextsThe contexts.protected org.gcube.informationsystem.tree.Tree<org.gcube.informationsystem.contexts.reference.entities.Context>contextsTreeThe contexts tree.protected CalendarcreationTimeThe creation time.static longDEFAULT_EXPIRING_TIMEOUTThe Constant DEFAULT_EXPIRING_TIMEOUT.protected CalendarexpiringTimeThe expiring time.static intexpiringTimeoutThe expiring timeout.protected booleaninitializedThe initialized.protected static ContextCachesingletonThe singleton.protected Map<UUID,org.gcube.informationsystem.contexts.reference.entities.Context>uuidToContextThe uuid to context.protected Map<UUID,String>uuidToContextFullNameThe uuid to context full name.
-
Constructor Summary
Constructors Constructor Description ContextCache()Instantiates a new context cache.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanCache()Clean cache.protected voidcleanCache(Calendar calendar)Clean cache.org.gcube.informationsystem.contexts.reference.entities.ContextgetContextByFullName(String contextFullName)Gets the context by full name.org.gcube.informationsystem.contexts.reference.entities.ContextgetContextByUUID(String uuid)Gets the context by UUID.org.gcube.informationsystem.contexts.reference.entities.ContextgetContextByUUID(UUID uuid)Gets the context by UUID.ContextCacheRenewalgetContextCacheRenewal()Gets the context cache renewal.protected StringgetContextFullName(org.gcube.informationsystem.contexts.reference.entities.Context context)Gets the context full name.StringgetContextFullNameByUUID(String uuid)Gets the context full name by UUID.StringgetContextFullNameByUUID(UUID uuid)Gets the context full name by UUID.Map<String,UUID>getContextFullNameToUUIDAssociation()Gets the context full name to UUID association.List<org.gcube.informationsystem.contexts.reference.entities.Context>getContexts()Gets the contexts.org.gcube.informationsystem.tree.Tree<org.gcube.informationsystem.contexts.reference.entities.Context>getContextsTree()Gets the contexts tree.static ContextCachegetInstance()Gets the single instance of ContextCache.UUIDgetUUIDByFullName(String contextFullName)Gets the uuid by full name.Map<UUID,String>getUUIDToContextFullNameAssociation()Gets the UUID to context full name association.voidrefreshContextsIfNeeded()Refresh contexts if needed.voidrenew()Renew.voidsetContextCacheRenewal(ContextCacheRenewal contextCacheRenewal)Sets the context cache renewal.protected voidsetContexts(Calendar calendar, List<org.gcube.informationsystem.contexts.reference.entities.Context> contexts)Sets the contexts.voidsetContexts(List<org.gcube.informationsystem.contexts.reference.entities.Context> contexts)Sets the contexts.static voidsetExpiringTimeout(int expiringTimeout)Sets the expiring timeout.
-
-
-
Field Detail
-
DEFAULT_EXPIRING_TIMEOUT
public static final long DEFAULT_EXPIRING_TIMEOUT
The Constant DEFAULT_EXPIRING_TIMEOUT.
-
expiringTimeout
public static int expiringTimeout
The expiring timeout.
-
singleton
protected static ContextCache singleton
The singleton.
-
contextCacheRenewal
protected ContextCacheRenewal contextCacheRenewal
The context cache renewal.
-
creationTime
protected Calendar creationTime
The creation time.
-
expiringTime
protected Calendar expiringTime
The expiring time.
-
contexts
protected List<org.gcube.informationsystem.contexts.reference.entities.Context> contexts
The contexts.
-
uuidToContext
protected Map<UUID,org.gcube.informationsystem.contexts.reference.entities.Context> uuidToContext
The uuid to context.
-
uuidToContextFullName
protected Map<UUID,String> uuidToContextFullName
The uuid to context full name.
-
contextFullNameToUUID
protected Map<String,UUID> contextFullNameToUUID
The context full name to UUID.
-
contextsTree
protected org.gcube.informationsystem.tree.Tree<org.gcube.informationsystem.contexts.reference.entities.Context> contextsTree
The contexts tree.
-
initialized
protected boolean initialized
The initialized.
-
-
Method Detail
-
setExpiringTimeout
public static void setExpiringTimeout(int expiringTimeout)
Sets the expiring timeout.- Parameters:
expiringTimeout- the new expiring timeout
-
getInstance
public static ContextCache getInstance()
Gets the single instance of ContextCache.- Returns:
- single instance of ContextCache
-
cleanCache
public void cleanCache()
Clean cache.
-
cleanCache
protected void cleanCache(Calendar calendar)
Clean cache.- Parameters:
calendar- the calendar
-
renew
public void renew() throws ResourceRegistryExceptionRenew.- Throws:
ResourceRegistryException- the resource registry exception
-
getContextCacheRenewal
public ContextCacheRenewal getContextCacheRenewal()
Gets the context cache renewal.- Returns:
- the context cache renewal
-
setContextCacheRenewal
public void setContextCacheRenewal(ContextCacheRenewal contextCacheRenewal)
Sets the context cache renewal.- Parameters:
contextCacheRenewal- the new context cache renewal
-
refreshContextsIfNeeded
public void refreshContextsIfNeeded() throws ResourceRegistryExceptionRefresh contexts if needed.- Throws:
ResourceRegistryException- the resource registry exception
-
getContexts
public List<org.gcube.informationsystem.contexts.reference.entities.Context> getContexts() throws ResourceRegistryException
Gets the contexts.- Returns:
- the contexts
- Throws:
ResourceRegistryException- the resource registry exception
-
setContexts
public void setContexts(List<org.gcube.informationsystem.contexts.reference.entities.Context> contexts)
Sets the contexts.- Parameters:
contexts- the new contexts
-
setContexts
protected void setContexts(Calendar calendar, List<org.gcube.informationsystem.contexts.reference.entities.Context> contexts)
Sets the contexts.- Parameters:
calendar- the calendarcontexts- the contexts
-
getContextFullName
protected String getContextFullName(org.gcube.informationsystem.contexts.reference.entities.Context context)
Gets the context full name.- Parameters:
context- the context- Returns:
- the context full name
-
getContextFullNameByUUID
public String getContextFullNameByUUID(UUID uuid) throws ResourceRegistryException
Gets the context full name by UUID.- Parameters:
uuid- the uuid- Returns:
- the context full name by UUID
- Throws:
ResourceRegistryException- the resource registry exception
-
getContextFullNameByUUID
public String getContextFullNameByUUID(String uuid) throws ResourceRegistryException
Gets the context full name by UUID.- Parameters:
uuid- the uuid- Returns:
- the context full name by UUID
- Throws:
ResourceRegistryException- the resource registry exception
-
getUUIDByFullName
public UUID getUUIDByFullName(String contextFullName) throws ResourceRegistryException
Gets the uuid by full name.- Parameters:
contextFullName- the context full name- Returns:
- the uuid by full name
- Throws:
ResourceRegistryException- the resource registry exception
-
getContextByUUID
public org.gcube.informationsystem.contexts.reference.entities.Context getContextByUUID(UUID uuid) throws ResourceRegistryException
Gets the context by UUID.- Parameters:
uuid- the uuid- Returns:
- the context by UUID
- Throws:
ResourceRegistryException- the resource registry exception
-
getContextByUUID
public org.gcube.informationsystem.contexts.reference.entities.Context getContextByUUID(String uuid) throws ResourceRegistryException
Gets the context by UUID.- Parameters:
uuid- the uuid- Returns:
- the context by UUID
- Throws:
ResourceRegistryException- the resource registry exception
-
getContextByFullName
public org.gcube.informationsystem.contexts.reference.entities.Context getContextByFullName(String contextFullName) throws ResourceRegistryException
Gets the context by full name.- Parameters:
contextFullName- the context full name- Returns:
- the context by full name
- Throws:
ResourceRegistryException- the resource registry exception
-
getUUIDToContextFullNameAssociation
public Map<UUID,String> getUUIDToContextFullNameAssociation() throws ResourceRegistryException
Gets the UUID to context full name association.- Returns:
- an Map containing UUID to Context FullName association
- Throws:
ResourceRegistryException- the resource registry exception
-
getContextFullNameToUUIDAssociation
public Map<String,UUID> getContextFullNameToUUIDAssociation() throws ResourceRegistryException
Gets the context full name to UUID association.- Returns:
- an Map containing Context FullName to UUID association
- Throws:
ResourceRegistryException- the resource registry exception
-
getContextsTree
public org.gcube.informationsystem.tree.Tree<org.gcube.informationsystem.contexts.reference.entities.Context> getContextsTree() throws ResourceRegistryExceptionGets the contexts tree.- Returns:
- the contexts tree
- Throws:
ResourceRegistryException- the resource registry exception
-
-