dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21748
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10382: minor fixes
------------------------------------------------------------
revno: 10382
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-03-21 20:53:37 +0700
message:
minor fixes
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java
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-api/src/main/java/org/hisp/dhis/common/SharingUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java 2013-03-21 06:43:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java 2013-03-21 13:53:37 +0000
@@ -230,11 +230,14 @@
*/
public static boolean canRead( User user, IdentifiableObject object )
{
+ System.err.println( "TRYING TO READ: " + object );
+
if ( sharingOverrideAuthority( user )
|| object.getUser() == null
|| user.equals( object.getUser() )
|| AccessStringHelper.canRead( object.getPublicAccess() ) )
{
+ System.err.println("CAN READ");
return true;
}
@@ -243,10 +246,12 @@
if ( AccessStringHelper.canRead( userGroupAccess.getAccess() )
&& userGroupAccess.getUserGroup().getMembers().contains( user ) )
{
+ System.err.println("CAN READ");
return true;
}
}
+ System.err.println("CAN NOT READ");
return false;
}
=== 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-03-20 07:28:44 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2013-03-21 13:53:37 +0000
@@ -47,6 +47,7 @@
import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserGroupAccess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -54,6 +55,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
/**
@@ -187,7 +189,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();
@@ -199,7 +201,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();
@@ -212,16 +214,14 @@
@Override
public int save( T object )
{
- if ( !isWriteAllowed( object ) )
- {
- AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_CREATE_DENIED );
- throw new CreateAccessDeniedException( object.toString() );
- }
-
if ( currentUserService.getCurrentUser() != null && SharingUtils.isSupported( clazz ) )
{
BaseIdentifiableObject identifiableObject = (BaseIdentifiableObject) object;
+ // TODO we might want to allow setting sharing props on save, but for now.. we null them out
+ identifiableObject.setPublicAccess( null );
+ identifiableObject.setUserGroupAccesses( new HashSet<UserGroupAccess>() );
+
if ( identifiableObject.getUser() == null )
{
identifiableObject.setUser( currentUserService.getCurrentUser() );
@@ -265,7 +265,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public final T get( int id )
{
T object = (T) sessionFactory.getCurrentSession().get( getClazz(), id );
@@ -280,7 +280,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public final T load( int id )
{
T object = (T) sessionFactory.getCurrentSession().load( getClazz(), id );
@@ -372,7 +372,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public final List<T> getAll()
{
Query query = sharingEnabled() ? getQueryAllAcl() : getQueryAll();
@@ -399,7 +399,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getAllEqName( String name )
{
Query query = sharingEnabled() ? getQueryAllEqNameAcl( name ) : getQueryAllEqName( name );
@@ -431,7 +431,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getAllEqNameIgnoreCase( String name )
{
Query query = sharingEnabled() ? getQueryAllEqNameAclIgnoreCase( name ) : getQueryAllEqNameIgnoreCase( name );
@@ -463,7 +463,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getAllEqShortName( String shortName )
{
Query query = sharingEnabled() ? getQueryAllEqShortNameAcl( shortName ) : getQueryAllEqShortName( shortName );
@@ -495,7 +495,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getAllEqShortNameIgnoreCase( String shortName )
{
Query query = sharingEnabled() ? getQueryAllEqShortNameAclIgnoreCase( shortName ) : getQueryAllEqShortNameIgnoreCase( shortName );
@@ -527,7 +527,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getAllLikeName( String name )
{
Query query = sharingEnabled() ? getQueryAllLikeNameAcl( name ) : getQueryAllLikeName( name );
@@ -559,7 +559,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public final List<T> getAllOrderedName()
{
Query query = sharingEnabled() ? getQueryAllOrderedNameAcl() : getQueryAllOrderedName();
@@ -587,7 +587,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getAllOrderedName( int first, int max )
{
Query query = sharingEnabled() ? getQueryAllOrderedNameAcl() : getQueryAllOrderedName();
@@ -599,7 +599,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getAllOrderedLastUpdated( int first, int max )
{
Query query = sharingEnabled() ? getQueryAllOrderedLastUpdatedAcl() : getQueryAllOrderedLastUpdated();
@@ -630,7 +630,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getAllLikeNameOrderedName( String name, int first, int max )
{
Query query = sharingEnabled() ? getQueryAllLikeNameOrderedNameAcl( name ) : getQueryAllLikeNameOrderedName( name );
@@ -753,7 +753,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getAllGeLastUpdated( Date lastUpdated )
{
Query query = sharingEnabled() ? getQueryAllGeLastUpdatedAcl( lastUpdated ) : getQueryAllGeLastUpdated( lastUpdated );
@@ -785,7 +785,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getAllGeCreated( Date created )
{
Query query = sharingEnabled() ? getQueryAllGeCreatedAcl( created ) : getQueryAllGeCreated( created );
@@ -817,7 +817,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getAllGeLastUpdatedOrderedName( Date lastUpdated )
{
Query query = sharingEnabled() ? getQueryAllGeLastUpdatedOrderedNameAcl( lastUpdated ) : getQueryAllGeLastUpdatedOrderedName( lastUpdated );
@@ -849,7 +849,7 @@
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public List<T> getByUser( User user )
{
Query query = getQuery( "from " + clazz.getName() + " c where user = :user" );