Skip to content
Snippets Groups Projects
Commit 90617426 authored by Kedar Naik's avatar Kedar Naik Committed by santosh kanase
Browse files

1.0.0-sdv-dco

parent f6386cd0
No related branches found
No related tags found
1 merge request!11.0.0-sdv-dco
Showing
with 2688 additions and 61 deletions
#!/bin/bash -e
banner_head()
{
echo "+------------------------------------------+"
printf "| %-40s |\n" "`date`"
echo "| |"
printf "\033[35m|`tput bold``tput rev` %+30s `tput sgr0`\033[0m|\n" "$@"
echo "+------------------------------------------+"
}
banner_head Developer-Console
sleep 3
printf -- '\033[35m \x1b[1m ~ ~ ~ ~ ~ Installing all dependencies/library ~ ~ ~ ~ ~ \033[0m\n'
yarn --cwd ./developer-console-ui/app install
printf -- '\033[32m \x1b[1m ~ ~ ~ ~ ~ Installation is completed ~ ~ ~ ~ ~ \033[0m\n\n'
printf -- '\033[35m \x1b[1m ~ ~ ~ ~ ~ dco-gateway build start ~ ~ ~ ~ ~ \033[0m\n'
yarn --cwd ./developer-console-ui/app build
printf -- '\033[32m \x1b[1m ~ ~ ~ ~ ~ developer-console-ui build successful ~ ~ ~ ~ ~ \033[0m\n\n'
sleep 3
printf -- '\033[35m \x1b[1m ~ ~ ~ ~ ~ dco-gateway build start ~ ~ ~ ~ ~ \033[0m\n'
mvn clean verify \
--batch-mode \
--file dco-gateway/pom.xml \
--settings dco-gateway/settings.xml
printf -- '\033[32m \x1b[1m ~ ~ ~ ~ ~ dco-gateway build successful ~ ~ ~ ~ ~ \033[0m\n\n'
sleep 3
printf -- '\033[35m \x1b[1m ~ ~ ~ ~ ~ scenario-library-service build start ~ ~ ~ ~ ~ \033[0m\n'
mvn clean verify \
--batch-mode \
--file scenario-library-service/pom.xml \
--settings scenario-library-service/settings.xml
printf -- '\033[32m \x1b[1m ~ ~ ~ ~ ~ scenario-library-service build successful~ ~ ~ ~ ~ \033[0m\n\n'
sleep 3
printf -- '\033[35m \x1b[1m ~ ~ ~ ~ ~ tracks-management-service build start ~ ~ ~ ~ ~ \033[0m\n'
mvn clean verify \
--batch-mode \
--file tracks-management-service/pom.xml \
--settings tracks-management-service/settings.xml
printf -- '\033[32m \x1b[1m ~ ~ ~ ~ ~ tracks-management-service build successful ~ ~ ~ ~ ~ \033[0m\n\n\n'
sleep 3
printf -- '\033[35m \x1b[1m ~ ~ ~ ~ ~ Start Minio ~ ~ ~ ~ ~ \033[0m\n'
[ -e minio/minio_keys.env ] && rm -rf minio/minio_keys.env
touch minio/minio_keys.env
docker compose up -d minio
docker compose ls
docker compose ps
if [ $( docker ps -a | grep minio | wc -l ) -gt 0 ]; then
printf -- '\033[32m \x1b[1m ~ ~ ~ ~ ~ minio is running ~ ~ ~ ~ ~ \033[0m\n\n'
printf -- '\033[32m \x1b[1m You can access minio s3 using http://localhost:9001 url.
The admin user is "minioadmin" and default password is "minioadmin" \033[0m\n\n'
tput rev
printf -- '\033[35m \x1b[1m Create 'dco-scenario-library-service' bucket and Access key, Secret Key in minio and run deploy script as per the documentation. \033[0m\n\n'
tput sgr0
else
printf -- '\033[31m \x1b[1m ~ ~ ~ ~ ~ minio container is missing ~ ~ ~ ~ ~ \033[0m\n'
fi
printf -- '\033[32m \x1b[1m For deployment, continue from step 3 from Build and Deploy section once you are done with Minio configuration \033[0m\n\n'
#!/bin/bash -e
help()
{
# Display Help
echo
printf -- '\033[31m \x1b[1m ~ ~ ~ ~ ~ Wrong Syntax ~ ~ ~ ~ ~ \033[0m\n'
echo "Argument access-key or secrete-key is missing."
echo
printf -- '\033[32m \x1b[1m ~ ~ ~ ~ ~ Help ~ ~ ~ ~ ~ \033[0m\n'
echo "Syntax:"
echo "sh 20-deploy-script.sh <access-key> <secrete-key> "
echo
echo "Description:"
echo "access-key Minio Access Key."
echo "secrete-key Minio Secret Key."
echo
}
if [ -z "$1" ]
then
help
exit 1;
fi
if [ -z "$2" ]
then
help
exit 1;
fi
echo "APP_STORAGE_ACCESS_KEY: $1" >> minio/minio_keys.env
echo "APP_STORAGE_SECRET_KEY: $2" >> minio/minio_keys.env
cat minio/minio_keys.env
docker compose up -d
docker compose ls
docker compose ps
app=( postgres pgadmin developer-console-ui dco-gateway scenario-library-service tracks-management-service )
arraylength=${#app[@]}
for (( i=0; i<${arraylength}; i++ ));
do
if [ $( docker ps -a | grep ${app[i]} | wc -l ) -gt 0 ]; then
printf -- '\033[32m \x1b[1m ~ ~ ~ ~ ~ '${app[i]}' is running ~ ~ ~ ~ ~ \033[0m\n\n\n'
else
printf -- '\033[31m \x1b[1m ~ ~ ~ ~ ~ '${app[i]}' container is missing ~ ~ ~ ~ ~ \033[0m\n\n\n'
fi
done
printf -- '\033[32m \x1b[1m Below are important urls that you can use to access application, swagger and playground for REST APIs \033[0m\n\n'
printf -- '\033[32m \x1b[1m -> Developer Console UI: http://localhost:3000 \033[0m\n\n'
printf -- '\033[32m \x1b[1m -> dco-gatway playground for REST APIs: http://localhost:8080/playground \033[0m\n\n'
printf -- '\033[32m \x1b[1m -> tracks-management-service swagger for REST APIs: http://localhost:8081/openapi/swagger-ui/index.html \033[0m\n\n'
printf -- '\033[32m \x1b[1m -> scenario-library-service swagger for REST APIs: http://localhost:8082/openapi/swagger-ui/index.html \033[0m\n\n'
printf -- '\033[32m \x1b[1m -> pgadmin client for postgresql database: http://localhost:5050. The username is "admin@default.com" and password is "admin" \033[0m\n\n'
printf -- '\033[32m \x1b[1m For more details, please refer the README.md file \033[0m\n\n'
\ No newline at end of file
#!/bin/bash -e
docker compose down --remove-orphans
cd minio
docker compose down --remove-orphans
app=( developer-console-ui dco-gateway scenario-library-service tracks-management-service postgres dpage/pgadmin4 minio )
image=( developer-console-ui:1.0 dco-gateway:1.0 scenario-library-service:1.0 tracks-management-service:1.0 postgres:1.0 dpage/pgadmin4:latest minio:1.0)
arraylength=${#app[@]}
for (( i=0; i<${arraylength}; i++ ));
do
if [ $( docker images | grep ${app[i]} | wc -l ) -gt 0 ]; then
docker rmi ${image[i]}
printf -- '\033[32m \x1b[1m ~ ~ ~ ~ ~ Deleted '${image[i]}' image from local ~ ~ ~ ~ ~ \033[0m\n'
else
printf -- '\033[31m \x1b[1m ~ ~ ~ ~ ~ No '${image[i]}' image available on local ~ ~ ~ ~ ~ \033[0m\n'
fi
done
Contributing to Eclipse SDV Developer Console
======================
Thanks for your interest in this project.
Project description:
--------------------
The Eclipse- SDV Developer Console, part of T-System's Hybercube portfolio, addresses challenges faced by OEMs in software development, testing, and simulation in the automotive industry.
Hypercube aims to accelerate time-to-market for new features by automating and standardizing software components. The Developer Console helps solve business challenges related to decreasing logistical costs, managing changing demands, and improving time, cost, and quality of tests and simulations. It provides a solution for managing simulations of software-defined vehicle components throughout the software lifecycle, including creating simulation objects, simulation setup, and execution.
eTrice The ultimate goal is to encourage the use of Hybercube and open source solutions to transform vehicles into software-defined vehicles and create new use cases and integrations for a connected world.
Simulation is an essential tool in OTA updates for vehicles because it allows OEM to test and validate software updates in a virtual environment before deploying them to vehicles in the field. By simulating different vehicle components and systems, OEM's can identify potential issues or conflicts that may arise during the OTA update process and make modifications to ensure that the update is delivered seamlessly to the vehicle.
Some of Example of Simulations like Functional Simulation ,Performance Simulations, Security Simulations, Compatibility Simulations.
To Create Simulation, prerequisite it to Create/use existing 1) Track/s and 2) Scenario.
A Simulation includes :
one or many scenario files (simulation object) in a specific order one track (simulation setup)
Thus, the simulation include the reference to the track and scenario, and request.
Developer resources:
--------------------
Information regarding source code management, builds, coding standards, and more about SDV- Developer Console.
- https://gitlab.eclipse.org/eclipse/dco
The SDV DCO code is stored in a git repository.
https://gitlab.eclipse.org/eclipse/dco
You can contribute bugfixes and new features by sending pull requests through GitHub.
Legal:
------------------------------
In order for your contribution to be accepted, it must comply with the Eclipse Foundation IP policy.
Please read the Eclipse Foundation policy on accepting contributions via Git.
1. Sign the Eclipse ECA
1. Register for an Eclipse Foundation User ID. You can register here.
2. Log into the Accounts Portal, and click on the 'Eclipse Contributor Agreement' link.
2. Go to your account settings and add your GitHub username to your account.
3. Make sure that you sign-off your Git commits in the following format: Signed-off-by: John Smith <johnsmith@nowhere.com> This is usually at the bottom of the commit message. You can automate this by adding the '-s' flag when you make the commits. e.g. git commit -s -m "Adding a cool feature"
4. Ensure that the email address that you make your commits with is the same one you used to sign up to the Eclipse Foundation website with.
Before your contribution can be accepted by the project, you need to create and electronically sign the Eclipse Foundation Contributor License Agreement (CLA).
- http://www.eclipse.org/legal/ECA.php
Contributing a change
------------------------------
Please refer below steps to contribute SDV DCO
1. Clone the repository onto your computer: git clone https://gitlab.eclipse.org/eclipse/dco/developer-console.git
2. Change the working directory to developer-console
3. Create a new branch from the latest master branch.
4. Please use below prefixes while creating a new branch with git checkout -b {prefix}/{your-branch-name}
a) If you are adding a new feature, then use git checkout -b feat/{your-branch-name}
b) If you are fixing some bug, then use git checkout -b fix/your-branch-name
c) If you are doing configuration/ci related changes, then use git checkout -b ci/{your-branch-name}
d) If you are doing documentation related changes, then use git checkout -b docs/{your-branch-name}
1. Ensure that all new and existing tests pass.
2. Commit the changes into the branch using below commands:
a) git add .
b) git commit -m "meaningful-commit--message"
c) git push
3. Once you push the changes to remote feature branch, raise a merge request on Gitlab to merge the code to main branch
4. Make sure that your commit message is meaningful and describes your changes correctly.
5. If you have a lot of commits for the change, squash them into a single commit.
6. Add "Santosh Kanase" user as a reviewer while raising a merge request.
##### What happens next?
Depends on the changes done by the contributor. If it is 100% authored by the contributor and meets the needs of the project, then it become eligile for the inclusion into the main repository. If you need more specific information/details, please consult with DCO owner through mailing-list. You can refer contact section.
Contact:
--------
Contact the project developers via the project's "dev" list.
- https://accounts.eclipse.org/mailing-list/dco-dev
Search for bugs:
----------------
This project uses Bugzilla to track ongoing development and issues.
- https://bugs.eclipse.org/bugs/buglist.cgi?product=DCO
Create a new bug:
-----------------
Be sure to search for existing bugs before you create another one. Remember that contributions are always welcome!
- https://bugs.eclipse.org/bugs/enter_bug.cgi?product=DCO
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [2023] [T-Systems]
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
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
# developer-console
# Developer-Console
![Alt text](images/sdv-dco-logo.png)
## Description
SDV-Developer Console(DCO) integrates all necessary sources for software lifecycle management and thereby optimizes the complete process from development to release of software. Our core of DCO includes services for development, testing, simulations, release and lifecycle management of software. Hereby, SDV-DCOs mission is to automize as much as possible by using different concepts of re-usability and standardization by connecting different business roles along the software lifecycle on one source. As our open-source contribution, we focus on simulation of services with SDV DCO - it includes
* Developer Console UI
* Track Management
* Scenario Library
* New Simulation
SDV- DCO enables the user with advanced user interface to plan, prepare, execute and monitor simulations of scenarios – from vehicle & fleet behaviour to services for software defined vehicles. Everyone, can create scenarios as well as simulations of these scenarios, with integrating third-party solutions and services for instance simulators, virtual vehicle repositories or simulations analysis and monitoring tools.
#### Develop simulation space
###### Simulation
* Vehicle Simulations
* Simulate a vehicle for test activity
* Simulate a vehicle for non-regression
* Simulate a fleet of vehicle (e.g. with unitary behavior e.g. overload)
* Simulates basic vehicle functionalities
###### Simulated Services:
* Remote Control: Simulate answers to remote orders
* Data collect: Simulate data collection about the car status
* OTA: Simulates the interactions with the OTA server
* Device Management: Handles the basic connectivity with backend
* xCall: e.g. simulate emergency call
###### Future Scope:
* Test Result Analysis
* Defect Tracking
* Reporting
![Alt text](images/SimulationProcessDiag.jpg)
> <span style="color:blue"> **Note:** </span>
<span style="color:blue"> **The Eclipse-SDV DCO consists of four micro-services such as DCO-UI, Track-Management-Service, Scenario-Management-Service, and Gateway-Service. These micro-services have been consolidated into the DCO-Mono-repo, named "developer-console" to simplify the deployment process for open source developers, eliminating the need for multiple deployment steps.**</span>
## Badges
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
![java](https://badgen.net/badge/java/>=17/blue?icon=java&scale=1) ![springgraphql](https://badgen.net/badge/spring-graphql/>=1.2/blue?icon=spring-graphql&scale=1) ![maven](https://badgen.net/badge/maven/>=3.8/blue?icon=maven&scale=1) ![next](https://badgen.net/badge/nextjs/12.1.0/blue?icon=nextjs&scale=1) ![graphql](https://badgen.net/badge/graphql/16.4.0/blue?icon=graphql&scale=1)
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
![git](https://badgen.net/badge/git/v2.38.1/blue?icon=git&scale=1) ![docker](https://badgen.net/badge/docker/v20.10.17/blue?icon=docker&scale=1) ![docker compose](https://badgen.net/badge/docker-compose/v2.10.2/blue?icon=docker&scale=1) ![postgresql](https://badgen.net/badge/postgresql/16/blue?icon=postgresql&scale=1)
```
cd existing_repo
git remote add origin https://gitlab.eclipse.org/eclipse/dco/developer-console.git
git branch -M main
git push -uf origin main
```
![linux](https://badgen.net/badge/platform/linux/blue?&scale=1) ![application](https://badgen.net/badge/application/DCO/blue?&scale=1) ![frontend](https://badgen.net/badge/frontend/nodejs/blue?&scale=1) ![backend](https://badgen.net/badge/backend/java/blue?&scale=1) ![database](https://badgen.net/badge/database/postgresql/blue?&scale=1)
## Integrate with your tools
![license](https://badgen.net/badge/license/Apache_License_2.0/blue?list=|&scale=1)
- [ ] [Set up project integrations](https://gitlab.eclipse.org/eclipse/dco/developer-console/-/settings/integrations)
## Collaborate with your team
## Installation and Pre-requisites
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
There are some pre-requisites. You should install java 17, spring-graphql, maven, nextjs, graphql, docker and docker compose on your local machine before getting started.
## Test and Deploy
##### Technology Stack
Use the built-in continuous integration in GitLab.
[![Stack](https://skills.thijs.gg/icons?i=java,nextjs,maven,postgresql,docker,linux,git)](https://skills.thijs.gg)
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
| Technology/Tools | Version |
| :------------- | :--------- |
| Java | 17 |
| Spring-Boot | 3.1.0 |
| spring-graphql | 1.2 or Above |
| Maven | 3.8 or Above |
| nextjs | 12.1.0 or Above |
| GraphQL | 16.4.0 or Above |
| Docker | 20.10.17 or Above |
| Docker Compose | v2.10.2 or Above |
## Getting started
###### Check versions of all installed applications
Please ensure that all above softwares and listed versions are installed/available on your machine and can verify using below commands.
***
```bash
git version
java --version
node --version
mvn --version
docker --version
docker compose version
```
If you have all required tools and softwares installed on your machine then you are ready to start application installation. :sunglasses:
###### Clone SDV DCO repository
Clone the repository using below command. Use gitlab token if required.
```bash
# git clone
git clone https://gitlab.eclipse.org/eclipse/dco/developer-console.git
#change working directory
cd developer-console
```
# Editing this README
### Build and Deploy
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
> <span style="color:blue"> **Note:** </span>
<span style="color:blue"> **If you do not have docker and docker compose on your machine or you are using Windows machine then below automation scripts/steps will not work as it is. In that case you have to build and install dco micro-services manually, and you have to refer below steps and screenshots to understand the configuration. Remember, Minio is a pre-requisite for scenario-library-service. Also, you will get postgres sql scripts under postgres directory.**</span>
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
###### Step 1: Build all micro-services and install **Minio** on local.
In this step, we are going to build all four micro-services and install Minio server as it is pre-requisite for scenario-library-service.
## Name
Choose a self-explaining name for your project.
**Note:** If you have already followed below steps, please make sure you are using latest images and executables. On sefer side, you can simply execute clean up commands before you start with build and deploy steps.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
```bash
# Change execution permission of build shell script
chmod +x 10-build-script.sh
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
# Build apps and install Minio.
sh 10-build-script.sh
```
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
###### Step 2: Create a new bucket named, **dco-scenario-library-service** and generate **access-key** and **secret-key** in Minio
> A) Access Minio using http://localhost:9001 url. The admin user is "**minioadmin**" and default password is "**minioadmin**"
![Alt text](images/Minio-Login-Page.png)
<br></br>
> B) Create a bucket with name "dco-scenario-library-service"
![Alt text](images/Create-Bucket.png)
<br></br>
> C) Generate access key and secret key.
Save both key values for future use as we need to pass both values as arguments while running deployment script.
![Alt text](images/Access-Seccret-Key.png)
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
After creating and configuring the **dco-scenario-library-service** bucket, **access key** and **secret key** in Minio, run deploy script to run all dockerized micro-services on local machine using docker compose.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
---
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
###### Step 3: Deploy - Run all micro-services including postgres database and pgadmin client for database.
```bash
# Change execution permission of deploy shell script
chmod +x 20-deploy-script.sh
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
# Execute deploy script by passing newly generated minio access key and secret key
sh 20-deploy-script.sh <access-key> <secrete-key>
```
After successful execution of deploy step 3, you can use below urls to access web-application, playground and swagger for REST APIs.
> 1) **Developer Console UI**: http://localhost:3000
The username is "**developer**" and password is "**password**"
![Alt text](images/developer-console-ui.png)
<br></br>
> 2) **dco-gateway** playground for REST APIs: http://localhost:8080/playground
The username is "**developer**" and password is "**password**"
![Alt text](images/dco-gateway-playground.png)
<br></br>
> 3) **tracks-management-service** swagger for REST APIs: http://localhost:8081/openapi/swagger-ui/index.html
The username is "**developer**" and password is "**password**"
![Alt text](images/tracks-management-service-swagger.png)
<br></br>
> 4) **scenario-library-service** swagger for REST APIs: http://localhost:8082/openapi/swagger-ui/index.html
The username is "**developer**" and password is "**password**"
![Alt text](images/scenario-library-service-swagger.png)
<br></br>
> 5) **pgadmin** client url: http://localhost:5050
The username is "**admin@default.com**" and password is "**admin**"
![Alt text](images/pdadmin-login-page.png)
<br></br>
a) Then click on **Add New Server** option and add server name as **local**.
![Alt text](images/add-server-config-1.png)
<br></br>
b) Click on **connection** tab and provide below details.
Host name/ Address : _postgres_
port : _5432_
Maintenance Database: _postgres_
Username : _postgres_
Password : _postgres_
![Alt text](images/add-server-config-2.png)
<br></br>
c) Click on ***Save*** button. You will see below screen after successful connection.
![Alt text](images/added-local-server.png)
---
### How to use SDV DCO?
The steps involved in utilizing the SDV-Developer Console (DCO), specifically the SDV-DCO, Simulation platform :
1. Access the Developer Console UI:
- Log in to the DCO platform using the provided credentials.
- The Developer Console UI serves as the central hub for managing the Simulation platform.
2. Create Scenarios:
- In the Scenario section of DCO, click the "New Scenario" button to create and manage various scenarios.
- These scenarios simulate different aspects of software behavior, such as vehicle and fleet behavior or services for software-defined vehicles.
- These scenarios serve as a foundation for simulations and testing.
3. Create Track (Using Vehicle ID/Information )
- Navigate Track Management
- Within the Developer Console UI, locate the Track section.
- This feature allows you to define and organize different tracks or projects associated with different vehicles that are part of the new scenarios.
4. Plan New Simulations:
- While creating simulation we have to define a scenario with a track.
- Once you have created scenarios, use DCO's advanced user interface to plan “New simulations” by using New simulation button .
- Define simulation parameters, specify the scenarios to be simulated, and configure other relevant settings.
- Launch the simulations.
5. Iterate and Refine:
- Based on the insights gained from the simulation results, iterate and refine your software development and lifecycle processes.
- Adjust scenarios, simulation parameters, and integrated services as necessary to enhance the overall software quality and performance.
6. Monitor/View Simulation:
- During the execution of simulations, monitor the progress and gather relevant data using the Simulation view provided by DCO.
- This enables you to assess the behavior and performance of the software throughout the simulated scenarios.
7. Prepare and Execute Simulations: - (To be Planned)
- Before executing simulations, DCO prepares the necessary resources and configurations.
- It leverages reusability and standardization concepts to optimize the process and reduce manual effort.
- DCO allows integration of third-party solutions and services, such as simulators, virtual vehicle repositories, or simulation analysis and monitoring tools.
8. Analyze and Evaluate Results: - (To be Planned)
- Once the simulations are complete, analyze the gathered data and evaluate the results.
- This analysis helps in understanding the impact of different scenarios on the software and identifying areas for improvement or optimization.
By following these steps, you can leverage the SDV-Developer Console (DCO) platform, specifically the Simulation activities for multiple scenarios involving vehicles.
---
### Clean Up:
Once you are done with the exploring of SDV DCO, you can use below steps to simply delete all configured and installed services and tools from your machine.
###### Remove all micro-services, Minio, postgres database and pgadmin client from local machine.
```bash
# Change execution permission of destroy shell script
chmod +x 30-destroy-script.sh
# To remove all apps.
sh 30-destroy-script.sh
```
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to this project, please refer [CONTRIBUTING.md](CONTRIBUTING.md) file for details.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
## License
For license details, please refer [LICENSE.md](LICENSE.md) file
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Architecture
SDV DCO Architecture
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
![Alt text](images/SDV-DCO-Architecture.png)
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
&copy; T-Systems
HELP.md
target/
app/target
api/target
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
FROM amazoncorretto:17-al2-jdk AS app
COPY dco-gateway/app/target/*.jar /app/app.jar
WORKDIR /app
ENTRYPOINT ["java", "-jar", "app.jar"]
# TODO: adapt openapi specification itself and file name
openapi: 3.0.1
info:
title: openapi-scenario
version: latest
servers:
- url: http://localhost:8080
tags:
- name: Scenario
description: The endpoints for scenario interactions
- name: Simulation
description: The endpoints for simulation interactions
paths:
/api/scenario:
post:
tags:
- Scenario
summary: Create a Scenario
description: Create a Scenario to database
operationId: createScenario
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
scenario:
type: string
file:
type: string
format: binary
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: "#/components/schemas/Scenario"
"400":
description: Bad Request
get:
tags:
- Scenario
summary: Read Scenario by query
description: Read Scenario by query and pageable from database
operationId: scenarioReadByQuery
parameters:
- name: query
in: query
required: false
description: >-
Comma separated list of `{field}{operation}{value}` where operation can be
`:` for equal,
`!` for not equal and
`~` for like operation
schema:
type: string
- name: search
in: query
required: false
description: Search value to query searchable fields against
schema:
type: string
- name: page
in: query
required: false
example: 0
schema:
type: integer
format: int32
- name: size
in: query
required: false
example: 15
schema:
type: integer
format: int32
- name: sort
in: query
required: false
example:
- name:asc
schema:
type: array
items:
type: string
example: name:asc
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/ScenarioPage"
"400":
description: Bad Request
put:
tags:
- Scenario
summary: Update Scenario by id
description: Update Scenario by id to database
operationId: scenarioUpdateById
parameters:
- name: id
in: query
description: The scenario id
required: true
schema:
type: string
format: uuid
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
scenario:
type: string
file:
type: string
format: binary
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Scenario"
"400":
description: Bad Request
"404":
description: Not Found
delete:
tags:
- Scenario
summary: Delete Scenario by id
description: Delete Scenario by id from database
operationId: deleteScenarioById
parameters:
- name: id
in: query
description: The scenario id
required: true
schema:
type: string
format: uuid
responses:
"204":
description: No Content
"404":
description: Not Found
/api/scenario/search:
get:
tags:
- Scenario
summary: Search for scenario with given '%' pattern. Returns paginated list
description: Search for scenario with given '%' pattern. Returns paginated list
operationId: searchScenarioByPattern
parameters:
- name: scenarioPattern
in: query
required: true
schema:
type: string
- name: page
in: query
required: false
example: 0
schema:
type: integer
format: int32
- name: size
in: query
required: false
example: 15
schema:
type: integer
format: int32
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/ScenarioPage"
"404":
description: Not Found
/api/simulation:
post:
tags:
- Simulation
summary: Launch Simulation
description: Launch a Simulation
operationId: launchSimulation
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SimulationInput"
required: true
responses:
"201":
description: Created
content:
application/json:
schema:
type: string
"400":
description: Bad Request
"404":
description: Not Found
get:
tags:
- Simulation
summary: Read Simulation by query
description: Read Simulation by query and pageable from database
operationId: simulationReadByQuery
parameters:
- name: query
in: query
required: false
description: >-
Comma separated list of `{field}{operation}{value}` where operation can be
`:` for equal,
`!` for not equal and
`~` for like operation
schema:
type: string
- name: search
in: query
required: false
description: Search value to query searchable fields against
schema:
type: string
- name: page
in: query
required: false
example: 0
schema:
type: integer
format: int32
- name: size
in: query
required: false
example: 15
schema:
type: integer
format: int32
- name: sort
in: query
required: false
example:
- name:asc
schema:
type: array
items:
type: string
example: name:asc
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/SimulationPage"
"400":
description: Bad Request
components:
schemas:
ScenarioInput:
type: object
properties:
name:
type: string
status:
type: string
enum: [ CREATED, ARCHIVED ]
type:
type: string
enum: [ MQTT, CAN ]
description:
type: string
createdBy:
type: string
lastModifiedBy:
type: string
description: The scenario data
FileData:
type: object
properties:
id:
type: string
format: uuid
path:
type: string
fileKey:
type: string
size:
type: string
checksum:
type: string
updatedBy:
type: string
updatedOn:
type: string
format: date-time
description: The scenario data
ScenarioPage:
type: object
properties:
content:
type: array
items:
$ref: '#/components/schemas/Scenario'
empty:
type: boolean
first:
type: boolean
last:
type: boolean
page:
type: integer
format: int32
size:
type: integer
format: int32
pages:
type: integer
format: int32
elements:
type: integer
format: int32
total:
type: integer
format: int64
description: The Scenario page data
Scenario:
type: object
properties:
id:
type: string
format: uuid
name:
type: string
type:
type: string
status:
type: string
description:
type: string
createdAt:
type: string
format: date-time
createdBy:
type: string
lastModifiedAt:
type: string
format: date-time
lastModifiedBy:
type: string
file:
$ref: "#/components/schemas/FileData"
description: The scenario data
SimulationInput:
type: object
properties:
name:
type: string
environment:
type: string
platform:
type: string
scenarioType:
type: string
hardware:
type: string
description:
type: string
tracks:
type: array
items:
type: string
format: uuid
scenarios:
type: array
items:
type: string
format: uuid
createdBy:
type: string
description: launch simulation input
SimulationPage:
type: object
properties:
content:
type: array
items:
$ref: '#/components/schemas/Simulation'
empty:
type: boolean
first:
type: boolean
last:
type: boolean
page:
type: integer
format: int32
size:
type: integer
format: int32
pages:
type: integer
format: int32
elements:
type: integer
format: int32
total:
type: integer
format: int64
description: The Scenario page data
Simulation:
type: object
properties:
id:
type: string
format: uuid
name:
type: string
status:
type: string
platform:
type: string
hardware:
type: string
environment:
type: string
scenarioType:
type: enum
$ref: "#/components/schemas/ScenarioType"
noOfScenarios:
type: integer
format: int32
noOfVehicle:
type: integer
format: int32
brands:
type: array
items:
type: string
createdBy:
type: string
startDate:
type: string
format: date-time
description:
type: string
description: Simulation Data
ScenarioType:
type: string
enum:
- Over-The-Air Service
- Vehicle Management
- Data Collection
- Remote Control
# TODO: adapt openapi specification itself and file name
openapi: 3.0.1
info:
title: openapi-track
version: latest
servers:
- url: http://localhost:8080
tags:
- name: Track
description: The endpoints for track interactions
- name: Vehicle
description: The endpoints for vehicle interactions
paths:
/api/track:
post:
tags:
- Track
summary: Create a Track
description: Create a Track to database
operationId: createTrack
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/TrackInput"
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Track"
"400":
description: Bad Request
"404":
description: Not Found
get:
tags:
- Track
summary: Read Track by query
description: Read Track by query and pageable from database
operationId: trackReadByQuery
parameters:
- name: query
in: query
required: false
example: brand:vw,brand!bmw,brand~benz
description: >-
Comma separated list of `{field}{operation}{value}` where operation can be
`:` for equal,
`!` for not equal and
`~` for like operation
schema:
type: string
- name: search
in: query
required: false
description: Search value to query searchable fields agains
schema:
type: string
- name: page
in: query
required: false
example: 0
schema:
type: integer
format: int32
- name: size
in: query
required: false
example: 15
schema:
type: integer
format: int32
- name: sort
in: query
required: false
example:
- name:asc
schema:
type: array
items:
type: string
example: name:asc
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/TrackPage"
"404":
description: Not Found
delete:
tags:
- Track
summary: Delete a track by id
description: Delete a track by id from database
operationId: deleteTrackById
parameters:
- name: id
in: path
description: The track id
required: true
schema:
type: string
format: uuid
responses:
"200":
description: OK
content:
application/json:
schema:
type: string
"400":
description: Bad Request
"404":
description: Not Found
/api/track/{id}:
get:
tags:
- Track
summary: Find track by id
description: Find track by id
operationId: findTrackById
parameters:
- name: id
in: path
description: The track id
required: true
schema:
type: string
format: uuid
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Track"
"404":
description: Not Found
/api/track/search:
get:
tags:
- Track
summary: Search for tracks with given '%' pattern. Returns paginated list
description: Search for tracks with given '%' pattern. Returns paginated list
operationId: searchTrackByPattern
parameters:
- name: trackPattern
in: query
required: true
schema:
type: string
- name: page
in: query
required: false
example: 0
schema:
type: integer
format: int32
- name: size
in: query
required: false
example: 15
schema:
type: integer
format: int32
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/TrackPage"
"404":
description: Not Found
/api/vehicle/{vin}:
get:
tags:
- Vehicle
summary: Find vehicle by vin
description: Find vehicle by vin
operationId: getVehicleByVin
parameters:
- name: vin
in: path
description: The vehicle vin
required: true
schema:
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/VehicleResponse"
"404":
description: Not Found
/api/track/hardware:
get:
tags:
- Track
summary: Read Hardware Module
description: Read Hardware Module
operationId: getHardwareModule
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
type: String
"404":
description: Not Found
/api/vehicle:
get:
tags:
- Vehicle
summary: Read vehicle by query
description: Read Vehicle by query and pageable from device service
operationId: vehicleReadByQuery
parameters:
- name: query
in: query
required: false
description: >-
Comma separated list of `{field}{operation}{value}` where operation can be
`:` for equal,
`!` for not equal and
`~` for like operation
schema:
type: string
- name: search
in: query
required: false
description: Search value to query searchable fields against
schema:
type: string
- name: page
in: query
required: false
example: 0
schema:
type: integer
format: int32
- name: size
in: query
required: false
example: 15
schema:
type: integer
format: int32
- name: sort
in: query
required: false
example:
- name:asc
schema:
type: array
items:
type: string
example: name:asc
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/VehiclePage"
"404":
description: Not Found
components:
schemas:
TrackPage:
type: object
properties:
content:
type: array
items:
$ref: '#/components/schemas/Track'
empty:
type: boolean
first:
type: boolean
last:
type: boolean
page:
type: integer
format: int32
size:
type: integer
format: int32
pages:
type: integer
format: int32
elements:
type: integer
format: int32
total:
type: integer
format: int64
description: The Track page data
Track:
type: object
properties:
id:
type: string
format: uuid
name:
type: string
trackType:
type: string
state:
type: string
duration:
type: string
description:
type: string
vehicles:
type: array
items:
$ref: "#/components/schemas/VehicleResponse"
description: Track data
VehicleResponse:
type: object
properties:
vin:
type: string
owner:
type: string
ecomDate:
type: string
country:
type: string
model:
type: string
brand:
type: string
region:
type: string
createdAt:
type: string
instantiatedAt:
type: string
updatedAt:
type: string
status:
type: string
type:
type: string
fleets:
type: array
items:
$ref: "#/components/schemas/FleetResponse"
devices:
type: array
items:
$ref: "#/components/schemas/DeviceResponse"
services:
type: array
items:
$ref: "#/components/schemas/ServiceResponse"
tags:
type: array
items:
type: string
description: vehicle data
FleetResponse:
type: object
properties:
id:
type: string
name:
type: string
type:
type: string
description: Fleet data
ServiceResponse:
type: object
properties:
serviceId:
type: string
operation:
type: string
updatedAt:
type: string
description: Fleet data
DeviceResponse:
type: object
properties:
id:
type: string
type:
type: string
status:
type: string
createdAt:
type: string
gatewayId:
type: string
modelType:
type: string
dmProtocol:
type: string
modifiedAt:
type: string
dmProtocolVersion:
type: string
serialNumber:
type: string
components:
type: array
items:
$ref: "#/components/schemas/DeviceComponentResponse"
description: device data
DeviceComponentResponse:
type: object
properties:
id:
type: string
name:
type: string
status:
type: string
version:
type: string
environmentType:
type: string
description: device component data
TrackInput:
type: object
properties:
name:
type: string
trackType:
type: string
state:
type: string
duration:
type: string
description:
type: string
vehicles:
type: array
items:
$ref: "#/components/schemas/Vehicle"
description: create track request data
Vehicle:
type: object
properties:
vin:
type: string
country:
type: string
description: vehicle data for track creation
VehiclePage:
type: object
properties:
content:
type: array
items:
$ref: '#/components/schemas/VehicleResponse'
empty:
type: boolean
first:
type: boolean
last:
type: boolean
page:
type: integer
format: int32
size:
type: integer
format: int32
pages:
type: integer
format: int32
elements:
type: integer
format: int32
total:
type: integer
format: int64
description: The Vehicle page data
<?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">
<parent>
<artifactId>dco-gateway</artifactId>
<groupId>com.tsystems.dco</groupId>
<version>latest</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dco-gateway-api</artifactId>
<packaging>jar</packaging>
<properties>
<cyclonedx.skip>true</cyclonedx.skip>
<dependency-track.skip>true</dependency-track.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<executions>
<execution>
<id>openapi-scenario</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/openapi/openapi-scenario.yml</inputSpec>
<generatorName>spring</generatorName>
<packageName>com.tsystems.dco.scenario</packageName>
<invokerPackage>com.tsystems.dco.scenario</invokerPackage>
<apiPackage>com.tsystems.dco.scenario.api</apiPackage>
<modelPackage>com.tsystems.dco.scenario.model</modelPackage>
<generateSupportingFiles>false</generateSupportingFiles>
<typeMappings>
<typeMapping>OffsetDateTime=Instant</typeMapping>
</typeMappings>
<importMappings>
<importMapping>java.time.OffsetDateTime=java.time.Instant</importMapping>
</importMappings>
<configOptions>
<useTags>true</useTags>
<useSpringBoot3>true</useSpringBoot3>
<interfaceOnly>true</interfaceOnly>
<serializableModel>true</serializableModel>
<skipDefaultInterface>true</skipDefaultInterface>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<openApiNullable>false</openApiNullable>
<additionalModelTypeAnnotations>@lombok.Builder @lombok.NoArgsConstructor @lombok.AllArgsConstructor</additionalModelTypeAnnotations>
</configOptions>
</configuration>
</execution>
<execution>
<id>openapi-track</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/openapi/openapi-track.yml</inputSpec>
<generatorName>spring</generatorName>
<packageName>com.tsystems.dco.track</packageName>
<invokerPackage>com.tsystems.dco.track</invokerPackage>
<apiPackage>com.tsystems.dco.track.api</apiPackage>
<modelPackage>com.tsystems.dco.track.model</modelPackage>
<generateSupportingFiles>false</generateSupportingFiles>
<typeMappings>
<typeMapping>OffsetDateTime=Instant</typeMapping>
</typeMappings>
<importMappings>
<importMapping>java.time.OffsetDateTime=java.time.Instant</importMapping>
</importMappings>
<configOptions>
<useTags>true</useTags>
<useSpringBoot3>true</useSpringBoot3>
<interfaceOnly>true</interfaceOnly>
<serializableModel>true</serializableModel>
<skipDefaultInterface>true</skipDefaultInterface>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<openApiNullable>false</openApiNullable>
<additionalModelTypeAnnotations>@lombok.Builder @lombok.NoArgsConstructor @lombok.AllArgsConstructor</additionalModelTypeAnnotations>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?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">
<parent>
<artifactId>dco-gateway</artifactId>
<groupId>com.tsystems.dco</groupId>
<version>latest</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dco-gateway-app</artifactId>
<properties>
<cyclonedx.skip>true</cyclonedx.skip>
<dependency-track.skip>true</dependency-track.skip>
<sonar.coverage.exclusions>
**/App.java,
**/src/main/java/com/tsystems/dco/config/**,
**/src/main/java/com/tsystems/dco/AppProperties**
</sonar.coverage.exclusions>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>dco-gateway-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-graphql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>graphql-java-tools</artifactId>
<version>13.0.3</version>
</dependency>
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>15.0.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230227</version>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.graphql</groupId>
<artifactId>spring-graphql-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.2.Final</version>
</path>
<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>2.7.4</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/*
* ========================================================================
* SDV Developer Console
*
* Copyright (C) 2022 - 2023 T-Systems International GmbH
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
* ========================================================================
*/
package com.tsystems.dco;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* Entrypoint of application.
*/
@SpringBootApplication
@EnableFeignClients
@EnableConfigurationProperties
public class App {
/**
* Main application entrypoint.
*
* @param args command line arguments
*/
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
/*
* ========================================================================
* SDV Developer Console
*
* Copyright (C) 2022 - 2023 T-Systems International GmbH
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
* ========================================================================
*/
package com.tsystems.dco;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.context.annotation.Configuration;
/**
* Properties of application.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Configuration
@ConfigurationProperties(prefix = "app")
public class AppProperties {
/**
* The app name.
*/
private String name;
/**
* The app version.
*/
private String version;
/**
* The rest properties.
*/
@NestedConfigurationProperty
private Rest rest;
/**
* The probes properties.
*/
@NestedConfigurationProperty
private Probes probes;
/**
* The cors properties.
*/
@NestedConfigurationProperty
private Cors cors;
/**
* Properties of rest.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class Rest {
private Integer port;
}
/**
* Properties of probes.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class Probes {
private Integer port;
}
/**
* Properties of cors.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class Cors {
private String headers;
private String origins;
}
}
/*
* ========================================================================
* SDV Developer Console
*
* Copyright (C) 2022 - 2023 T-Systems International GmbH
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
* ========================================================================
*/
package com.tsystems.dco.config;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tsystems.dco.exception.BaseException;
import graphql.schema.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.graphql.GraphQlProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.annotation.Order;
import org.springframework.graphql.ExecutionGraphQlRequest;
import org.springframework.graphql.execution.RuntimeWiringConfigurer;
import org.springframework.graphql.server.WebGraphQlHandler;
import org.springframework.graphql.server.WebGraphQlRequest;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.util.AlternativeJdkIdGenerator;
import org.springframework.util.Assert;
import org.springframework.util.IdGenerator;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.support.AbstractMultipartHttpServletRequest;
import org.springframework.web.server.ServerWebInputException;
import org.springframework.web.servlet.function.*;
import reactor.core.publisher.Mono;
import java.net.URI;
import java.util.*;
import java.util.regex.Pattern;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
@Configuration
public class GraphQLConfiguration {
@Bean
public RuntimeWiringConfigurer runtimeWiringConfigurerUpload() {
GraphQLScalarType uploadScalar = GraphQLScalarType.newScalar()
.name("Upload")
.coercing(new UploadCoercing())
.build();
return wiringBuilder -> wiringBuilder.scalar(uploadScalar);
}
@Bean
@Order(1)
public RouterFunction<ServerResponse> graphQlMultipartRouterFunction(
GraphQlProperties properties,
WebGraphQlHandler webGraphQlHandler,
ObjectMapper objectMapper
) {
String path = properties.getPath();
var builder = RouterFunctions.route();
var graphqlMultipartHandler = new GraphqlMultipartHandler(webGraphQlHandler, objectMapper);
builder = builder.POST(path, RequestPredicates.contentType(MULTIPART_FORM_DATA)
.and(RequestPredicates.accept(MediaType.MULTIPART_FORM_DATA)), graphqlMultipartHandler::handleRequest);
return builder.build();
}
}
class UploadCoercing implements Coercing<MultipartFile, MultipartFile> {
@Override
public MultipartFile serialize(Object dataFetcherResult) throws CoercingSerializeException {
throw new CoercingSerializeException("Upload is an input-only type");
}
@Override
public MultipartFile parseValue(Object input) throws CoercingParseValueException {
if (input instanceof MultipartFile) {
return (MultipartFile) input;
}
throw new CoercingParseValueException(
String.format("Expected a 'MultipartFile' like object but was '%s'.", input != null ? input.getClass() : null)
);
}
@Override
public MultipartFile parseLiteral(Object input) throws CoercingParseLiteralException {
throw new CoercingParseLiteralException("Parsing literal of 'MultipartFile' is not supported");
}
}
class GraphqlMultipartHandler {
private final WebGraphQlHandler graphQlHandler;
private final ObjectMapper objectMapper;
public GraphqlMultipartHandler(WebGraphQlHandler graphQlHandler, ObjectMapper objectMapper) {
Assert.notNull(graphQlHandler, "WebGraphQlHandler is required");
Assert.notNull(objectMapper, "ObjectMapper is required");
this.graphQlHandler = graphQlHandler;
this.objectMapper = objectMapper;
}
protected static final List<MediaType> SUPPORTED_RESPONSE_MEDIA_TYPES =
Arrays.asList(MediaType.APPLICATION_GRAPHQL, MediaType.APPLICATION_JSON);
private static final Log logger = LogFactory.getLog(GraphqlMultipartHandler.class);
private static final String VARIABLES = "variables";
private final IdGenerator idGenerator = new AlternativeJdkIdGenerator();
public ServerResponse handleRequest(ServerRequest serverRequest) {
Optional<String> operation = serverRequest.param("operations");
Optional<String> mapParam = serverRequest.param("map");
Map<String, Object> inputQuery = readJson(operation, new TypeReference<>() {
});
final Map<String, Object> queryVariables;
if (inputQuery.containsKey(VARIABLES)) {
queryVariables = (Map<String, Object>) inputQuery.get(VARIABLES);
} else {
queryVariables = new HashMap<>();
}
Map<String, MultipartFile> fileParams = readMultipartBody(serverRequest);
Map<String, List<String>> fileMapInput = readJson(mapParam, new TypeReference<>() {
});
fileMapInput.forEach((String fileKey, List<String> objectPaths) -> {
MultipartFile file = fileParams.get(fileKey);
if (file != null) {
objectPaths.forEach((String objectPath) ->
MultipartVariableMapper.mapVariable(
objectPath,
queryVariables,
file
)
);
}
});
String query = (String) inputQuery.get("query");
String opName = (String) inputQuery.get("operationName");
WebGraphQlRequest graphQlRequest = new MultipartGraphQlRequest(
query,
opName,
queryVariables,
serverRequest.uri(), serverRequest.headers().asHttpHeaders(),
this.idGenerator.generateId().toString(), LocaleContextHolder.getLocale());
if (logger.isDebugEnabled()) {
logger.debug("Executing: " + graphQlRequest);
}
Mono<ServerResponse> responseMono = this.graphQlHandler.handleRequest(graphQlRequest)
.map(response -> {
if (logger.isDebugEnabled()) {
logger.debug("Execution complete");
}
ServerResponse.BodyBuilder builder = ServerResponse.ok();
builder.headers(headers -> headers.putAll(response.getResponseHeaders()));
builder.contentType(selectResponseMediaType(serverRequest));
return builder.body(response.toMap());
});
return ServerResponse.async(responseMono);
}
private <T> T readJson(Optional<String> string, TypeReference<T> t) {
Map<String, Object> map = new HashMap<>();
if (string.isPresent()) {
try {
return objectMapper.readValue(string.get(), t);
} catch (JsonProcessingException e) {
throw new BaseException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
}
}
return (T) map;
}
private static Map<String, MultipartFile> readMultipartBody(ServerRequest request) {
try {
var abstractMultipartHttpServletRequest = (AbstractMultipartHttpServletRequest) request.servletRequest();
return abstractMultipartHttpServletRequest.getFileMap();
} catch (RuntimeException ex) {
throw new ServerWebInputException("Error while reading request parts", null, ex);
}
}
private static MediaType selectResponseMediaType(ServerRequest serverRequest) {
for (MediaType accepted : serverRequest.headers().accept()) {
if (SUPPORTED_RESPONSE_MEDIA_TYPES.contains(accepted)) {
return accepted;
}
}
return MediaType.APPLICATION_JSON;
}
}
class MultipartVariableMapper {
private static final Pattern PERIOD = Pattern.compile("\\.");
private static final String VARIABLES = "variables";
private static final Mapper<Map<String, Object>> MAP_MAPPER =
new Mapper<Map<String, Object>>() {
@Override
public Object set(Map<String, Object> location, String target, MultipartFile value) {
return location.put(target, value);
}
@Override
public Object recurse(Map<String, Object> location, String target) {
return location.get(target);
}
};
private static final Mapper<List<Object>> LIST_MAPPER =
new Mapper<List<Object>>() {
@Override
public Object set(List<Object> location, String target, MultipartFile value) {
return location.set(Integer.parseInt(target), value);
}
@Override
public Object recurse(List<Object> location, String target) {
return location.get(Integer.parseInt(target));
}
};
@SuppressWarnings({"unchecked", "rawtypes"})
public static void mapVariable(String objectPath, Map<String, Object> variables, MultipartFile part) {
String[] segments = PERIOD.split(objectPath);
if (segments.length < 2) {
throw new BaseException(HttpStatus.INTERNAL_SERVER_ERROR, "object-path in map must have at least two segments");
} else if (!VARIABLES.equals(segments[0])) {
throw new BaseException(HttpStatus.INTERNAL_SERVER_ERROR, "can only map into variables");
}
Object currentLocation = variables;
for (var i = 1; i < segments.length; i++) {
String segmentName = segments[i];
Mapper mapper = determineMapper(currentLocation, objectPath, segmentName);
if (i == segments.length - 1) {
if (null != mapper.set(currentLocation, segmentName, part)) {
throw new BaseException(HttpStatus.INTERNAL_SERVER_ERROR, "expected null value when mapping " + objectPath);
}
} else {
currentLocation = mapper.recurse(currentLocation, segmentName);
if (null == currentLocation) {
throw new BaseException(HttpStatus.INTERNAL_SERVER_ERROR, "found null intermediate value when trying to map " + objectPath);
}
}
}
}
private static Mapper<?> determineMapper(
Object currentLocation, String objectPath, String segmentName) {
if (currentLocation instanceof Map) {
return MAP_MAPPER;
} else if (currentLocation instanceof List) {
return LIST_MAPPER;
}
throw new BaseException(HttpStatus.INTERNAL_SERVER_ERROR, "expected a map or list at " + segmentName + " when trying to map " + objectPath);
}
interface Mapper<T> {
Object set(T location, String target, MultipartFile value);
Object recurse(T location, String target);
}
}
class MultipartGraphQlRequest extends WebGraphQlRequest implements ExecutionGraphQlRequest {
private final String document;
private final String operationName;
private final Map<String, Object> variables;
public MultipartGraphQlRequest(
String query,
String operationName,
Map<String, Object> variables,
URI uri, HttpHeaders headers,
String id, @Nullable Locale locale) {
super(uri, headers, fakeBody(query), id, locale);
this.document = query;
this.operationName = operationName;
this.variables = variables;
}
private static Map<String, Object> fakeBody(String query) {
Map<String, Object> fakeBody = new HashMap<>();
fakeBody.put("query", query);
return fakeBody;
}
@Override
public String getDocument() {
return document;
}
@Override
public String getOperationName() {
return operationName;
}
@Override
public Map<String, Object> getVariables() {
return variables;
}
}
package com.tsystems.dco.config;
import org.springframework.beans.factory.annotation.Value;
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.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;
import static org.springframework.security.config.Customizer.withDefaults;
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Value("${app.username}")
private String username;
@Value("${app.password}")
private String password;
@Bean
public SecurityFilterChain configure(HttpSecurity http) throws Exception {
return http.cors().and().csrf().disable()
.authorizeRequests(auth -> auth.anyRequest().authenticated())
.httpBasic(withDefaults())
.build();
}
@Bean
public InMemoryUserDetailsManager userDetailsManager() {
UserDetails user1 = User.withDefaultPasswordEncoder()
.username(username)
.password(password)
.roles("USER")
.build();
UserDetails user2 = User.withDefaultPasswordEncoder()
.username("dco")
.password("dco")
.roles("USER")
.build();
UserDetails admin = User.withDefaultPasswordEncoder()
.username("admin")
.password("password")
.roles("USER","ADMIN")
.build();
return new InMemoryUserDetailsManager(user1, user2, admin);
}
}
/*
* ========================================================================
* SDV Developer Console
*
* Copyright (C) 2022 - 2023 T-Systems International GmbH
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
* ========================================================================
*/
package com.tsystems.dco.config;
import com.tsystems.dco.AppProperties;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* Configuration for MVC and cors.
*/
@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {
private final AppProperties properties;
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods("HEAD", "GET", "PUT", "POST", "DELETE", "PATCH", "OPTIONS")
.allowedOrigins(properties.getCors().getOrigins())
.allowedHeaders(properties.getCors().getHeaders());
}
}
/*
* ========================================================================
* SDV Developer Console
*
* Copyright (C) 2022 - 2023 T-Systems International GmbH
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
* ========================================================================
*/
package com.tsystems.dco.exception;
import lombok.Getter;
import lombok.ToString;
import org.springframework.http.HttpStatus;
/**
* Base exception that contains a http status code
*/
@Getter
@ToString
public class BaseException extends RuntimeException {
private final HttpStatus status;
/**
* Base exception constructor with status and message.
*
* @param status The http status that should occur when exception is thrown
* @param message The message that should occur when exception is thrown
*/
public BaseException(HttpStatus status, String message) {
super(message);
this.status = status;
}
}
/*
* ========================================================================
* SDV Developer Console
*
* Copyright (C) 2022 - 2023 T-Systems International GmbH
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
* ========================================================================
*/
package com.tsystems.dco.exception;
import graphql.GraphQLError;
import graphql.GraphqlErrorBuilder;
import graphql.schema.DataFetchingEnvironment;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONObject;
import org.springframework.graphql.execution.DataFetcherExceptionResolverAdapter;
import org.springframework.graphql.execution.ErrorType;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class CustomExceptionHandler extends DataFetcherExceptionResolverAdapter {
private static final String KEY_STATUS = "status";
private static final String KEY_MESSAGE = "message";
/**
* @param ex the exception to resolve
* @param env the environment for the invoked {@code DataFetcher}
* @return GraphQLError
*/
@SneakyThrows
@Override
public GraphQLError resolveToSingleError(Throwable ex, DataFetchingEnvironment env) {
log.warn("exception is : {}", ex.getMessage());
var message = ex.getMessage();
var errorType = ErrorType.INTERNAL_ERROR;
var startIndex = message.indexOf("{");
var endIndex = message.indexOf("}") + 2;
if (startIndex != -1) {
var substring = message.substring(startIndex, endIndex);
var json = new JSONObject(substring);
if (json.has(KEY_MESSAGE))
message = json.getString(KEY_MESSAGE);
if (json.has(KEY_STATUS))
errorType = ErrorType.valueOf(json.getString(KEY_STATUS));
log.warn("GetMessage is : {}", message);
log.warn("GetCause is : {}", errorType);
}
log.warn(" ErrorType.valueOf(keyStatus) {}" + errorType);
if (ex instanceof Exception) {
return GraphqlErrorBuilder.newError()
.errorType(errorType)
.message(message)
.path(env.getExecutionStepInfo().getPath())
.location(env.getField().getSourceLocation())
.build();
}
return null;
}
}
/*
* ========================================================================
* SDV Developer Console
*
* Copyright (C) 2022 - 2023 T-Systems International GmbH
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
* ========================================================================
*/
package com.tsystems.dco.scenario;
import com.tsystems.dco.scenario.model.Scenario;
import com.tsystems.dco.scenario.model.ScenarioInput;
import com.tsystems.dco.scenario.model.ScenarioPage;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.UUID;
public interface ScenarioClient {
Scenario createScenario(ScenarioInput scenarioInput, MultipartFile file);
void deleteScenarioById(UUID id);
Scenario updateScenario(UUID id, ScenarioInput scenarioInput, MultipartFile file);
ScenarioPage scenarioReadByQuery(String query, String search, Integer page, Integer size, List<String> sort);
ScenarioPage searchScenarioByPattern(String scenarioPattern, Integer page, Integer size);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment