HTTP STATUS CODE | USAGE |
---|---|
200 Ok | Resource created and returned |
200 Ok | Resource updated and returned |
200 Ok | Resource patched and returned |
200 Ok | Resource deleted |
200 Ok | Request processed successfully |
201 Created | Resource created and location header returned |
202 Accepted | Request will be processed asynchronously |
204 No Content | Request processed successfully and there is no response payload |
USE CASE | HTTP METHOD |
---|---|
Create | POST |
Get or Find | GET |
Update | PUT |
Partial Update | PATCH |
Delete or Soft Delete | DELETE |
Search | POST |
List Of Values | GET |
HTTP STATUS CODE | USAGE |
---|---|
400 Bad Request | Input validation failed |
400 Bad Request | JSON payload or request is unparsable |
401 Unauthorized | Require authorization header |
404 Not Found | No data exist for given input |
409 Conflict | When optimistic lock fails (User tries to update stale version) |
412 Precondition Failed | Constraint violation occurred |
HTTP STATUS CODE | EXAMPLE USAGE |
---|---|
500 Internal Server Error | Unexpected system failure |
500 Internal Server Error | Unexpected failure during database call |
500 Internal Server Error | Micro-service to micro-service call failed |
500 Internal Server Error | Auth server (Keycloak/Okta) call failed |
503 Service Unavailable | Database is down |
504 Gateway Timeout | Depending micro-service is not up |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.LocalDate; | |
import java.util.Map; | |
import javax.persistence.Entity; | |
import javax.persistence.Id; | |
import javax.persistence.Table; | |
@Entity | |
@Table(name = "patient_profile") | |
public class PatientProfile { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.core.type.TypeReference; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import java.io.IOException; | |
import java.util.HashMap; | |
import java.util.Map; | |
import javax.persistence.AttributeConverter; | |
import javax.persistence.Converter; | |
@Converter | |
public class StringMapConverter implements AttributeConverter<Map<String, String>, String> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE patient_profile ( | |
id int, | |
first_name varchar(45), | |
last_name varchar(45), | |
date_of_birth date, | |
-- ------------------------------- | |
-- Custom Attributes | |
attribute_1 varchar(255), | |
attribute_2 varchar(255), | |
-- ------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE patient_profile ( | |
id int, | |
first_name varchar(45), | |
last_name varchar(45), | |
date_of_birth date, | |
-- ------------------------------------------- | |
-- Custom Attributes | |
other_attributes json, -- JSON Datatype Column | |
-- ------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.databind.JsonNode; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import java.util.HashSet; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.Set; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.autoconfigure.security.oauth2.resource.JwtAccessTokenConverterConfigurer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.databind.ObjectMapper; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | |
import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerProperties; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.context.annotation.Import; | |
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | |
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
OlderNewer