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 theCacheServiceLoader
to provide an interface for handling theNamedView
s for a Gaffer graph.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CACHE_SERVICE_NAME_PREFIX
static String
NAMED_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 void
addNamedView(NamedViewDetail namedViewDetail, boolean overwrite)
Adds the suppliedNamedViewDetail
to the cache.void
addNamedView(NamedViewDetail namedViewDetail, boolean overwrite, User user, String adminAuth)
Adds the suppliedNamedViewDetail
to the cache.void
addToCache(NamedViewDetail namedView, boolean overwrite)
Add the specifiedNamedViewDetail
to the cachevoid
deleteNamedView(String name, User user)
Removes the specifiedNamedViewDetail
from the cache.void
deleteNamedView(String name, User user, String adminAuth)
Removes the specifiedNamedViewDetail
from the cache.Iterable<NamedViewDetail>
getAllNamedViews(User user)
Gets all theNamedViewDetail
s from the cache for a user.Iterable<NamedViewDetail>
getAllNamedViews(User user, String adminAuth)
Gets all theNamedViewDetail
s from the cache for a user.static String
getCacheNameFrom(String suffixNamedViewCacheName)
NamedViewDetail
getFromCache(String name)
Get theNamedViewDetail
related to the specified name from cacheNamedViewDetail
getNamedView(String name, User user)
Gets the specifiedNamedViewDetail
from the cache.NamedViewDetail
getNamedView(String name, User user, String adminAuth)
Gets the specifiedNamedViewDetail
from the cache.String
getSuffixCacheName()
-
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 suppliedNamedViewDetail
to the cache. If the overwrite flag is set to false, and theNamedViewDetail
already exists, the Exception thrown will include an overwrite message. Otherwise, theNamedViewDetail
with the same name will simply be overwritten. If it turns out the user is overwriting a non-existentNamedViewDetail
, then theNamedViewDetail
will be added normally.- Parameters:
namedViewDetail
- TheNamedViewDetail
to 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 specifiedNamedViewDetail
from the cache.- Parameters:
name
-NamedViewDetail
name to deleteuser
- AUser
object 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 specifiedNamedViewDetail
from the cache.- Parameters:
name
-NamedViewDetail
name to getuser
-User
user requesting view- Returns:
- namedView
NamedViewDetail
of specified name - Throws:
CacheOperationException
- if the get operation fails
-
getNamedView
public NamedViewDetail getNamedView(String name, User user, String adminAuth) throws CacheOperationException
Gets the specifiedNamedViewDetail
from the cache.- Parameters:
name
-NamedViewDetail
name to getuser
-User
user requesting viewadminAuth
- admin auths- Returns:
- namedView
NamedViewDetail
of specified name - Throws:
CacheOperationException
- if the get operation fails
-
getAllNamedViews
public Iterable<NamedViewDetail> getAllNamedViews(User user) throws CacheOperationException
Gets all theNamedViewDetail
s from the cache for a user.- Parameters:
user
-User
user requesting views- Returns:
- a
Iterable
containing all of theNamedViewDetail
s in the cache - Throws:
CacheOperationException
- if the get operation fails
-
getAllNamedViews
public Iterable<NamedViewDetail> getAllNamedViews(User user, String adminAuth) throws CacheOperationException
Gets all theNamedViewDetail
s from the cache for a user.- Parameters:
user
-User
user requesting viewsadminAuth
- admin auths- Returns:
- a
Iterable
containing all of theNamedViewDetail
s in the cache - Throws:
CacheOperationException
- if the get operation fails
-
addToCache
public void addToCache(NamedViewDetail namedView, boolean overwrite) throws CacheOperationException
Add the specifiedNamedViewDetail
to the cache- Parameters:
namedView
- theNamedViewDetail
to add to the cacheoverwrite
- if true, overwrite any existing entry which matches theNamedViewDetail
name- Throws:
CacheOperationException
- if the add operation fails
-
getFromCache
public NamedViewDetail getFromCache(String name) throws CacheOperationException
Get theNamedViewDetail
related to the specified name from cache- Overrides:
getFromCache
in classCache<String,NamedViewDetail>
- Parameters:
name
- the name of theNamedViewDetail
to 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 suppliedNamedViewDetail
to the cache. If the overwrite flag is set to false, and theNamedViewDetail
already exists, the Exception thrown will include an overwrite message. Otherwise, theNamedViewDetail
with the same name will simply be overwritten. If it turns out the user is overwriting a non-existentNamedViewDetail
, then theNamedViewDetail
will be added normally.- Parameters:
namedViewDetail
- TheNamedViewDetail
to 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 specifiedNamedViewDetail
from the cache.- Parameters:
name
-NamedViewDetail
name to deleteuser
- AUser
object 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
-
-