0

I am using grails-5.2.5 to migrate an application from grails-2.5.2 version. In grails-2 version there is a class RestVehicleTrackingController which extends RestfulController. The purpose of the class is to return Map object as JSON. No related domain is specified. But in grails-5 version I can see that a domain should be specified. But I need to query any domain and prepare Map then response as JSON which was happening in previous version. Isn't it possible to keep the code as it is? My attempts are as below:

URL mapping:

"/api/vehicleList/$gatepassNo?(.$format)?"(controller: 'restVehicleTracking', action: 'getVehicleList')

My controller:

class RestVehicleTrackingController extends RestfulController {
    static allowedMethods = [search: 'GET', getVehicleList: 'GET']
    def restCommonService
    def vehicleTrackingService


    def getVehicleList(String gatepassNo) {
        def ipAddress = restCommonService.getClientIpAddress(request)
        def url = '/api/ws/vt/gatePass/vehicleList'
        String requestParams = params.toString()
        if (gatepassNo) {
            def retVal = vehicleTrackingService.getVehicleInformation(gatepassNo)
            if (retVal) {
                restCommonService.storeRequestInformation(url, requestParams, retVal.toString(), true, ipAddress, 'DOWN',)
                respond retVal, formats: ['json', 'xml']
            }
        }
        restCommonService.storeRequestInformation(url, requestParams, null, false, ipAddress, 'DOWN',)
        respond null, status: 404
    }
    
}

In grails-2.5.2 above code works fine and no error at extension. But in grails-5.2.5 this class RestVehicleTrackingController extends RestfulController gives the following error:

There is no default constructor available in class 'grails.rest.RestfulController'

Sumon Bappi
  • 1,937
  • 8
  • 38
  • 82

0 Answers0