Package ubic.gemma.persistence.util
Class AclQueryUtils
- java.lang.Object
-
- ubic.gemma.persistence.util.AclQueryUtils
-
public class AclQueryUtils extends Object
Utilities for integrating ACL intoQuery.To build a query, sequentially proceed as follows:
- form your select clause and your jointures
- concatenate
formAclRestrictionClause(String)orformNativeAclJoinClause(String)in the jointure section - form where clause and add your constraints
- concatenate
formNativeAclRestrictionClause(SessionFactoryImplementor)in the clause section (only for native queries) - bind all your parameters
- bind ACL-specific parameters with
addAclParameters(Query, Class)to the query object
- Author:
- poirigui
-
-
Constructor Summary
Constructors Constructor Description AclQueryUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddAclParameters(Query query, Class<? extends gemma.gsec.model.Securable> aoiType)BindQueryparameters to a join clause generated withformAclRestrictionClause(String)and add ACL restriction parameters defined informAclRestrictionClause(String).static StringformAclRestrictionClause(String aoiIdColumn)Create an HQL join clause forAclObjectIdentity,AclGrantedAuthoritySidand a restriction clause to limit the result only to objects the currently logged user can access.static StringformNativeAclJoinClause(String aoiIdColumn)Native SQL flavour of the ACL jointure.static StringformNativeAclRestrictionClause(SessionFactoryImplementor sessionFactoryImplementor)Native flavour of the ACL restriction clause.
-
-
-
Field Detail
-
AOI_ALIAS
public static final String AOI_ALIAS
Alias used.- See Also:
- Constant Field Values
-
SID_ALIAS
public static final String SID_ALIAS
Alias used.- See Also:
- Constant Field Values
-
ACE_ALIAS
public static final String ACE_ALIAS
Alias used.- See Also:
- Constant Field Values
-
-
Method Detail
-
formAclRestrictionClause
public static String formAclRestrictionClause(String aoiIdColumn)
Create an HQL join clause forAclObjectIdentity,AclGrantedAuthoritySidand a restriction clause to limit the result only to objects the currently logged user can access.Ensure that you use
addAclParameters(Query, Class)afterward to bind the query parameters.FIXME: this ACL jointure is really annoying because it is one-to-many, maybe handling everything in a sub-query would be preferable?
- Parameters:
aoiIdColumn- column for the identifier e.g. "ee.id"- Returns:
- clause to add to the query after any jointure
-
formNativeAclJoinClause
public static String formNativeAclJoinClause(String aoiIdColumn)
Native SQL flavour of the ACL jointure.Note: unlike the HQL version, this query uses
onto restrict the jointure, so you can define thewhereclause yourself.- See Also:
formAclRestrictionClause(String)
-
formNativeAclRestrictionClause
public static String formNativeAclRestrictionClause(SessionFactoryImplementor sessionFactoryImplementor)
Native flavour of the ACL restriction clause.- See Also:
formAclRestrictionClause(String)
-
addAclParameters
public static void addAclParameters(Query query, Class<? extends gemma.gsec.model.Securable> aoiType) throws QueryParameterException
BindQueryparameters to a join clause generated withformAclRestrictionClause(String)and add ACL restriction parameters defined informAclRestrictionClause(String).This method also work for native queries formed with
formNativeAclJoinClause(String)andformNativeAclRestrictionClause(SessionFactoryImplementor).- Parameters:
query- aQueryobject that contains the join and restriction clausesaoiType- the AOI type to be bound in the query- Throws:
QueryParameterException- if any defined parameters are missing, which is typically due to a missing priorformAclRestrictionClause(String).
-
-