Class SecuredNamedQueryManager
- java.lang.Object
-
- com.inductiveautomation.ignition.common.db.namedquery.SecuredNamedQueryManager
-
- All Implemented Interfaces:
NamedQueryManager
public class SecuredNamedQueryManager extends java.lang.Object implements NamedQueryManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSecuredNamedQueryManager.RolesAndZonesSnapshot
-
Constructor Summary
Constructors Constructor Description SecuredNamedQueryManager(NamedQueryManager gatewayQueryManager, java.util.function.Supplier<SecuredNamedQueryManager.RolesAndZonesSnapshot> rolesAndZonesSnapshotSupplier)SecuredNamedQueryManager(NamedQueryManager gatewayQueryManager, java.util.function.Supplier<java.util.Collection<java.lang.String>> zones, java.util.function.Supplier<java.util.Collection<java.lang.String>> roles)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringbeginTransaction(java.lang.String project, java.lang.String datasource, int isolationLevel, long timeout)Registers a transaction, but does not actually begin it until a query is invoked in that transaction.voidclearAllCaches(java.lang.String project)Clears all Named Query caches for this project.voidclearCache(java.lang.String project, java.util.Set<java.lang.String> queryPaths)Clears the named query caches of the passed paths to the named queries.java.lang.Objectexecute(java.lang.String project, NamedQuery query, java.util.Map<java.lang.String,java.lang.Object> parameters, boolean canCache, boolean canLimit, java.lang.String tx, boolean getKey)Executes a named query that exists on the providedqueryPath.java.lang.Objectexecute(java.lang.String project, java.lang.String queryPath, java.util.Map<java.lang.String,java.lang.Object> parameters, boolean canCache, boolean canLimit, java.lang.String tx, boolean getKey)Executes a named query that exists on the providedqueryPath.booleanexecuteSFquery(java.lang.String project, java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> parameters)Executes an update query that exists on the providedqueryPaththrough the Store & Forward system.NamedQuerygetQueryFromPath(java.lang.String project, java.lang.String queryPath)Returns the CachedNamedQuerybased on the providedqueryPath.SecuredNamedQueryManager.RolesAndZonesSnapshotgetRolesAndZonesSnapshot()
-
-
-
Constructor Detail
-
SecuredNamedQueryManager
public SecuredNamedQueryManager(NamedQueryManager gatewayQueryManager, java.util.function.Supplier<SecuredNamedQueryManager.RolesAndZonesSnapshot> rolesAndZonesSnapshotSupplier)
-
SecuredNamedQueryManager
public SecuredNamedQueryManager(NamedQueryManager gatewayQueryManager, java.util.function.Supplier<java.util.Collection<java.lang.String>> zones, java.util.function.Supplier<java.util.Collection<java.lang.String>> roles)
-
-
Method Detail
-
beginTransaction
public java.lang.String beginTransaction(java.lang.String project, java.lang.String datasource, int isolationLevel, long timeout) throws java.lang.ExceptionDescription copied from interface:NamedQueryManagerRegisters a transaction, but does not actually begin it until a query is invoked in that transaction. This lets us have a beginTransaction without client protection that doesn't risk getting our connection pool clobbered. Returns null if project does not exist or has not started up.- Specified by:
beginTransactionin interfaceNamedQueryManager- Throws:
java.lang.Exception
-
execute
public java.lang.Object execute(java.lang.String project, java.lang.String queryPath, java.util.Map<java.lang.String,java.lang.Object> parameters, boolean canCache, boolean canLimit, java.lang.String tx, boolean getKey) throws java.lang.ExceptionDescription copied from interface:NamedQueryManagerExecutes a named query that exists on the providedqueryPath. If the Named Query has parameters, values for each parameter should be supplied in theparametersmap that conform to their data type. If the Named Query cannot be found at the supplied path, the required parameters aren't present, or their types are incorrect an Exception is thrown.- Specified by:
executein interfaceNamedQueryManagerqueryPath- The path to the Named Query. Must not be nullparameters- A parameter map for the named query. Keys being the parameter name and values their corresponding value. Must not be nullcanCache- If true, will cache if the query config is set to cachecanLimit- If true, will limit the results if the query config is set to limittx- If this field is not blank, will make this query part of a transactiongetKey- If update query, will return new PK if true otherwise returns number of rows affected.- Returns:
- Object of query results. May be null
- Throws:
java.lang.Exception- If query not found or query generates an exception
-
execute
public java.lang.Object execute(java.lang.String project, NamedQuery query, java.util.Map<java.lang.String,java.lang.Object> parameters, boolean canCache, boolean canLimit, java.lang.String tx, boolean getKey) throws java.lang.ExceptionDescription copied from interface:NamedQueryManagerExecutes a named query that exists on the providedqueryPath. If the Named Query has parameters, values for each parameter should be supplied in theparametersmap that conform to their data type. If the Named Query cannot be found at the supplied path, the required parameters aren't present, or their types are incorrect an Exception is thrown.- Specified by:
executein interfaceNamedQueryManager- Parameters:
project- The name of the effective project the named queries whose cache you wish to clear reside in.query- The NamedQuery to execute. Must not be nullparameters- A parameter map for the named query. Keys being the parameter name and values their corresponding value. Must not be nullcanCache- If true, will cache if the query config is set to cachecanLimit- If true, will limit the results if the query config is set to limit- Returns:
- Object of query results. May be null
- Throws:
java.lang.Exception- If query not found or query generates an exception
-
executeSFquery
public boolean executeSFquery(java.lang.String project, java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> parameters) throws java.lang.ExceptionDescription copied from interface:NamedQueryManagerExecutes an update query that exists on the providedqueryPaththrough the Store & Forward system. If the Named Query cannot be found at the supplied path, the required parameters aren't present, or their types are incorrect an Exception is thrown.- Specified by:
executeSFqueryin interfaceNamedQueryManager- Parameters:
project- Project the query resides in. Not empty or null.path- Path to the query resource. Not empty or null.parameters- A parameter map for the named query. Keys being the parameter name and values their corresponding value. Must not be null- Returns:
- True if successfully sent to store and forward system.
- Throws:
java.lang.Exception- If required values are empty or don't exist, or if query is not an Update query.
-
getQueryFromPath
@Nullable public NamedQuery getQueryFromPath(java.lang.String project, java.lang.String queryPath) throws java.lang.Exception
Description copied from interface:NamedQueryManagerReturns the CachedNamedQuerybased on the providedqueryPath. Useful for checking permissions.- Specified by:
getQueryFromPathin interfaceNamedQueryManagerqueryPath- Path to Named Query resource- Returns:
- NamedQuery resource or null if not found.
- Throws:
java.lang.Exception- If query or the project are not found
-
clearCache
public void clearCache(java.lang.String project, java.util.Set<java.lang.String> queryPaths) throws java.lang.ExceptionDescription copied from interface:NamedQueryManagerClears the named query caches of the passed paths to the named queries.- Specified by:
clearCachein interfaceNamedQueryManager- Parameters:
project- the name of the effective project the named queries whose cache you wish to clear reside in.queryPaths- a set of paths to the named queries that we want to clear. Must not be null.- Throws:
java.lang.Exception- If query or the project are not found
-
clearAllCaches
public void clearAllCaches(java.lang.String project) throws java.lang.ExceptionDescription copied from interface:NamedQueryManagerClears all Named Query caches for this project.- Specified by:
clearAllCachesin interfaceNamedQueryManager- Parameters:
project- The name of the effective project whose named queries' cache you wish to clear.- Throws:
java.lang.Exception- If the project is not found
-
getRolesAndZonesSnapshot
public SecuredNamedQueryManager.RolesAndZonesSnapshot getRolesAndZonesSnapshot()
- Returns:
- The current RolesAndZonesSnapshot that goven the permissions of running queries via this query manager. Note that this snapshot may change if the web auth status changes.
-
-