=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java 2013-01-18 12:58:45 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java 2013-01-18 13:04:27 +0000 @@ -72,7 +72,12 @@ public static boolean isSupported( IdentifiableObject identifiableObject ) { - return SUPPORTED_TYPES.containsValue( identifiableObject.getClass() ); + return isSupported( identifiableObject.getClass() ); + } + + public static boolean isSupported( Class clazz ) + { + return SUPPORTED_TYPES.containsValue( clazz ); } public static Class classForType( String type ) === 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-01-18 12:58:45 +0000 +++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2013-01-18 13:04:27 +0000 @@ -30,7 +30,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Criteria; -import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.SQLQuery; import org.hibernate.SessionFactory; @@ -806,25 +805,10 @@ private boolean sharingEnabled() { - return hasShareProperties() && !(currentUserService.getCurrentUser() == null || + return SharingUtils.isSupported( clazz ) && !(currentUserService.getCurrentUser() == null || currentUserService.getCurrentUser().getUserCredentials().getAllAuthorities().contains( SharingUtils.SHARING_OVERRIDE_AUTHORITY )); } - private boolean hasShareProperties() - { - try - { - // for now we need to have this test, since not all idObjectClasses are converted - sessionFactory.getClassMetadata( clazz ).getPropertyType( "publicAccess" ); - } - catch ( HibernateException ignored ) - { - return false; - } - - return true; - } - private boolean isReadAllowed( T object ) { if ( IdentifiableObject.class.isInstance( object ) ) @@ -861,7 +845,7 @@ { IdentifiableObject idObject = (IdentifiableObject) object; - if ( hasShareProperties() ) + if ( SharingUtils.isSupported( clazz ) ) { return SharingUtils.canUpdate( currentUserService.getCurrentUser(), idObject ); } @@ -876,7 +860,7 @@ { IdentifiableObject idObject = (IdentifiableObject) object; - if ( hasShareProperties() ) + if ( SharingUtils.isSupported( clazz ) ) { return SharingUtils.canDelete( currentUserService.getCurrentUser(), idObject ); }