Skip to content

Commit

Permalink
XTR v3.0.1-alpha
Browse files Browse the repository at this point in the history
XRoad REST request/response mapping

Included are 3 basic DSL-s to support public XRoad services
of Estonian Business Registry.
  • Loading branch information
RayDNoper committed Jun 27, 2024
1 parent f4866da commit b22e4d5
Show file tree
Hide file tree
Showing 39 changed files with 846 additions and 2 deletions.
Empty file added .env
Empty file.
Binary file added .gradle/8.8/checksums/checksums.lock
Binary file not shown.
Binary file added .gradle/8.8/checksums/md5-checksums.bin
Binary file not shown.
Binary file added .gradle/8.8/checksums/sha1-checksums.bin
Binary file not shown.
Empty file.
Binary file not shown.
Binary file added .gradle/8.8/executionHistory/executionHistory.lock
Binary file not shown.
Binary file added .gradle/8.8/fileChanges/last-build.bin
Binary file not shown.
Binary file added .gradle/8.8/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added .gradle/8.8/fileHashes/fileHashes.lock
Binary file not shown.
Binary file added .gradle/8.8/fileHashes/resourceHashesCache.bin
Binary file not shown.
Empty file added .gradle/8.8/gc.properties
Empty file.
Binary file added .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 2 additions & 0 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Tue Jun 04 16:36:32 EEST 2024
gradle.version=8.8
Binary file added .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file added .gradle/file-system.probe
Binary file not shown.
Empty file added .gradle/vcs-1/gc.properties
Empty file.
26 changes: 26 additions & 0 deletions DSL/ar/detailandmed_v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
params:
- reg_code
- username
- password

service: https://ariregxmlv6.rik.ee/
method: POST

envelope: >
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xro="http://x-road.eu/xsd/xroad.xsd" xmlns:iden="http://x-road.eu/xsd/identifiers" xmlns:prod="http://arireg.x-road.eu/producer/">
<soapenv:Body>
<prod:detailandmed_v2>
<prod:keha>
<prod:ariregister_kasutajanimi>{{username}}</prod:ariregister_kasutajanimi>
<prod:ariregister_parool>{{password}}</prod:ariregister_parool>
<prod:ariregistri_kood>{{reg_code}}</prod:ariregistri_kood>
<prod:yandmed>1</prod:yandmed>
<prod:iandmed>1</prod:iandmed>
<prod:kandmed>0</prod:kandmed>
<prod:dandmed>0</prod:dandmed>
<prod:maarused>0</prod:maarused>
</prod:keha>
</prod:detailandmed_v2>
</soapenv:Body>
</soapenv:Envelope>
17 changes: 17 additions & 0 deletions DSL/ar/ettevottegaSeotudIsikud_v1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
params:
- reg_code

service: https://ariregxmlv6.rik.ee/
method: POST

envelope: >
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="http://arireg.x-road.eu/producer/">
<soapenv:Header/>
<soapenv:Body>
<prod:ettevottegaSeotudIsikud_v1>
<prod:keha>
<prod:ariregistri_kood>{{reg_code}}</prod:ariregistri_kood>
</prod:keha>
</prod:ettevottegaSeotudIsikud_v1>
</soapenv:Body>
</soapenv:Envelope>
22 changes: 22 additions & 0 deletions DSL/ar/lihtandmed_v3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
params:
- reg_code
- username
- password

service: https://ariregxmlv6.rik.ee/
method: POST

envelope: >
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:iden="http://x-road.eu/xsd/identifiers" xmlns:prod="http://arireg.x-road.eu/producer/" xmlns:xro="http://x-road.eu/xsd/xroad.xsd">
<soapenv:Body>
<prod:lihtandmed_v3>
<prod:keha>
<prod:ariregister_kasutajanimi>{{username}}</prod:ariregister_kasutajanimi>
<prod:ariregister_parool>{{password}}</prod:ariregister_parool>
<prod:ariregistri_kood>{{reg_code}}</prod:ariregistri_kood>
</prod:keha>
</prod:lihtandmed_v3>
</soapenv:Body>
</soapenv:Envelope>
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM eclipse-temurin:17-jdk AS build
WORKDIR /workspace/app

COPY gradlew .
COPY gradlew.bat .
COPY gradle gradle
COPY build.gradle .
COPY src src
COPY .env .env
COPY DSL DSL

RUN chmod 754 ./gradlew
RUN ./gradlew -Pprod clean bootJar
RUN mkdir -p build/libs && (cd build/libs; jar -xf *.jar)

FROM eclipse-temurin:17-jdk
VOLUME /build/tmp

ARG DEPENDENCY=/workspace/app/build/libs
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app
COPY DSL /DSL

ENV application.dslPath=/DSL

COPY .env /app/.env
RUN echo BUILDTIME=`date +%s` >> /app/.env

RUN adduser xtr
RUN chown -R xtr:xtr /app
RUN chown -R xtr:xtr /DSL
USER xtr

EXPOSE 9010

ENTRYPOINT ["java","-cp","app:app/lib/*","ee.buerokratt.xtr.XTRApplication"]
25 changes: 25 additions & 0 deletions HELP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Getting Started

### Reference Documentation
For further reference, please consider the following sections:

* [Official Gradle documentation](https://docs.gradle.org)
* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.3.0/gradle-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.3.0/gradle-plugin/reference/html/#build-image)
* [Spring Web Services](https://docs.spring.io/spring-boot/docs/3.3.0/reference/htmlsingle/index.html#io.webservices)
* [Spring Web](https://docs.spring.io/spring-boot/docs/3.3.0/reference/htmlsingle/index.html#web)
* [Spring Configuration Processor](https://docs.spring.io/spring-boot/docs/3.3.0/reference/htmlsingle/index.html#appendix.configuration-metadata.annotation-processor)

### Guides
The following guides illustrate how to use some features concretely:

* [Producing a SOAP web service](https://spring.io/guides/gs/producing-web-service/)
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)

### Additional Links
These additional references should also help you:

* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle)

27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# XTR
X-Road requests and responses as REST
# XTR v3
### REST request/response mappings for XRoad SOAP requests

### Services

Services are defined as YAML-formatted DSLs in folder specified in `application.dslPath` property.

The directory format should be `<DSLpath>/<service provider>/<service name>`.

```yaml
params:
- <list of allowed parameters>
service: <uri of service>
method: <GET|POST>

envelope: <XRoad envelope as XML>
```
* `envelope` can contain handlebars mappings for parameters
* Only parameters specified in `params` will be applied for handlebars mappings

All services are served as POST endpoints.

POST /<service provider>/<service_name>

with optiona parameters as JSON object in request body.
45 changes: 45 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.0'
id 'io.spring.dependency-management' version '1.1.5'
}

group = 'ee.buerokratt'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-web-services'
implementation 'wsdl4j:wsdl4j'

implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.0'
implementation 'com.github.jknack:handlebars:4.4.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.0'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.15.0'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
useJUnitPlatform()
}


19 changes: 19 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.9'
services:
xtr:
container_name: xtr
build:
context: .
ports:
- 9020:8080
volumes:
- ./DSL:/DSL
networks:
- bykstack

networks:
bykstack:
name: bykstack
driver: bridge
driver_opts:
com.docker.network.driver.mtu: 1400
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit b22e4d5

Please sign in to comment.