dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21494
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10179: changed logic of canCreatePrivate, allows creation of private objects for all users if there is n...
------------------------------------------------------------
revno: 10179
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-03-13 21:19:05 +0700
message:
changed logic of canCreatePrivate, allows creation of private objects for all users if there is no private authority for the object
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.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-13 14:14:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java 2013-03-13 14:19:05 +0000
@@ -27,11 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
+import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.datadictionary.DataDictionary;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
@@ -46,6 +42,11 @@
import org.hisp.dhis.user.UserGroup;
import org.hisp.dhis.user.UserGroupAccess;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -69,10 +70,6 @@
PUBLIC_AUTHORITIES.put( Report.class, "F_REPORT_PUBLIC_ADD" );
PRIVATE_AUTHORITIES.put( Report.class, "F_REPORT_PRIVATE_ADD" );
- SUPPORTED_TYPES.put( "reportTable", ReportTable.class );
- PUBLIC_AUTHORITIES.put( ReportTable.class, "F_REPORTTABLE_PUBLIC_ADD" );
- PRIVATE_AUTHORITIES.put( ReportTable.class, "F_REPORTTABLE_PRIVATE_ADD" );
-
SUPPORTED_TYPES.put( "dataSet", DataSet.class );
PUBLIC_AUTHORITIES.put( DataSet.class, "F_DATASET_PUBLIC_ADD" );
PRIVATE_AUTHORITIES.put( DataSet.class, "F_DATASET_PRIVATE_ADD" );
@@ -97,13 +94,21 @@
PUBLIC_AUTHORITIES.put( IndicatorGroupSet.class, "F_INDICATORGROUPSET_PUBLIC_ADD" );
PRIVATE_AUTHORITIES.put( IndicatorGroupSet.class, "F_INDICATORGROUPSET_PRIVATE_ADD" );
- SUPPORTED_TYPES.put( "userGroup", UserGroup.class );
- PUBLIC_AUTHORITIES.put( UserGroup.class, "F_USERGROUP_PUBLIC_ADD" );
- PRIVATE_AUTHORITIES.put( UserGroup.class, "F_USERGROUP_PRIVATE_ADD" );
-
SUPPORTED_TYPES.put( "program", Program.class );
PUBLIC_AUTHORITIES.put( Program.class, "F_PROGRAM_PUBLIC_ADD" );
PRIVATE_AUTHORITIES.put( Program.class, "F_PROGRAM_PRIVATE_ADD" );
+
+ SUPPORTED_TYPES.put( "userGroup", UserGroup.class );
+ PUBLIC_AUTHORITIES.put( UserGroup.class, "F_USERGROUP_PUBLIC_ADD" );
+
+ SUPPORTED_TYPES.put( "reportTable", ReportTable.class );
+ PUBLIC_AUTHORITIES.put( ReportTable.class, "F_REPORTTABLE_PUBLIC_ADD" );
+
+ SUPPORTED_TYPES.put( "map", org.hisp.dhis.mapping.Map.class );
+ PUBLIC_AUTHORITIES.put( org.hisp.dhis.mapping.Map.class, "F_MAP_PUBLIC_ADD" );
+
+ SUPPORTED_TYPES.put( "chart", Chart.class );
+ PUBLIC_AUTHORITIES.put( Chart.class, "F_CHART_PUBLIC_ADD" );
}
public static boolean isSupported( String type )
@@ -155,7 +160,9 @@
public static boolean canCreatePrivate( User user, IdentifiableObject object )
{
Set<String> authorities = user != null ? user.getUserCredentials().getAllAuthorities() : new HashSet<String>();
- return authorities.contains( SHARING_OVERRIDE_AUTHORITY ) || authorities.contains( PRIVATE_AUTHORITIES.get( object.getClass() ) );
+ return authorities.contains( SHARING_OVERRIDE_AUTHORITY )
+ || PRIVATE_AUTHORITIES.get( object.getClass() ) == null
+ || authorities.contains( PRIVATE_AUTHORITIES.get( object.getClass() ) );
}
/**