=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2014-03-25 15:41:15 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2014-03-25 15:43:26 +0000 @@ -29,6 +29,7 @@ */ import com.google.common.collect.Maps; +import org.hisp.dhis.api.controller.exception.NotFoundException; import org.hisp.dhis.api.utils.WebUtils; import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.IdentifiableObject; @@ -212,6 +213,38 @@ } } + + @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) + public String getObject( @PathVariable( "uid" ) String uid, @RequestParam Map parameters, + Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception + { + WebOptions options = new WebOptions( parameters ); + T entity = getEntity( uid ); + + if ( entity == null ) + { + throw new NotFoundException( uid ); + } + + if ( options.hasLinks() ) + { + WebUtils.generateLinks( entity ); + } + + if ( sharingService.isSupported( getEntityClass() ) ) + { + addAccessProperties( entity ); + } + + postProcessEntity( entity ); + postProcessEntity( entity, options, parameters ); + + model.addAttribute( "model", entity ); + model.addAttribute( "viewClass", options.getViewClass( "detailed" ) ); + + return StringUtils.uncapitalize( getEntitySimpleName() ); + } + //-------------------------------------------------------------------------- // POST //-------------------------------------------------------------------------- @@ -233,14 +266,16 @@ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = { "application/xml", "text/xml" } ) @ResponseStatus( value = HttpStatus.NO_CONTENT ) - public void putXmlObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception + public void putXmlObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream + input ) throws Exception { throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() ); } @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" ) @ResponseStatus( value = HttpStatus.NO_CONTENT ) - public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception + public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream + input ) throws Exception { throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() ); } @@ -251,7 +286,8 @@ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE ) @ResponseStatus( value = HttpStatus.NO_CONTENT ) - public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception + public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws + Exception { throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() ); } @@ -265,6 +301,7 @@ * Override to process entities after it has been retrieved from * storage and before it is returned to the view. Entities is null-safe. */ + protected void postProcessEntities( List entityList, WebOptions options, Map parameters ) {