Class ProductControllerRDBS

java.lang.Object
com.cyran.tp.server.products.ProductControllerRDBS

@RestController
public class ProductControllerRDBS
extends java.lang.Object
Managing products and storing information about them
Author:
Jakub Perdek
  • Constructor Summary

    Constructors 
    Constructor Description
    ProductControllerRDBS()  
  • Method Summary

    Modifier and Type Method Description
    java.lang.String createProduct​(javax.servlet.http.HttpServletRequest request, java.lang.String body, javax.servlet.http.HttpServletResponse response)
    Method for product creation
    ProductsDTO[] getFirstProducts​(javax.servlet.http.HttpServletRequest request, java.lang.Integer count, javax.servlet.http.HttpServletResponse response)
    Method for obtaining first n products from DB to be displayed in main page
    java.lang.String updateProduct​(javax.servlet.http.HttpServletRequest request, java.lang.String body, javax.servlet.http.HttpServletResponse response)
    Method for updating product

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getFirstProducts

      @RequestMapping(path="/firstProducts", method=GET, produces="application/json") @ResponseBody @CrossOrigin public ProductsDTO[] getFirstProducts​(javax.servlet.http.HttpServletRequest request, @RequestParam java.lang.Integer count, javax.servlet.http.HttpServletResponse response) throws java.lang.InterruptedException
      Method for obtaining first n products from DB to be displayed in main page
      Parameters:
      request - - request for obtaining firs n products
      count - - number of products which should be obtained from DB
      response - - response which should be send back
      Returns:
      obtained n products from DB
      Throws:
      java.lang.InterruptedException - if something interrupts it
    • createProduct

      @RequestMapping(path="/product/insert", method=POST, produces="application/json") @ResponseBody @CrossOrigin public java.lang.String createProduct​(javax.servlet.http.HttpServletRequest request, @RequestBody java.lang.String body, javax.servlet.http.HttpServletResponse response) throws java.lang.InterruptedException, org.json.simple.parser.ParseException
      Method for product creation
      Parameters:
      request - - request for product creation
      body - - body of post request with all information about product
      response - - response which should be send back
      Returns:
      string that confirms of product creation, otherwise denial of it or some error message
      Throws:
      java.lang.InterruptedException - if something interrupts it
      org.json.simple.parser.ParseException - if parsing of body JSON went wrong
    • updateProduct

      @RequestMapping(path="/product/update", method=POST, produces="application/json") @ResponseBody @CrossOrigin public java.lang.String updateProduct​(javax.servlet.http.HttpServletRequest request, @RequestBody java.lang.String body, javax.servlet.http.HttpServletResponse response) throws java.lang.InterruptedException, org.json.simple.parser.ParseException
      Method for updating product
      Parameters:
      request - - request for updating product
      body - - body of post request with all information for updating product - name identifies product and cant be changed
      response - - response which should be send back
      Returns:
      string that confirms of product update, otherwise error information
      Throws:
      java.lang.InterruptedException - if something interrupts it
      org.json.simple.parser.ParseException - if parsing of body JSON went wrong