Giter VIP home page Giter VIP logo

petclinic-phase4's Introduction

PetClinic Phase 4

Overview

In this phase of the project, we convert the code from phase 3 to a RESTful service using Spring REST services.

PetClinic Reference Application

What You Are Given

  • Completed code from phase 3.
  • Completed code for the Owner sequence.

What You Need To Complete

Activity 1
Building a REST Server
Activity 2
Building a REST Client
Activity 3
Building Out Our REST Server
  • Modify each of your Controller classes to implement REST endpoints for each of the standard CRUD methods.
  • Each controller will have it's own base URL.
  • Each method within each controller will follow the same naming convention for its endpoints.
    • \add
    • \get
    • \update
    • \delete
    • \getall
  • Add any other endpoints as needed to match functionality of the reference website. For instance, you may want to be able to get all visits for a specific pet, etc. See the OwnerController for one example of a non-CRUD endpoint.
  • You need to figure out the best way to pass information from Postman to your REST endpoints. In other words, are you going to use a @PathVariable or @RequestBody.
  • Test your endpoints with Postman
Activity 4
Infinite Recursion
  • There's an issue with the way the JSON data is being marshalled.
  • Look at the results when you navigate to http://localhost:8080/owner/getAllOwners
  • This is caused by the infinitely recursive relationship between model objects.
  • Research the @JsonIgnoreProperties annotation to see how this can be handled.
  • Add the @JsonIgnoreProperties annotation to each model's association fields (the fields that relate to other model objects) with the proper attributes.
  • See the Owner model for an example.
Activity 5
Playing With a REST Client
  • Test your endpoints out with a REST client.

  • You'll have to modify your REST client code along with the RestTemplate and/or it's parameters to test each of the endpoints.

  • You do NOT need to get all endpoints tested at the same time. Test them one at a time by changing RestTemplate methods and/or parameters.

  • You'll need to figure out which RestTemplate method is needed to test each endpoint.

    • This tutorial gives some more detailed info about how to use a RestTemplate.
  • Remember, there are more APIs to use with a RestTemplate than those shown.

Frameworks Used

  • Spring
  • Spring Boot
  • Spring Data JPA
  • Hibernate
  • Spring REST

Spring Annotations Used

  • @SpringBootApplication
  • @RestController
  • @Service
  • @Entity
  • @Table
  • @Id
  • @GeneratedValue
  • @OneToMany
  • @ManyToOne
  • @JoinColumn
  • @BodyMapping
  • @GetMapping
  • @PostMapping
  • @ResponseBody
  • @RequestMapping
  • @RequestParam
  • @PathVariable

Bonus Activities

Bonus Activity 1 (easy)
Adding a Bit of Swagger
Bonus Activity 2 (medium)
Exception Handling
  • Add exception handling to your REST service by referencing the tutorial below.
  • Error Handling for REST with Spring
  • Try using solution 4 from the tutorial. This is endpoint specific so you'll have to implement it in all of your endpoints.
Bonus Activity 3 (medium)
Custom White Label Page
Bonus Activity 4 (hard)
Adding Spring Security

Notes

  • Dependencies have already been added for you in the pom.xml file for this phase. You shouldn't have to modify or add anything to your build file (pom.xml), but feel free to as needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.