Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #47 from corona-warn-app/chore/update-cwa-parent-2…
Browse files Browse the repository at this point in the history
….0.2

Chore: Update CWA-Parent to 2.0.2
  • Loading branch information
f11h authored Mar 16, 2023
2 parents 0e9aa34 + 03acb30 commit 728c42e
Show file tree
Hide file tree
Showing 28 changed files with 249 additions and 241 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/setup-java@v2
with:
java-version: 11
java-version: 17
distribution: adopt
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: sigstore/cosign-installer@main
- uses: actions/setup-java@v2
with:
java-version: 11
java-version: 17
distribution: adopt
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/setup-java@v2
with:
java-version: 11
java-version: 17
distribution: adopt
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/setup-java@v2
with:
java-version: 11
java-version: 17
distribution: adopt
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/setup-java@v2
with:
java-version: 11
java-version: 17
distribution: adopt
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>app.coronawarn</groupId>
<artifactId>cwa-parent</artifactId>
<version>1.7.1</version>
<version>2.0.2</version>
<relativePath/>
</parent>
<groupId>eu.europa.ec.dgc</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.server.ResponseStatusException;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

Expand Down Expand Up @@ -62,15 +63,31 @@ public ResponseEntity<ProblemReportDto> handleException(Exception e) {
if (e instanceof ResponseStatusException) {
DgcaBusinessRulesResponseException de = (DgcaBusinessRulesResponseException) e;
return ResponseEntity
.status(((ResponseStatusException) e).getStatus())
.contentType(MediaType.APPLICATION_JSON)
.body(new ProblemReportDto(de.getCode(), de.getProblem(), de.getSentValues(), de.getDetails()));
.status(((ResponseStatusException) e).getStatusCode())
.contentType(MediaType.APPLICATION_JSON)
.body(new ProblemReportDto(de.getCode(), de.getProblem(), de.getSentValues(), de.getDetails()));
} else {
log.error("Uncatched exception", e);
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.contentType(MediaType.APPLICATION_JSON)
.body(new ProblemReportDto("0x500", "Internal Server Error", "", ""));
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.contentType(MediaType.APPLICATION_JSON)
.body(new ProblemReportDto("0x500", "Internal Server Error", "", ""));
}
}

/**
* Global Exception Handler to wrap exceptions into a readable JSON Object.
*
* @param e the thrown exception
* @param request the thrown WebRequest
* @return ResponseEntity with readable data.
*/
@ExceptionHandler(ResponseStatusException.class)
public ResponseEntity<ProblemReportDto> handleException(ResponseStatusException e, WebRequest request) {
DgcaBusinessRulesResponseException de = (DgcaBusinessRulesResponseException) e;
return ResponseEntity
.status(e.getStatusCode())
.contentType(MediaType.APPLICATION_JSON)
.body(new ProblemReportDto(de.getCode(), de.getProblem(), de.getSentValues(), de.getDetails()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@

package eu.europa.ec.dgc.businessrule.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.SecurityFilterChain;

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Configuration
public class WebSecurityConfig {

@Override
protected void configure(HttpSecurity http) throws Exception {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable();
return http.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

package eu.europa.ec.dgc.businessrule.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

package eu.europa.ec.dgc.businessrule.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@

package eu.europa.ec.dgc.businessrule.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;


@Entity
@Table(name = "shedlock_br")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

package eu.europa.ec.dgc.businessrule.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

package eu.europa.ec.dgc.businessrule.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.ZonedDateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

package eu.europa.ec.dgc.businessrule.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import java.util.List;
import jakarta.validation.Valid;
import java.util.Optional;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
Expand Down Expand Up @@ -91,11 +90,11 @@ public class BoosterNotificationRuleController {
array = @ArraySchema(schema = @Schema(implementation = BoosterNotificationRuleListItemDto.class))))
}
)
public ResponseEntity<List<BoosterNotificationRuleListItemDto>> getRules(
public ResponseEntity<Object> getRules(
@RequestHeader(value = API_VERSION_HEADER, required = false) String apiVersion
) {
Optional<SignedListEntity> rulesList = boosterNotificationRuleService.getRulesSignedList();
ResponseEntity responseEntity;
ResponseEntity<Object> responseEntity;
if (rulesList.isPresent()) {
ResponseEntity.BodyBuilder respBuilder = ResponseEntity.ok();
String signature = rulesList.get().getSignature();
Expand Down Expand Up @@ -143,27 +142,27 @@ public ResponseEntity<List<BoosterNotificationRuleListItemDto>> getRules(
mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = String.class),
examples = {
@ExampleObject(value = "{\n"
+ " \"Identifier\": \"VR-DE-1\",\n"
+ " \"Version\": \"1.0.0\",\n"
+ " \"SchemaVersion\":\"1.0.0\",\n"
+ " \"Engine\":\"CERTLOGIC\",\n"
+ " \"EngineVersion\":\"1.0.0\",\n"
+ " \"Type\":\"Acceptance\",\n"
+ " \"Country\":\"DE\",\n"
+ " \"CertificateType\":\"Vaccination\",\n"
+ " \"Description\":[{\"lang\":\"en\",\"desc\":\"Vaccination must be from June and "
+ "doses must be 2\"}],\n"
+ " \"ValidFrom\":\"2021-06-27T07:46:40Z\",\n"
+ " \"ValidTo\":\"2021-08-01T07:46:40Z\",\n"
+ " \"AffectedFields\":[\"dt\",\"dn\"],\n"
+ " \"Logic\":{\n"
+ " \"and\": [\n"
+ " {\">=\":[ {\"var\":\"dt\"}, \"2021-06-01T00:00:00Z\" ]},\n"
+ " {\">=\":[ {\"var\":\"dn\"}, 2 ]}\n"
+ " ]\n"
+ " }\n"
+ "}")
@ExampleObject(value = """
{
"Identifier": "VR-DE-1",
"Version": "1.0.0",
"SchemaVersion":"1.0.0",
"Engine":"CERTLOGIC",
"EngineVersion":"1.0.0",
"Type":"Acceptance",
"Country":"DE",
"CertificateType":"Vaccination",
"Description":[{"lang":"en","desc":"Vaccination must be from June and doses must be 2"}],
"ValidFrom":"2021-06-27T07:46:40Z",
"ValidTo":"2021-08-01T07:46:40Z",
"AffectedFields":["dt","dn"],
"Logic":{
"and": [
{">=":[ {"var":"dt"}, "2021-06-01T00:00:00Z" ]},
{">=":[ {"var":"dn"}, 2 ]}
]
}
}""")
})),
@ApiResponse(
responseCode = "404",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.validation.Valid;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -91,11 +90,11 @@ public class BusinessRuleController {
array = @ArraySchema(schema = @Schema(implementation = BusinessRuleListItemDto.class))))
}
)
public ResponseEntity<List<BusinessRuleListItemDto>> getRules(
public ResponseEntity<Object> getRules(
@RequestHeader(value = API_VERSION_HEADER, required = false) String apiVersion
) {
Optional<SignedListEntity> rulesList = businessRuleService.getBusinessRulesSignedList();
ResponseEntity responseEntity;
ResponseEntity<Object> responseEntity;
if (rulesList.isPresent()) {
ResponseEntity.BodyBuilder respBuilder = ResponseEntity.ok();
String signature = rulesList.get().getSignature();
Expand Down Expand Up @@ -194,27 +193,27 @@ public ResponseEntity<List<BusinessRuleListItemDto>> getRulesForCountry(
mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = String.class),
examples = {
@ExampleObject(value = "{\n"
+ " \"Identifier\": \"VR-DE-1\",\n"
+ " \"Version\": \"1.0.0\",\n"
+ " \"SchemaVersion\":\"1.0.0\",\n"
+ " \"Engine\":\"CERTLOGIC\",\n"
+ " \"EngineVersion\":\"1.0.0\",\n"
+ " \"Type\":\"Acceptance\",\n"
+ " \"Country\":\"DE\",\n"
+ " \"CertificateType\":\"Vaccination\",\n"
+ " \"Description\":[{\"lang\":\"en\",\"desc\":\"Vaccination must be from June and "
+ "doses must be 2\"}],\n"
+ " \"ValidFrom\":\"2021-06-27T07:46:40Z\",\n"
+ " \"ValidTo\":\"2021-08-01T07:46:40Z\",\n"
+ " \"AffectedFields\":[\"dt\",\"dn\"],\n"
+ " \"Logic\":{\n"
+ " \"and\": [\n"
+ " {\">=\":[ {\"var\":\"dt\"}, \"2021-06-01T00:00:00Z\" ]},\n"
+ " {\">=\":[ {\"var\":\"dn\"}, 2 ]}\n"
+ " ]\n"
+ " }\n"
+ "}")
@ExampleObject(value = """
{
"Identifier": "VR-DE-1",
"Version": "1.0.0",
"SchemaVersion":"1.0.0",
"Engine":"CERTLOGIC",
"EngineVersion":"1.0.0",
"Type":"Acceptance",
"Country":"DE",
"CertificateType":"Vaccination",
"Description":[{"lang":"en","desc":"Vaccination must be from June and doses must be 2"}],
"ValidFrom":"2021-06-27T07:46:40Z",
"ValidTo":"2021-08-01T07:46:40Z",
"AffectedFields":["dt","dn"],
"Logic":{
"and": [
{">=":[ {"var":"dt"}, "2021-06-01T00:00:00Z" ]},
{">=":[ {"var":"dn"}, 2 ]}
]
}
}""")
})),
@ApiResponse(
responseCode = "400",
Expand Down
Loading

0 comments on commit 728c42e

Please sign in to comment.