=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java 2015-11-17 15:43:39 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java 2015-11-17 17:01:46 +0000 @@ -47,7 +47,6 @@ import org.hisp.dhis.dataelement.CategoryOptionGroupSet; import org.hisp.dhis.dataelement.DataElementCategory; import org.hisp.dhis.dataset.DataSet; -import org.hisp.dhis.program.Program; import org.hisp.dhis.schema.PropertyType; import org.hisp.dhis.schema.annotation.Property; import org.hisp.dhis.schema.annotation.PropertyRange; @@ -274,23 +273,6 @@ return dataSets; } - - /** - * Returns a set of the programs for all user authority groups - * of this user credentials. - */ - public Set getAllPrograms() - { - Set programs = new HashSet<>(); - - for ( UserAuthorityGroup group : userAuthorityGroups ) - { - programs.addAll( group.getPrograms() ); - } - - return programs; - } - /** * Indicates whether this user credentials can issue the given user authority * group. First the given authority group must not be null. Second this === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2015-11-17 15:43:39 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2015-11-17 17:01:46 +0000 @@ -85,7 +85,6 @@ import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueService; import org.hisp.dhis.user.CurrentUserService; import org.hisp.dhis.user.User; -import org.hisp.dhis.user.UserCredentials; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; @@ -505,8 +504,6 @@ OrganisationUnitSelectionMode orgUnitSelectionMode, String trackedEntityInstance, Date startDate, Date endDate, EventStatus status, Date lastUpdated, DataElementCategoryOptionCombo attributeCoc, IdSchemes idSchemes, Integer page, Integer pageSize, boolean totalPages, boolean skipPaging, boolean includeAttributes ) { - UserCredentials userCredentials = currentUserService.getCurrentUser().getUserCredentials(); - EventSearchParams params = new EventSearchParams(); Program pr = programService.getProgram( program ); @@ -529,24 +526,6 @@ { throw new IllegalQueryException( "Org unit is specified but does not exist: " + orgUnit ); } - - if( ou != null && !organisationUnitService.isInUserHierarchy( ou ) ) - { - if( !userCredentials.isAuthorized( "F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS" ) ) - { - throw new IllegalQueryException( "User has no access to organisation unit: " + ou.getUid() ); - } - } - - if( pr == null && userCredentials.getAllPrograms().size() == 0 ) - { - throw new IllegalQueryException( "User has no access to programs"); - } - - if( pr != null && userCredentials.getAllPrograms().contains( pr ) ) - { - throw new IllegalQueryException( "User has no access to program: " + pr.getUid() ); - } TrackedEntityInstance tei = entityInstanceService.getTrackedEntityInstance( trackedEntityInstance ); @@ -885,31 +864,12 @@ event.setDueDate( DateUtils.getLongDateString( programStageInstance.getDueDate() ) ); event.setStoredBy( programStageInstance.getCompletedUser() ); - UserCredentials userCredentials = currentUserService.getCurrentUser().getUserCredentials(); - - OrganisationUnit ou = programStageInstance.getOrganisationUnit(); - - if ( ou != null ) - { - if( !organisationUnitService.isInUserHierarchy( ou ) ) - { - if( !userCredentials.isAuthorized( "F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS" ) ) - { - throw new IllegalQueryException( "User has no access to organisation unit: " + ou.getUid() ); - } - } - - event.setOrgUnit( ou.getUid() ); - } - - Program program = programStageInstance.getProgramInstance().getProgram(); - - if( !userCredentials.getAllPrograms().contains( program ) ) + if ( programStageInstance.getOrganisationUnit() != null ) { - throw new IllegalQueryException( "User has no access to program: " + program.getUid() ); + event.setOrgUnit( programStageInstance.getOrganisationUnit().getUid() ); } - - event.setProgram( program.getUid() ); + + event.setProgram( programStageInstance.getProgramInstance().getProgram().getUid() ); event.setEnrollment( programStageInstance.getProgramInstance().getUid() ); event.setProgramStage( programStageInstance.getProgramStage().getUid() ); @@ -1318,5 +1278,5 @@ private DataElement getDataElement( String dataElementId ) { return dataElementCache.get( dataElementId, new IdentifiableObjectCallable<>( manager, DataElement.class, dataElementId ) ); - } + } } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java 2015-11-17 15:43:39 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java 2015-11-17 17:01:46 +0000 @@ -389,7 +389,8 @@ if( uid == null) { throw new WebMessageException( WebMessageUtils.conflict( "DataElement must be of type file" ) ); - } + } + FileResource fileResource = fileResourceService.getFileResource( uid );