This repository has been archived by the owner on Sep 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from admin-ch/develop
Release 1.0.0
- Loading branch information
Showing
30 changed files
with
309 additions
and
157 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Swiss Admin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# CC-API-Gateway-Service | ||
TODO | ||
# CovidCertificate-API-Gateway-Service | ||
|
||
The API gateway service provides an API for third party systems. | ||
|
||
This project is released by the the Federal Office of Information Technology, Systems and Telecommunication FOITT on behalf of the Federal Office of Public Health FOPH. | ||
|
||
## Lombok | ||
Project uses Lombok. Configure your IDE with lombok plugin. | ||
|
||
## Local development | ||
TODO |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3' | ||
services: | ||
db-api-gateway: | ||
image: postgres | ||
ports: | ||
- "3121:5432" | ||
environment: | ||
- POSTGRES_USER=cc-api-gateway | ||
- POSTGRES_PASSWORD=secret | ||
- POSTGRES_DB=cc-api-gateway |
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
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
27 changes: 27 additions & 0 deletions
27
src/main/java/ch/admin/bag/covidcertificate/gateway/domain/KpiData.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ch.admin.bag.covidcertificate.gateway.domain; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
import java.time.LocalDateTime; | ||
import java.util.UUID; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
@Table(name = "kpi") | ||
public class KpiData { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
UUID id; | ||
LocalDateTime timestamp; | ||
String type; | ||
String value; | ||
|
||
public KpiData(LocalDateTime timestamp, String type, String value) { | ||
this.timestamp = timestamp; | ||
this.type = type; | ||
this.value = value; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/ch/admin/bag/covidcertificate/gateway/domain/KpiDataRepository.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package ch.admin.bag.covidcertificate.gateway.domain; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.UUID; | ||
|
||
public interface KpiDataRepository extends JpaRepository<KpiData, UUID> { | ||
} |
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
6 changes: 2 additions & 4 deletions
6
src/main/java/ch/admin/bag/covidcertificate/gateway/error/RestError.java
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
32 changes: 32 additions & 0 deletions
32
...main/java/ch/admin/bag/covidcertificate/gateway/filters/CachedBodyHttpServletRequest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ch.admin.bag.covidcertificate.gateway.filters; | ||
|
||
import org.springframework.util.StreamUtils; | ||
|
||
import javax.servlet.ServletInputStream; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletRequestWrapper; | ||
import java.io.*; | ||
|
||
public class CachedBodyHttpServletRequest extends HttpServletRequestWrapper { | ||
|
||
private byte[] cachedBody; | ||
|
||
public CachedBodyHttpServletRequest(HttpServletRequest request) throws IOException { | ||
super(request); | ||
InputStream requestInputStream = request.getInputStream(); | ||
this.cachedBody = StreamUtils.copyToByteArray(requestInputStream); | ||
} | ||
|
||
@Override | ||
public ServletInputStream getInputStream() { | ||
return new CachedBodyServletInputStream(this.cachedBody); | ||
} | ||
|
||
@Override | ||
public BufferedReader getReader() { | ||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(this.cachedBody); | ||
return new BufferedReader(new InputStreamReader(byteArrayInputStream)); | ||
} | ||
|
||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...main/java/ch/admin/bag/covidcertificate/gateway/filters/CachedBodyServletInputStream.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package ch.admin.bag.covidcertificate.gateway.filters; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import javax.servlet.ReadListener; | ||
import javax.servlet.ServletInputStream; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
@Slf4j | ||
public class CachedBodyServletInputStream extends ServletInputStream { | ||
|
||
private final InputStream cachedBodyInputStream; | ||
|
||
public CachedBodyServletInputStream(byte[] cachedBody) { | ||
this.cachedBodyInputStream = new ByteArrayInputStream(cachedBody); | ||
} | ||
|
||
@Override | ||
public int read() throws IOException { | ||
return cachedBodyInputStream.read(); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
try { | ||
return cachedBodyInputStream.available() == 0; | ||
} catch (IOException e) { | ||
log.error("Exception during reading", e); | ||
throw new IllegalStateException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isReady() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void setReadListener(ReadListener readListener) { | ||
//Method not used | ||
} | ||
} |
95 changes: 0 additions & 95 deletions
95
src/main/java/ch/admin/bag/covidcertificate/gateway/filters/CustomHttpRequestWrapper.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.