Well, shouldn't it be like we catch the custom exception in StratosApi (in this case CartridgeAlreadyExistsException), and return the relevant response status code to the end user. Otherwise, we are not make use of those custom exceptions
On Sat, Jan 31, 2015 at 9:39 PM, Imesh Gunaratne <im...@apache.org> wrote: > IMO we need validations in both places. The reason being that in REST API > if we do not check the availability of a resource before executing an > operation it may raise a HTTP 500 to the end user as a result of the > exception raised by the backend service. > > Thanks > > On Sat, Jan 31, 2015 at 5:52 PM, Sajith Kariyawasam <saj...@wso2.com> > wrote: > >> Hi Devs, >> >> I noted that in addCartridge operation, existing cartridge check is done >> twice. >> >> In StratosApiV41 --> CartridgeBean cartridgeBean = >> StratosApiV41Utils.getCartridgeForValidate(cartridgeType); >> >> Also in CloudcontrollerServiceImpl --> >> cloudControllerContext.getCartridge(cartridgeType) >> >> I think the check in StratosApi (rest endpoint) is redundant, and that is >> not a responsibility of rest endpoint, also this will be an overhead to do >> a service call. >> >> Any reason for adding it there..? >> >> Thanks, >> Sajith >> > > > > -- > Imesh Gunaratne > > Technical Lead, WSO2 > Committer & PMC Member, Apache Stratos >