Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/26423 fixed default base-path for api and improvements made to the readme #22

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 59 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
# CDR Client
The Swisscom Health Confidential Data Routing (CDR) Client

## Installation / Run the client
> Improvements for the installation are planned. For now, the client is only available as a jar file with manual steps required for the installation.

Pre-Requirements:
* Java 17 (or higher) installed

Go to the [releases](https://github.com/swisscom/cdr-client/releases) github page and click on the maven assets for the newest release:
![releases assets overview](./installation/releases-overview.png)
Download the jar file:
![release jar download](./installation/single-release-overview.png)
Place a file named application-customer.yaml in the same directory as the jar file.
The application-customer.yaml file should contain the configuration for the client.
An example can be found [here](#application-customer-yaml-example).

Open a terminal and navigate to the directory where the jar file is located.
Run the following command to start the client (check the jar name and replace it in the command or rename the jar itself):
> The -D parameters need to be placed before the "-jar cdr-client.jar".<p>
> The quotes are necessary for Windows, but not for Unix systems
```shell
java "-Dspring.profiles.active=customer" "-Dspring.config.additional-location=./application-customer.yaml" -jar cdr-client.jar
```

Check that no error messages are present in the terminal (or have a look at the "cdr-client.log" file that is created in the same folder as you've placed tha jar file)
and that the client is running.

Configure an OS appropriate service to run the client as a background service.

## API
There is no endpoint (beside actuator/health) that are offered here.
There is no endpoint offered here.

The CDR Client is triggered by a scheduler and synchronizes by the given delay time the files from the CDR API.
The CDR Client is triggered by a scheduler and downloads by the given delay time the files from the CDR API.
File uploads are triggered by the file system events.

### Functionality
For each defined connector the CDR Client calls the defined endpoint of the CDR API.
Expand Down Expand Up @@ -62,18 +90,7 @@ To create scripts to run the application locally one needs to run following grad
This creates a folder ```build/install/cdr-client``` with scripts for windows and unix servers in the ```bin``` folder.

To run the application locally one can call ```./build/install/cdr-client/bin/cdr-client```. It is required to have a ```application-customer.yaml``` and link it by adding following command line: ```JVM_OPTS="-Dspring.config.additional-location=./application-customer.yaml"```.
With a minimum configuration that looks like this:
```
client:
endpoint:
host: cdr.health.swisscom.com
customer:
- connector-id: 8000000000000
content-type: application/forumdatenaustausch+xml;charset=UTF-8
target-folder: /tmp/download/8000000000000
source-folder: /tmp/source/8000000000000
mode: test
```
With a configuration that looks like [this](#application-customer-yaml-example).

## Running the Jar
If the provided jar should be run directly, the following command can be used:
Expand All @@ -88,3 +105,31 @@ LOGGING_FILE_NAME={{ cdr_client_dir }}/logs/cdr-client.log"
The LOGGING_FILE_NAME is just so that the log file is not auto created where the jar is run from.

See [Application Plugin](#application-plugin) regarding the content of the application-customer.yaml

## application-customer yaml example
```
client:
local-folder: /tmp/download/in-flight # temporary folder for files that are currently downloaded from CDR API
idp-credentials:
tenant-id: swisscom-health-tenant-id # provided by Swisscom Health
client-id: my-client-id # Self created through CDR UI
client-secret: my-secret # Self created through CDR UI
endpoint:
host: cdr.health.swisscom.ch
customer:
- connector-id: 8000000000000 # provided by Swisscom Health
content-type: application/forumdatenaustausch+xml;charset=UTF-8
target-folder: /tmp/download/test/8000000000000
source-folder: /tmp/upload/test/8000000000000
mode: test
- connector-id: 8000000000000 # provided by Swisscom Health
content-type: application/forumdatenaustausch+xml;charset=UTF-8
target-folder: /tmp/download/8000000000000
source-folder: /tmp/upload/8000000000000
mode: production

```

Some information can also be set as environment variables. See [application-client.yaml](./src/main/resources/config/application-client.yaml) for variable names.

If the host is not set to production, but to stg instead, then the CDR_CLIENT_SCOPE_PREFIX environment variable needs to be set to "tst.".
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ idea {
}

application {
mainClass = "com.swisscom.health.des.cdr.clientvm.CdrClientApplicationKt"
mainClass = "com.swisscom.health.des.cdr.client.CdrClientApplicationKt"
applicationDefaultJvmArgs = listOf("-Dspring.profiles.active=client,customer")
}
dependencyManagement {
Expand Down Expand Up @@ -132,7 +132,7 @@ val jacocoTestCoverageVerification = tasks.named<JacocoCoverageVerification>("ja
classDirectories.setFrom(files(classDirectories.files.map {
fileTree(it) {
setExcludes(listOf(
"**/com/swisscom/health/des/cdr/clientvm/msal4j/*.class"
"**/com/swisscom/health/des/cdr/client/msal4j/*.class"
))
}
}))
Expand Down
4 changes: 2 additions & 2 deletions docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ services:
depends_on:
wiremock:
condition: service_healthy
image: local.caddy.cdrappmgr
container_name: caddy-app-mgr
image: local.caddy.cdrclient
container_name: caddy-cdr-client
build: ./caddy
mem_limit: 256m
ports:
Expand Down
Binary file added installation/releases-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added installation/single-release-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.swisscom.health.des.cdr.clientvm
package com.swisscom.health.des.cdr.client

import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig
import com.swisscom.health.des.cdr.client.config.CdrClientConfig
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.runApplication
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.swisscom.health.des.cdr.clientvm
package com.swisscom.health.des.cdr.client

import io.micrometer.tracing.Span
import io.micrometer.tracing.Tracer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.swisscom.health.des.cdr.clientvm.config
package com.swisscom.health.des.cdr.client.config

import io.github.oshai.kotlinlogging.KotlinLogging
import jakarta.annotation.PostConstruct
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.swisscom.health.des.cdr.clientvm.config
package com.swisscom.health.des.cdr.client.config

import com.mayakapps.kache.InMemoryKache
import com.mayakapps.kache.KacheStrategy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.swisscom.health.des.cdr.clientvm.handler
package com.swisscom.health.des.cdr.client.handler

import com.microsoft.aad.msal4j.ClientCredentialParameters
import com.microsoft.aad.msal4j.IAuthenticationResult
import com.microsoft.aad.msal4j.IConfidentialClientApplication
import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig
import com.swisscom.health.des.cdr.client.config.CdrClientConfig
import io.github.oshai.kotlinlogging.KLogger
import io.github.oshai.kotlinlogging.KotlinLogging
import io.micrometer.tracing.Tracer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.swisscom.health.des.cdr.clientvm.handler
package com.swisscom.health.des.cdr.client.handler

import com.microsoft.aad.msal4j.ClientCredentialParameters
import com.microsoft.aad.msal4j.IConfidentialClientApplication
import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig
import com.swisscom.health.des.cdr.client.config.CdrClientConfig
import io.github.oshai.kotlinlogging.KotlinLogging
import io.micrometer.tracing.Tracer
import okhttp3.Headers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.swisscom.health.des.cdr.clientvm.handler
package com.swisscom.health.des.cdr.client.handler

import com.mayakapps.kache.ObjectKache
import com.microsoft.aad.msal4j.ClientCredentialParameters
import com.microsoft.aad.msal4j.IConfidentialClientApplication
import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig
import com.swisscom.health.des.cdr.client.config.CdrClientConfig
import io.github.oshai.kotlinlogging.KotlinLogging
import io.micrometer.tracing.Tracer
import kotlinx.coroutines.delay
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.swisscom.health.des.cdr.clientvm.scheduling
package com.swisscom.health.des.cdr.client.scheduling

import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig
import com.swisscom.health.des.cdr.clientvm.handler.PullFileHandling
import com.swisscom.health.des.cdr.clientvm.handler.pathIsDirectoryAndWritable
import com.swisscom.health.des.cdr.client.config.CdrClientConfig
import com.swisscom.health.des.cdr.client.handler.PullFileHandling
import com.swisscom.health.des.cdr.client.handler.pathIsDirectoryAndWritable
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.swisscom.health.des.cdr.clientvm.scheduling
package com.swisscom.health.des.cdr.client.scheduling

import com.mayakapps.kache.ObjectKache
import com.swisscom.health.des.cdr.clientvm.TraceSupport.continueSpan
import com.swisscom.health.des.cdr.clientvm.TraceSupport.startSpan
import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig
import com.swisscom.health.des.cdr.clientvm.handler.PushFileHandling
import com.swisscom.health.des.cdr.client.TraceSupport.continueSpan
import com.swisscom.health.des.cdr.client.TraceSupport.startSpan
import com.swisscom.health.des.cdr.client.config.CdrClientConfig
import com.swisscom.health.des.cdr.client.handler.PushFileHandling
import io.github.irgaly.kfswatch.KfsDirectoryWatcher
import io.github.irgaly.kfswatch.KfsDirectoryWatcherEvent
import io.github.irgaly.kfswatch.KfsEvent
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config/application-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ client:
scheme: https
port: 443
# host: dev-cdr-functions.azurewebsites.net
base-path: documents
base-path: api/documents
customer:
# MUST BE SET IN ENVIRONMENT
# - connector-id: 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.swisscom.health.des.cdr.clientvm
package com.swisscom.health.des.cdr.client

import org.junit.jupiter.api.extension.AnnotatedElementContext
import org.junit.jupiter.api.extension.ExtensionContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.swisscom.health.des.cdr.clientvm
package com.swisscom.health.des.cdr.client

import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.BeforeAll
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.swisscom.health.des.cdr.clientvm
package com.swisscom.health.des.cdr.client

import com.microsoft.aad.msal4j.ClientCredentialParameters
import com.microsoft.aad.msal4j.IAuthenticationResult
import com.microsoft.aad.msal4j.IConfidentialClientApplication
import com.microsoft.aad.msal4j.TokenSource
import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig
import com.swisscom.health.des.cdr.clientvm.handler.CONNECTOR_ID_HEADER
import com.swisscom.health.des.cdr.clientvm.handler.PULL_RESULT_ID_HEADER
import com.swisscom.health.des.cdr.clientvm.handler.PullFileHandling
import com.swisscom.health.des.cdr.clientvm.scheduling.DocumentDownloadScheduler
import com.swisscom.health.des.cdr.client.config.CdrClientConfig
import com.swisscom.health.des.cdr.client.handler.CONNECTOR_ID_HEADER
import com.swisscom.health.des.cdr.client.handler.PULL_RESULT_ID_HEADER
import com.swisscom.health.des.cdr.client.handler.PullFileHandling
import com.swisscom.health.des.cdr.client.scheduling.DocumentDownloadScheduler
import io.micrometer.tracing.Span
import io.micrometer.tracing.TraceContext
import io.micrometer.tracing.Tracer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.swisscom.health.des.cdr.clientvm.config
package com.swisscom.health.des.cdr.client.config

import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig.IdpCredentials
import com.swisscom.health.des.cdr.client.config.CdrClientConfig.IdpCredentials
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.swisscom.health.des.cdr.clientvm.handler
package com.swisscom.health.des.cdr.client.handler

import com.mayakapps.kache.ObjectKache
import com.microsoft.aad.msal4j.ClientCredentialParameters
import com.microsoft.aad.msal4j.IAuthenticationResult
import com.microsoft.aad.msal4j.IConfidentialClientApplication
import com.microsoft.aad.msal4j.TokenSource
import com.ninjasquad.springmockk.SpykBean
import com.swisscom.health.des.cdr.clientvm.AlwaysSameTempDirFactory
import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig
import com.swisscom.health.des.cdr.client.AlwaysSameTempDirFactory
import com.swisscom.health.des.cdr.client.config.CdrClientConfig
import io.mockk.every
import io.mockk.mockk
import kotlinx.coroutines.runBlocking
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.swisscom.health.des.cdr.clientvm.handler
package com.swisscom.health.des.cdr.client.handler

import io.github.oshai.kotlinlogging.KotlinLogging
import org.junit.jupiter.api.Assertions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.swisscom.health.des.cdr.clientvm.handler
package com.swisscom.health.des.cdr.client.handler

import com.mayakapps.kache.ObjectKache
import com.microsoft.aad.msal4j.ClientCredentialParameters
import com.microsoft.aad.msal4j.IAuthenticationResult
import com.microsoft.aad.msal4j.IConfidentialClientApplication
import com.microsoft.aad.msal4j.TokenSource
import com.ninjasquad.springmockk.SpykBean
import com.swisscom.health.des.cdr.clientvm.AlwaysSameTempDirFactory
import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig
import com.swisscom.health.des.cdr.client.AlwaysSameTempDirFactory
import com.swisscom.health.des.cdr.client.config.CdrClientConfig
import io.mockk.every
import io.mockk.mockk
import kotlinx.coroutines.runBlocking
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.swisscom.health.des.cdr.clientvm.handler
package com.swisscom.health.des.cdr.client.handler

import com.microsoft.aad.msal4j.ClientCredentialParameters
import com.microsoft.aad.msal4j.IConfidentialClientApplication
import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig
import com.swisscom.health.des.cdr.client.config.CdrClientConfig
import io.micrometer.tracing.Span
import io.micrometer.tracing.TraceContext
import io.micrometer.tracing.Tracer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.swisscom.health.des.cdr.clientvm.scheduling
package com.swisscom.health.des.cdr.client.scheduling

import com.swisscom.health.des.cdr.clientvm.config.CdrClientConfig
import com.swisscom.health.des.cdr.clientvm.handler.PullFileHandling
import com.swisscom.health.des.cdr.client.config.CdrClientConfig
import com.swisscom.health.des.cdr.client.handler.PullFileHandling
import io.micrometer.tracing.Span
import io.micrometer.tracing.TraceContext
import io.micrometer.tracing.Tracer
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/application-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ client:
- connector-id: 1
content-type: application/forumdatenaustausch+xml;charset=UTF-8
target-folder: ${java.io.tmpdir}
source-folder: ${java.io.tmpdir}/cdr-client-test-source # If you change this, then you need to change com.swisscom.health.des.cdr.clientvm.AlwaysSameTempDirFactory as well
source-folder: ${java.io.tmpdir}/cdr-client-test-source # If you change this, then you need to change com.swisscom.health.des.cdr.client.AlwaysSameTempDirFactory as well
mode: test
Loading