This file contains 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
/* | |
* Copyright 2002-2020 the original author or authors. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* https://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains 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
@ExceptionHandler(NotFoundException.class) | |
public ResponseEntity<HttpClientErrorException> handleNotFound(NotFoundException ex, WebRequest req) { | |
ProblemDetail p = ProblemDetail.forStatus(ex.getStatusCode()); | |
URI type = new DefaultUriBuilderFactory() | |
.uriString("https://yoursite.acme.com/not-found/{error-code}") | |
.build(Map.of("error-code", ex.getErrorCode())); | |
p.setDetail(ex.getStatusText()); | |
p.setTitle("Object not found"); | |
p.setType(type); | |
p.setProperty("hint", "hint-value"); |
This file contains 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
@ExceptionHandler(BadRequestException.class) | |
public ResponseEntity<HttpClientErrorException> handleBadRequest(BadRequestException ex, WebRequest req) { | |
ProblemDetail p = ProblemDetail.forStatus(ex.getStatusCode()); | |
URI type = new DefaultUriBuilderFactory() | |
.uriString("https://yoursite.acme.com/bad-request/{error-code}") | |
.build(Map.of("error-code", ex.getErrorCode())); | |
p.setDetail(ex.getStatusText()); | |
p.setTitle("Bad Request"); | |
p.setType(type); | |
p.setProperty("hint", "hint-value"); |
This file contains 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
package com.kapresoft.api; | |
import com.kapresoft.api.exception.client.BadRequestException; | |
import com.kapresoft.api.exception.client.NotFoundException; | |
import org.springframework.http.ProblemDetail; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.bind.annotation.ControllerAdvice; | |
import org.springframework.web.bind.annotation.ExceptionHandler; | |
import org.springframework.web.client.HttpClientErrorException; |
This file contains 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
package lombok; | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
/** | |
* This annotation can be used on a field of a builder class to let lombok generate an add method for adding a single | |
* element to the collection behind the field. |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-dependencies</artifactId> | |
<version>2.6.1</version> | |
<packaging>pom</packaging> | |
<name>spring-boot-dependencies</name> | |
<description>Spring Boot Dependencies</description> | |
<url>https://spring.io/projects/spring-boot</url> |
This file contains 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
package com.kapresoft.springboot.serializeimmutableobjects.dto.hierarchical; | |
import com.fasterxml.jackson.annotation.JsonProperty; | |
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | |
import lombok.Builder; | |
import lombok.EqualsAndHashCode; | |
import lombok.Value; | |
@Value | |
@EqualsAndHashCode(callSuper = true) |
This file contains 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
package com.kapresoft.springboot.serializeimmutableobjects.dto.hierarchical; | |
import lombok.Getter; | |
@Getter | |
public abstract class BaseAccount { | |
String username; | |
String email; |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<groupId>com.fasterxml.jackson</groupId> | |
<artifactId>jackson-parent</artifactId> | |
<!-- note: does NOT change for every version of bom --> | |
<version>2.12</version> | |
</parent> |
This file contains 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
@startuml | |
"Client App" -> "Account API": POST /account | |
"Account API" -> "Jackson ObjectMapper": readValue(byte[] src, Class<Account>) | |
"Account API" -> "Account API": createAccount(Account) | |
"Account API" -> "Jackson ObjectMapper": writeValue(OutputStream out, Account newAccount) | |
"Client App" <-- "Account API": Response (OutputStream) | |
@enduml |
NewerOlder