------------------------------------------------------------ revno: 14472 committer: Morten Olav Hansen <morte...@gmail.com> branch nick: dhis2 timestamp: Thu 2014-03-27 09:25:39 +0100 message: minor fixes, use isShareable in securityService, check for shareable type in SharingController, remove share requirement from aclService.classFromType modified: dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/acl/DefaultAclService.java dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.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/acl/DefaultAclService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/acl/DefaultAclService.java 2014-03-27 08:20:52 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/acl/DefaultAclService.java 2014-03-27 08:25:39 +0000 @@ -247,7 +247,7 @@ { Schema schema = schemaService.getSchemaBySingularName( type ); - if ( schema != null && schema.isShareable() && schema.isIdentifiableObject() ) + if ( schema != null && schema.isIdentifiableObject() ) { return (Class<? extends IdentifiableObject>) schema.getKlass(); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java 2014-03-27 06:07:15 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java 2014-03-27 08:25:39 +0000 @@ -289,7 +289,7 @@ @Override public boolean canCreatePublic( IdentifiableObject identifiableObject ) { - return !aclService.isSupported( identifiableObject.getClass() ) + return !aclService.isShareable( identifiableObject.getClass() ) || aclService.canCreatePublic( currentUserService.getCurrentUser(), identifiableObject.getClass() ); } @@ -298,14 +298,14 @@ { Class<? extends IdentifiableObject> klass = aclService.classForType( type ); - return !aclService.isSupported( klass ) + return !aclService.isShareable( klass ) || aclService.canCreatePublic( currentUserService.getCurrentUser(), klass ); } @Override public boolean canCreatePrivate( IdentifiableObject identifiableObject ) { - return !aclService.isSupported( identifiableObject.getClass() ) + return !aclService.isShareable( identifiableObject.getClass() ) || aclService.canCreatePrivate( currentUserService.getCurrentUser(), identifiableObject.getClass() ); } @@ -314,7 +314,7 @@ { Class<? extends IdentifiableObject> klass = aclService.classForType( type ); - return !aclService.isSupported( klass ) + return !aclService.isShareable( klass ) || aclService.canCreatePrivate( currentUserService.getCurrentUser(), klass ); } @@ -349,7 +349,7 @@ @Override public boolean canManage( IdentifiableObject identifiableObject ) { - return !aclService.isSupported( identifiableObject.getClass() ) + return !aclService.isShareable( identifiableObject.getClass() ) || aclService.canManage( currentUserService.getCurrentUser(), identifiableObject ); } } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java 2014-03-27 06:07:15 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java 2014-03-27 08:25:39 +0000 @@ -30,6 +30,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hisp.dhis.acl.AccessStringHelper; import org.hisp.dhis.acl.AclService; import org.hisp.dhis.api.utils.ContextUtils; import org.hisp.dhis.api.webdomain.sharing.Sharing; @@ -39,7 +40,6 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.dxf2.utils.JacksonUtils; -import org.hisp.dhis.acl.AccessStringHelper; import org.hisp.dhis.user.CurrentUserService; import org.hisp.dhis.user.UserGroup; import org.hisp.dhis.user.UserGroupAccess; @@ -157,7 +157,15 @@ @RequestMapping( value = "", method = { RequestMethod.POST, RequestMethod.PUT }, consumes = "application/json" ) public void setSharing( @RequestParam String type, @RequestParam String id, HttpServletResponse response, HttpServletRequest request ) throws IOException { - BaseIdentifiableObject object = (BaseIdentifiableObject) manager.get( aclService.classForType( type ), id ); + Class<? extends IdentifiableObject> sharingClass = aclService.classForType( type ); + + if ( sharingClass == null || !aclService.isShareable( sharingClass ) ) + { + ContextUtils.notFoundResponse( response, "Type " + type + " is not supported." ); + return; + } + + BaseIdentifiableObject object = (BaseIdentifiableObject) manager.get( sharingClass, id ); if ( object == null ) {
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp