On Fri, Aug 9, 2013 at 12:41 PM, Matt Franklin <[email protected]>wrote:

> On Fri, Aug 9, 2013 at 9:44 AM, Erin Noe-Payne <[email protected]
> >wrote:
>
> > Hey All,
> >
> > So as I am testing out the rest api's I'm noticing a recurring issue
> > in the service layers - they do not necessarily check or throw errors
> > for bad data.
> >
> > One example is in DefaultPageService#updatePage. If I pass this method
> > a bogus pageLayoutCode, it will retrieve a null layout at 315, and
> > then set the page's layout to null at line 335. This results in
> > corrupted data.
> >
> > Another example is DefaultPageService#addWidgetToPageRegion. This will
> > not actually save corrupt data, but it doesn't check if the widgetId
> > is valid, and will eventually throw a nullpointerexception.
> >
> > What is the correct way to deal with this? Should service layer
> > methods be checking data validity and throwing errors that the
> > controller can listen for and pass on as a 400? Am I missing
> > something, or are there other suggestions?
> >
>
> We should be throwing exceptions when illegal state is reached.   We should
> also validate inputs comply with basic rules via a filter and bean
> validation
>

+1 we are kind of in the maturing stage as a project now and we need to
spend more time on polishing the code to cover the edge cases. Thanks for
taking the initiative Erin.

Reply via email to