dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36383
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18622: HibernateIdentifiableObjectStore, using sharing criteria to get object instead of call to acl ser...
------------------------------------------------------------
revno: 18622
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-03-18 21:13:23 +0100
message:
HibernateIdentifiableObjectStore, using sharing criteria to get object instead of call to acl service. Performance improvement.
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.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-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java 2015-03-08 10:49:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java 2015-03-18 20:13:23 +0000
@@ -101,15 +101,7 @@
return null;
}
- T object = getObject( Restrictions.eq( "uid", uid ) );
-
- if ( !isReadAllowed( object ) )
- {
- AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED );
- throw new ReadAccessDeniedException( object.toString() );
- }
-
- return object;
+ return getSharingObject( Restrictions.eq( "uid", uid ) );
}
@Override
@@ -175,15 +167,7 @@
return null;
}
- T object = getObject( Restrictions.eq( "code", code ) );
-
- if ( !isReadAllowed( object ) )
- {
- AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ_DENIED );
- throw new ReadAccessDeniedException( object.toString() );
- }
-
- return object;
+ return getSharingObject( Restrictions.eq( "code", code ) );
}
@Override
=== 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 2015-03-16 13:12:20 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2015-03-18 20:13:23 +0000
@@ -284,6 +284,18 @@
}
/**
+ * Retrieves an object based on the given Criterions using a sharing Criteria.
+ *
+ * @param expressions the Criterions for the Criteria.
+ * @return an object of the implementation Class type.
+ */
+ @SuppressWarnings( "unchecked" )
+ protected final T getSharingObject( Criterion... expressions )
+ {
+ return (T) getSharingCriteria( expressions ).uniqueResult();
+ }
+
+ /**
* Retrieves a List based on the given Criterions.
*
* @param expressions the Criterions for the Criteria.
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java 2015-03-16 13:49:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java 2015-03-18 20:13:23 +0000
@@ -114,7 +114,7 @@
// ---------------------------------------------------------------------
DataElement dataElement = idObjectManager.get( DataElement.class, de );
-
+
if ( dataElement == null )
{
ContextUtils.conflictResponse( response, "Illegal data element identifier: " + de );