Class NamedOperationCache
- java.lang.Object
-
- uk.gov.gchq.gaffer.cache.Cache<String,NamedOperationDetail>
-
- uk.gov.gchq.gaffer.store.operation.handler.named.cache.NamedOperationCache
-
public class NamedOperationCache extends Cache<String,NamedOperationDetail>
Wrapper around theCacheServiceLoader
to provide an interface for handling theNamedOperation
s for a Gaffer graph.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CACHE_SERVICE_NAME_PREFIX
static String
NAMED_OPERATION_CACHE_SERVICE_NAME
static String
NAMED_OPERATION_CACHE_WAS_MADE_WITH_NULL_OR_EMPTY_SUFFIX
-
Constructor Summary
Constructors Constructor Description NamedOperationCache(String suffixNamedOperationCacheName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNamedOperation(NamedOperationDetail namedOperation, boolean overwrite, User user)
If the user is just adding to the cache, ie the overwrite flag is set to false, then no security is added.void
addNamedOperation(NamedOperationDetail namedOperation, boolean overwrite, User user, String adminAuth)
If the user is just adding to the cache, ie the overwrite flag is set to false, then no security is added.void
deleteNamedOperation(String name, User user)
Checks whether aUser
has write access to the cache.void
deleteNamedOperation(String name, User user, String adminAuth)
Checks whether aUser
has write access to the cache.Iterable<NamedOperationDetail>
getAllNamedOperations(User user)
Get all the named operations held in the cache.Iterable<NamedOperationDetail>
getAllNamedOperations(User user, String adminAuth)
Get all the named operations held in the cache.static String
getCacheNameFrom(String suffixNamedOperationCacheName)
NamedOperationDetail
getFromCache(String name)
Retrieve the specified named operation from the cache.NamedOperationDetail
getNamedOperation(String name, User user)
First gets the NamedOperationDetail in question and checks whether the user has read access before returning the value.NamedOperationDetail
getNamedOperation(String name, User user, String adminAuth)
First gets the NamedOperationDetail in question and checks whether the user has read access before returning the value.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_OPERATION_CACHE_WAS_MADE_WITH_NULL_OR_EMPTY_SUFFIX
public static final String NAMED_OPERATION_CACHE_WAS_MADE_WITH_NULL_OR_EMPTY_SUFFIX
- See Also:
- Constant Field Values
-
NAMED_OPERATION_CACHE_SERVICE_NAME
public static final String NAMED_OPERATION_CACHE_SERVICE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NamedOperationCache
public NamedOperationCache(String suffixNamedOperationCacheName)
-
-
Method Detail
-
getSuffixCacheName
public String getSuffixCacheName()
-
addNamedOperation
public void addNamedOperation(NamedOperationDetail namedOperation, boolean overwrite, User user) throws CacheOperationException
If the user is just adding to the cache, ie the overwrite flag is set to false, then no security is added. However if the user is overwriting the named operation stored in the cache, then their opAuths must be checked against the write roles associated with theNamedOperationDetail
. If it turns out the user is overwriting a non-existent NamedOperationDetail, then the users NamedOperationDetail will be added normally.- Parameters:
namedOperation
- The NamedOperationDetail that the user wants to store.overwrite
- Flag relating to whether the user is adding (false) or updating/overwriting (true).user
- The user making the request.- Throws:
CacheOperationException
- thrown if the user doesn't have write access to the NamedOperationDetail requested, or if the add operation fails for some reason.
-
deleteNamedOperation
public void deleteNamedOperation(String name, User user) throws CacheOperationException
Checks whether aUser
has write access to the cache. If they do then the NamedOperationDetail and name is removed from the cache. If they don't or the NamedOperationDetail doesn't exist then an Exception is thrown.- Parameters:
name
- The name of the NamedOperationDetail a user would like to delete.user
- AUser
object that can optionally be used for checking permissions.- Throws:
CacheOperationException
- Thrown when the NamedOperationDetail doesn't exist or the User doesn't have write permission on the NamedOperationDetail.
-
getNamedOperation
public NamedOperationDetail getNamedOperation(String name, User user) throws CacheOperationException
First gets the NamedOperationDetail in question and checks whether the user has read access before returning the value. If the NamedOperationDetail doesn't exist or the User doesn't have permission to read this NamedOperationDetail, then an exception is thrown.- Parameters:
name
- The name of the NamedOperationDetail held in the cache.user
- TheUser
object that is used for checking read permissions.- Returns:
- NamedOperationDetail.
- Throws:
CacheOperationException
- thrown if the NamedOperationDetail doesn't exist or the User doesn't have permission to read it.
-
getAllNamedOperations
public Iterable<NamedOperationDetail> getAllNamedOperations(User user)
Get all the named operations held in the cache.
-
getFromCache
public NamedOperationDetail getFromCache(String name) throws CacheOperationException
Retrieve the specified named operation from the cache.- Overrides:
getFromCache
in classCache<String,NamedOperationDetail>
- Parameters:
name
- the name of the named operation to retrieve- Returns:
- the details of the requested named operation
- Throws:
CacheOperationException
- if there was an error accessing the cache
-
addNamedOperation
public void addNamedOperation(NamedOperationDetail namedOperation, boolean overwrite, User user, String adminAuth) throws CacheOperationException
If the user is just adding to the cache, ie the overwrite flag is set to false, then no security is added. However if the user is overwriting the named operation stored in the cache, then their opAuths must be checked against the write roles associated with theNamedOperationDetail
. If it turns out the user is overwriting a non-existent NamedOperationDetail, then the users NamedOperationDetail will be added normally.- Parameters:
namedOperation
- The NamedOperationDetail that the user wants to store.overwrite
- 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
- thrown if the user doesn't have write access to the NamedOperationDetail requested, or if the add operation fails for some reason.
-
deleteNamedOperation
public void deleteNamedOperation(String name, User user, String adminAuth) throws CacheOperationException
Checks whether aUser
has write access to the cache. If they do then the NamedOperationDetail and name is removed from the cache. If they don't or the NamedOperationDetail doesn't exist then an Exception is thrown.- Parameters:
name
- The name of the NamedOperationDetail a user would like to delete.user
- AUser
object that can optionally be used for checking permissions.adminAuth
- The admin auth supplied for permissions.- Throws:
CacheOperationException
- Thrown when the NamedOperationDetail doesn't exist or the User doesn't have write permission on the NamedOperationDetail.
-
getNamedOperation
public NamedOperationDetail getNamedOperation(String name, User user, String adminAuth) throws CacheOperationException
First gets the NamedOperationDetail in question and checks whether the user has read access before returning the value. If the NamedOperationDetail doesn't exist or the User doesn't have permission to read this NamedOperationDetail, then an exception is thrown.- Parameters:
name
- The name of the NamedOperationDetail held in the cache.user
- TheUser
object that is used for checking read permissions.adminAuth
- The admin auth supplied for permissions.- Returns:
- NamedOperationDetail.
- Throws:
CacheOperationException
- thrown if the NamedOperationDetail doesn't exist or the User doesn't have permission to read it.
-
getAllNamedOperations
public Iterable<NamedOperationDetail> getAllNamedOperations(User user, String adminAuth)
Get all the named operations held in the cache.
-
-