dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24196
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11817: force enable acl for dashboards
------------------------------------------------------------
revno: 11817
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-08-27 12:49:43 +0200
message:
force enable acl for dashboards
modified:
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2013-08-27 10:49:43 +0000
@@ -43,6 +43,7 @@
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.common.SharingUtils;
+import org.hisp.dhis.dashboard.Dashboard;
import org.hisp.dhis.hibernate.exception.CreateAccessDeniedException;
import org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException;
import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException;
@@ -192,7 +193,7 @@
* @param expressions the Criterions for the Criteria.
* @return an object of the implementation Class type.
*/
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
protected final T getObject( Criterion... expressions )
{
return (T) getCriteria( expressions ).uniqueResult();
@@ -204,7 +205,7 @@
* @param expressions the Criterions for the Criteria.
* @return a List with objects of the implementation Class type.
*/
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
protected final List<T> getList( Criterion... expressions )
{
return getCriteria( expressions ).list();
@@ -276,7 +277,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public final T get( int id )
{
T object = (T) sessionFactory.getCurrentSession().get( getClazz(), id );
@@ -291,7 +292,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public final T load( int id )
{
T object = (T) sessionFactory.getCurrentSession().load( getClazz(), id );
@@ -389,7 +390,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public final List<T> getAll()
{
Query query = sharingEnabled() ? getQueryAllAcl() : getQueryAll();
@@ -416,7 +417,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllEqName( String name )
{
Query query = sharingEnabled() ? getQueryAllEqNameAcl( name ) : getQueryAllEqName( name );
@@ -448,7 +449,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllEqNameIgnoreCase( String name )
{
Query query = sharingEnabled() ? getQueryAllEqNameAclIgnoreCase( name ) : getQueryAllEqNameIgnoreCase( name );
@@ -480,7 +481,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllEqShortName( String shortName )
{
Query query = sharingEnabled() ? getQueryAllEqShortNameAcl( shortName ) : getQueryAllEqShortName( shortName );
@@ -512,7 +513,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllEqShortNameIgnoreCase( String shortName )
{
Query query = sharingEnabled() ? getQueryAllEqShortNameAclIgnoreCase( shortName ) : getQueryAllEqShortNameIgnoreCase( shortName );
@@ -544,7 +545,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllLikeName( String name )
{
Query query = sharingEnabled() ? getQueryAllLikeNameAcl( name ) : getQueryAllLikeName( name );
@@ -576,7 +577,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllLikeShortName( String shortName )
{
if ( NameableObject.class.isAssignableFrom( clazz ) )
@@ -613,7 +614,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public final List<T> getAllOrderedName()
{
Query query = sharingEnabled() ? getQueryAllOrderedNameAcl() : getQueryAllOrderedName();
@@ -641,7 +642,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllOrderedName( int first, int max )
{
Query query = sharingEnabled() ? getQueryAllOrderedNameAcl() : getQueryAllOrderedName();
@@ -653,7 +654,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllOrderedLastUpdated( int first, int max )
{
Query query = sharingEnabled() ? getQueryAllOrderedLastUpdatedAcl() : getQueryAllOrderedLastUpdated();
@@ -684,7 +685,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllLikeNameOrderedName( String name, int first, int max )
{
Query query = sharingEnabled() ? getQueryAllLikeNameOrderedNameAcl( name ) : getQueryAllLikeNameOrderedName( name );
@@ -807,7 +808,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllGeLastUpdated( Date lastUpdated )
{
Query query = sharingEnabled() ? getQueryAllGeLastUpdatedAcl( lastUpdated ) : getQueryAllGeLastUpdated( lastUpdated );
@@ -839,7 +840,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllGeCreated( Date created )
{
Query query = sharingEnabled() ? getQueryAllGeCreatedAcl( created ) : getQueryAllGeCreated( created );
@@ -871,7 +872,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getAllGeLastUpdatedOrderedName( Date lastUpdated )
{
Query query = sharingEnabled() ? getQueryAllGeLastUpdatedOrderedNameAcl( lastUpdated ) : getQueryAllGeLastUpdatedOrderedName( lastUpdated );
@@ -903,7 +904,7 @@
}
@Override
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public List<T> getByUser( User user )
{
Query query = getQuery( "from " + clazz.getName() + " c where user = :user" );
@@ -959,10 +960,15 @@
// Helpers
//----------------------------------------------------------------------------------------------------------------
+ protected boolean forceAcl()
+ {
+ return Dashboard.class.isAssignableFrom( clazz );
+ }
+
protected boolean sharingEnabled()
{
- return SharingUtils.isSupported( clazz ) && !(currentUserService.getCurrentUser() == null ||
- CollectionUtils.containsAny( currentUserService.getCurrentUser().getUserCredentials().getAllAuthorities(), SharingUtils.SHARING_OVERRIDE_AUTHORITIES ));
+ return forceAcl() || (SharingUtils.isSupported( clazz ) && !(currentUserService.getCurrentUser() == null ||
+ CollectionUtils.containsAny( currentUserService.getCurrentUser().getUserCredentials().getAllAuthorities(), SharingUtils.SHARING_OVERRIDE_AUTHORITIES )));
}
protected boolean isReadAllowed( T object )