dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24895
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12247: change exception type in EventController (for missing program and programStage)
------------------------------------------------------------
revno: 12247
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-09-26 10:00:58 +0200
message:
change exception type in EventController (for missing program and programStage)
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.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/api/controller/event/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java 2013-09-17 12:15:39 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java 2013-09-26 08:00:58 +0000
@@ -61,7 +61,7 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.client.HttpServerErrorException;
+import org.springframework.web.client.HttpClientErrorException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -74,7 +74,7 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = EventController.RESOURCE_PATH )
+@RequestMapping(value = EventController.RESOURCE_PATH)
public class EventController
{
public static final String RESOURCE_PATH = "/events";
@@ -102,13 +102,13 @@
// Controller
// -------------------------------------------------------------------------
- @RequestMapping( value = "", method = RequestMethod.GET )
+ @RequestMapping(value = "", method = RequestMethod.GET)
public String getEvents(
- @RequestParam( value = "program", required = false ) String programUid,
- @RequestParam( value = "programStage", required = false ) String programStageUid,
- @RequestParam( value = "orgUnit" ) String orgUnitUid,
- @RequestParam @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date startDate,
- @RequestParam @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date endDate,
+ @RequestParam(value = "program", required = false) String programUid,
+ @RequestParam(value = "programStage", required = false) String programStageUid,
+ @RequestParam(value = "orgUnit") String orgUnitUid,
+ @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
+ @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
@RequestParam Map<String, String> parameters, Model model, HttpServletRequest request ) throws Exception
{
WebOptions options = new WebOptions( parameters );
@@ -118,7 +118,7 @@
if ( program == null && programStage == null )
{
- throw new HttpServerErrorException( HttpStatus.BAD_REQUEST,
+ throw new HttpClientErrorException( HttpStatus.BAD_REQUEST,
"Both program and programStage is invalid or missing, needs at least one." );
}
@@ -169,8 +169,8 @@
return "event";
}
- @RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getEvent( @PathVariable( "uid" ) String uid, @RequestParam Map<String, String> parameters,
+ @RequestMapping(value = "/{uid}", method = RequestMethod.GET)
+ public String getEvent( @PathVariable("uid") String uid, @RequestParam Map<String, String> parameters,
Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
WebOptions options = new WebOptions( parameters );
@@ -193,8 +193,8 @@
return "event";
}
- @RequestMapping( method = RequestMethod.POST, consumes = "application/xml" )
- @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')" )
+ @RequestMapping(method = RequestMethod.POST, consumes = "application/xml")
+ @PreAuthorize("hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')")
public void postXmlEvent( HttpServletResponse response, HttpServletRequest request, ImportOptions importOptions ) throws Exception
{
InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat( request.getInputStream() );
@@ -238,8 +238,8 @@
}
}
- @RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')" )
+ @RequestMapping(method = RequestMethod.POST, consumes = "application/json")
+ @PreAuthorize("hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')")
public void postJsonEvent( HttpServletResponse response, HttpServletRequest request, ImportOptions importOptions ) throws Exception
{
InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat( request.getInputStream() );
@@ -284,10 +284,10 @@
}
- @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
- @ResponseStatus( value = HttpStatus.NO_CONTENT )
- @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_DELETE')" )
- public void deleteEvent( HttpServletResponse response, @PathVariable( "uid" ) String uid )
+ @RequestMapping(value = "/{uid}", method = RequestMethod.DELETE)
+ @ResponseStatus(value = HttpStatus.NO_CONTENT)
+ @PreAuthorize("hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_DELETE')")
+ public void deleteEvent( HttpServletResponse response, @PathVariable("uid") String uid )
{
Event event = eventService.getEvent( uid );
@@ -300,9 +300,9 @@
eventService.deleteEvent( event );
}
- @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = { "application/xml", "text/xml" } )
- @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')" )
- public void putXmlEvent( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws IOException
+ @RequestMapping(value = "/{uid}", method = RequestMethod.PUT, consumes = { "application/xml", "text/xml" })
+ @PreAuthorize("hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')")
+ public void putXmlEvent( HttpServletResponse response, HttpServletRequest request, @PathVariable("uid") String uid ) throws IOException
{
Event event = eventService.getEvent( uid );
@@ -319,9 +319,9 @@
ContextUtils.okResponse( response, "Event updated: " + uid );
}
- @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
- @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')" )
- public void putJsonEvent( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws IOException
+ @RequestMapping(value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json")
+ @PreAuthorize("hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')")
+ public void putJsonEvent( HttpServletResponse response, HttpServletRequest request, @PathVariable("uid") String uid ) throws IOException
{
Event event = eventService.getEvent( uid );