------------------------------------------------------------ revno: 17422 committer: Morten Olav Hansen <[email protected]> branch nick: dhis2 timestamp: Tue 2014-11-11 14:53:17 +0545 message: remove custom CRUD code for relationshipTypes, now uses default CRUD impl instead (which uses security etc) modified: dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/RelationshipTypeController.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-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/RelationshipTypeController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/RelationshipTypeController.java 2014-10-21 13:31:06 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/RelationshipTypeController.java 2014-11-11 09:08:17 +0000 @@ -28,23 +28,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.hisp.dhis.dxf2.utils.JacksonUtils; import org.hisp.dhis.relationship.RelationshipType; -import org.hisp.dhis.relationship.RelationshipTypeService; import org.hisp.dhis.schema.descriptors.RelationshipTypeSchemaDescriptor; import org.hisp.dhis.webapi.controller.AbstractCrudController; -import org.hisp.dhis.webapi.utils.ContextUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseStatus; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.InputStream; /** * @author Morten Olav Hansen <[email protected]> @@ -53,93 +41,4 @@ @RequestMapping( value = RelationshipTypeSchemaDescriptor.API_ENDPOINT ) public class RelationshipTypeController extends AbstractCrudController<RelationshipType> { - @Autowired - private RelationshipTypeService relationshipTypeService; - - //-------------------------------------------------------------------------- - // POST - //-------------------------------------------------------------------------- - - @Override - @RequestMapping( method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } ) - @ResponseStatus( HttpStatus.CREATED ) - public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception - { - RelationshipType relationshipType = JacksonUtils.fromXml( input, RelationshipType.class ); - relationshipTypeService.addRelationshipType( relationshipType ); - - response.setHeader( "Location", ContextUtils.getRootPath( request ) + RelationshipTypeSchemaDescriptor.API_ENDPOINT + "/" + relationshipType.getUid() ); - } - - @Override - @RequestMapping( method = RequestMethod.POST, consumes = "application/json" ) - @ResponseStatus( HttpStatus.CREATED ) - public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception - { - RelationshipType relationshipType = JacksonUtils.fromJson( input, RelationshipType.class ); - relationshipTypeService.addRelationshipType( relationshipType ); - - response.setHeader( "Location", ContextUtils.getRootPath( request ) + RelationshipTypeSchemaDescriptor.API_ENDPOINT + "/" + relationshipType.getUid() ); - } - - //-------------------------------------------------------------------------- - // PUT - //-------------------------------------------------------------------------- - - @Override - @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = { "application/xml", "text/xml" } ) - public void putXmlObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception - { - RelationshipType relationshipType = relationshipTypeService.getRelationshipType( uid ); - - if ( relationshipType == null ) - { - ContextUtils.conflictResponse( response, "RelationshipType does not exist: " + uid ); - return; - } - - RelationshipType newRelationshipType = JacksonUtils.fromXml( input, RelationshipType.class ); - newRelationshipType.setUid( relationshipType.getUid() ); - relationshipType.mergeWith( newRelationshipType ); - - relationshipTypeService.updateRelationshipType( relationshipType ); - } - - @Override - @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" ) - public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception - { - RelationshipType relationshipType = relationshipTypeService.getRelationshipType( uid ); - - if ( relationshipType == null ) - { - ContextUtils.conflictResponse( response, "RelationshipType does not exist: " + uid ); - return; - } - - RelationshipType newRelationshipType = JacksonUtils.fromJson( input, RelationshipType.class ); - newRelationshipType.setUid( relationshipType.getUid() ); - relationshipType.mergeWith( newRelationshipType ); - - relationshipTypeService.updateRelationshipType( relationshipType ); - } - - //-------------------------------------------------------------------------- - // DELETE - //-------------------------------------------------------------------------- - - @Override - @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE ) - public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception - { - RelationshipType relationshipType = relationshipTypeService.getRelationshipType( uid ); - - if ( relationshipType == null ) - { - ContextUtils.conflictResponse( response, "RelationshipType does not exist: " + uid ); - return; - } - - relationshipTypeService.deleteRelationshipType( relationshipType ); - } }
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : [email protected] Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp

