java - What is the right place for checking a resource presence in Spring REST MVC project? -


i have spring rest mvc project consists of repositories, models, services, , controllers. after code review there discovered resource existence checked on different layers (the in services , controllers).

is ok have code below in few layers, or should in 1 place?

if (resource == null) {     throw new resourcenotfoundexception(); } 

this code should placed in 1 particular layer. choose services. why? place resource looked for. it's service job find resource or throw appropriate exception. endpoint/controller should used receive request , return response - should dummy possible. of work should done in services.

basically can put such logic in chosen layer, 1 , same resources.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -