=== 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 2013-03-13 15:24:18 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java 2013-03-19 10:50:27 +0000 @@ -27,6 +27,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.hisp.dhis.api.utils.ContextUtils; import org.hisp.dhis.api.webdomain.sharing.Sharing; import org.hisp.dhis.api.webdomain.sharing.SharingUserGroupAccess; @@ -58,9 +60,11 @@ * @author Morten Olav Hansen */ @Controller -@RequestMapping( value = SharingController.RESOURCE_PATH, method = RequestMethod.GET ) +@RequestMapping(value = SharingController.RESOURCE_PATH, method = RequestMethod.GET) public class SharingController { + private static final Log log = LogFactory.getLog( SharingController.class ); + public static final String RESOURCE_PATH = "/sharing"; @Autowired @@ -78,7 +82,7 @@ @Autowired private UserGroupAccessService userGroupAccessService; - @RequestMapping( value = "", produces = { "application/json", "text/*" } ) + @RequestMapping(value = "", produces = { "application/json", "text/*" }) public void getSharing( @RequestParam String type, @RequestParam String id, HttpServletResponse response ) throws IOException { if ( !SharingUtils.isSupported( type ) ) @@ -127,7 +131,7 @@ JacksonUtils.toJson( response.getOutputStream(), sharing ); } - @RequestMapping( value = "", method = { RequestMethod.POST, RequestMethod.PUT }, consumes = "application/json" ) + @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( SharingUtils.classForType( type ), id ); @@ -185,6 +189,28 @@ manager.update( object ); + StringBuilder builder = new StringBuilder(); + + builder.append( "'" ).append( currentUserService.getCurrentUsername() ).append( "'" ); + builder.append( " update sharing on " ).append( object.getClass().getName() ); + builder.append( ", uid: " ).append( object.getUid() ).append( ", name: " ).append( object.getName() ); + builder.append( ", publicAccess: " ).append( object.getPublicAccess() ); + + if ( !object.getUserGroupAccesses().isEmpty() ) + { + builder.append( ", userGroupAccesses: " ); + + for ( UserGroupAccess userGroupAccess : object.getUserGroupAccesses() ) + { + builder.append( "{ uid: " ).append( userGroupAccess.getUserGroup().getUid() ); + builder.append( ", name: " ).append( userGroupAccess.getUserGroup().getName() ); + builder.append( ", access: " ).append( userGroupAccess.getAccess() ); + builder.append( " } " ); + } + } + + log.info( builder ); + ContextUtils.okResponse( response, "Access control set" ); }