Class NamedViewCache
- java.lang.Object
-
- uk.gov.gchq.gaffer.cache.Cache<String,NamedViewDetail>
-
- uk.gov.gchq.gaffer.store.operation.handler.named.cache.NamedViewCache
-
public class NamedViewCache extends Cache<String,NamedViewDetail>
Wrapper around theCacheServiceLoaderto provide an interface for handling theNamedViews for a Gaffer graph.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCACHE_SERVICE_NAME_PREFIXstatic StringNAMED_VIEW_CACHE_SERVICE_NAME
-
Constructor Summary
Constructors Constructor Description NamedViewCache(String suffixNamedViewCacheName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNamedView(NamedViewDetail namedViewDetail, boolean overwrite)Adds the suppliedNamedViewDetailto the cache.voidaddNamedView(NamedViewDetail namedViewDetail, boolean overwrite, User user, String adminAuth)Adds the suppliedNamedViewDetailto the cache.voidaddToCache(NamedViewDetail namedView, boolean overwrite)Add the specifiedNamedViewDetailto the cachevoiddeleteNamedView(String name, User user)Removes the specifiedNamedViewDetailfrom the cache.voiddeleteNamedView(String name, User user, String adminAuth)Removes the specifiedNamedViewDetailfrom the cache.Iterable<NamedViewDetail>getAllNamedViews(User user)Gets all theNamedViewDetails from the cache for a user.Iterable<NamedViewDetail>getAllNamedViews(User user, String adminAuth)Gets all theNamedViewDetails from the cache for a user.static StringgetCacheNameFrom(String suffixNamedViewCacheName)NamedViewDetailgetFromCache(String name)Get theNamedViewDetailrelated to the specified name from cacheNamedViewDetailgetNamedView(String name, User user)Gets the specifiedNamedViewDetailfrom the cache.NamedViewDetailgetNamedView(String name, User user, String adminAuth)Gets the specifiedNamedViewDetailfrom the cache.StringgetSuffixCacheName()-
Methods inherited from class uk.gov.gchq.gaffer.cache.Cache
clearCache, contains, deleteFromCache, getAllKeys, getCache, getCacheName, getCacheNameFrom, getSuffixCacheNameWithoutPrefix
-
-
-
-
Field Detail
-
CACHE_SERVICE_NAME_PREFIX
public static final String CACHE_SERVICE_NAME_PREFIX
- See Also:
- Constant Field Values
-
NAMED_VIEW_CACHE_SERVICE_NAME
public static final String NAMED_VIEW_CACHE_SERVICE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NamedViewCache
public NamedViewCache(String suffixNamedViewCacheName)
-
-
Method Detail
-
getSuffixCacheName
public String getSuffixCacheName()
-
addNamedView
public void addNamedView(NamedViewDetail namedViewDetail, boolean overwrite) throws CacheOperationException
Adds the suppliedNamedViewDetailto the cache. If the overwrite flag is set to false, and theNamedViewDetailalready exists, the Exception thrown will include an overwrite message. Otherwise, theNamedViewDetailwith the same name will simply be overwritten. If it turns out the user is overwriting a non-existentNamedViewDetail, then theNamedViewDetailwill be added normally.- Parameters:
namedViewDetail- TheNamedViewDetailto storeoverwrite- Flag relating to whether the user is adding (false) or updating/overwriting (true).- Throws:
CacheOperationException- if the add operation fails.
-
deleteNamedView
public void deleteNamedView(String name, User user) throws CacheOperationException
Removes the specifiedNamedViewDetailfrom the cache.- Parameters:
name-NamedViewDetailname to deleteuser- AUserobject that can optionally be used for checking permissions- Throws:
CacheOperationException- Thrown when the NamedViewDetail doesn't exist or the User doesn't have write permission on the NamedViewDetail
-
getNamedView
public NamedViewDetail getNamedView(String name, User user) throws CacheOperationException
Gets the specifiedNamedViewDetailfrom the cache.- Parameters:
name-NamedViewDetailname to getuser-Useruser requesting view- Returns:
- namedView
NamedViewDetailof specified name - Throws:
CacheOperationException- if the get operation fails
-
getNamedView
public NamedViewDetail getNamedView(String name, User user, String adminAuth) throws CacheOperationException
Gets the specifiedNamedViewDetailfrom the cache.- Parameters:
name-NamedViewDetailname to getuser-Useruser requesting viewadminAuth- admin auths- Returns:
- namedView
NamedViewDetailof specified name - Throws:
CacheOperationException- if the get operation fails
-
getAllNamedViews
public Iterable<NamedViewDetail> getAllNamedViews(User user) throws CacheOperationException
Gets all theNamedViewDetails from the cache for a user.- Parameters:
user-Useruser requesting views- Returns:
- a
Iterablecontaining all of theNamedViewDetails in the cache - Throws:
CacheOperationException- if the get operation fails
-
getAllNamedViews
public Iterable<NamedViewDetail> getAllNamedViews(User user, String adminAuth) throws CacheOperationException
Gets all theNamedViewDetails from the cache for a user.- Parameters:
user-Useruser requesting viewsadminAuth- admin auths- Returns:
- a
Iterablecontaining all of theNamedViewDetails in the cache - Throws:
CacheOperationException- if the get operation fails
-
addToCache
public void addToCache(NamedViewDetail namedView, boolean overwrite) throws CacheOperationException
Add the specifiedNamedViewDetailto the cache- Parameters:
namedView- theNamedViewDetailto add to the cacheoverwrite- if true, overwrite any existing entry which matches theNamedViewDetailname- Throws:
CacheOperationException- if the add operation fails
-
getFromCache
public NamedViewDetail getFromCache(String name) throws CacheOperationException
Get theNamedViewDetailrelated to the specified name from cache- Overrides:
getFromCachein classCache<String,NamedViewDetail>- Parameters:
name- the name of theNamedViewDetailto return- Returns:
- the
NamedViewDetail - Throws:
CacheOperationException- if the get operation fails, or the name does not exist in cache
-
addNamedView
public void addNamedView(NamedViewDetail namedViewDetail, boolean overwrite, User user, String adminAuth) throws CacheOperationException
Adds the suppliedNamedViewDetailto the cache. If the overwrite flag is set to false, and theNamedViewDetailalready exists, the Exception thrown will include an overwrite message. Otherwise, theNamedViewDetailwith the same name will simply be overwritten. If it turns out the user is overwriting a non-existentNamedViewDetail, then theNamedViewDetailwill be added normally.- Parameters:
namedViewDetail- TheNamedViewDetailto storeoverwrite- Flag relating to whether the user is adding (false) or updating/overwriting (true).user- The user making the request.adminAuth- The admin auth supplied for permissions.- Throws:
CacheOperationException- if the add operation fails.
-
deleteNamedView
public void deleteNamedView(String name, User user, String adminAuth) throws CacheOperationException
Removes the specifiedNamedViewDetailfrom the cache.- Parameters:
name-NamedViewDetailname to deleteuser- AUserobject that can optionally be used for checking permissionsadminAuth- The admin auth supplied for permissions.- Throws:
CacheOperationException- Thrown when the NamedViewDetail doesn't exist or the User doesn't have write permission on the NamedViewDetail
-
-