StudentRESTfullWS.java

package com.sunilos.proj0.rest;

import java.util.List;

import org.apache.log4j.Logger;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.ResponseBody;

import com.sunilos.proj0.ctl.BaseCtl;

import com.sunilos.proj0.dto.StudentDTO;

import com.sunilos.proj0.form.StudentForm;

import com.sunilos.proj0.service.StudentServiceInt;

/**

* Student RESTfull Web Service

*

* @author SunilOS

* @version 1.0

* @Copyright (c) SunilOS

*/

@Controller

@RequestMapping(value = "/rest/Student", method = RequestMethod.GET)

public class StudentRESTfullWS extends BaseCtl {

/**

* Logger object

*/

private static Logger log = Logger.getLogger(StudentRESTfullWS.class);

@Autowired

StudentServiceInt service;

/**

* Gets Student information

*

* @param id

* @return

*/

@RequestMapping(value = "/{id}", method = RequestMethod.GET)

@ResponseBody

public StudentDTO get(@PathVariable long id) {

log.debug("StudentCtl doDisplay() Start");

StudentDTO dto = service.findByPK(id);

return dto;

}

/**

* Deletes a Student

*

* @param id

* @return

* @throws Exception

*/

@RequestMapping(value = "/delete/{id}")

@ResponseBody

public StudentDTO delete(@PathVariable long id) throws Exception {

StudentDTO dto = service.findByPK(id);

service.delete(id);

return dto;

}

/**

* Gets Student list

*

* @param form

* @return

*/

@RequestMapping(value = "/search", method = RequestMethod.GET)

@ResponseBody

public List getList(StudentForm form) {

StudentDTO dto = (StudentDTO) form.getDto();

return service.search(dto, form.getPageNo(), form.getPageSize());

}

}