Newer
Older
The `ServiceSpecificationFetcher` is a Java-based application designed to fetch hierarchical data from RESTful APIs. It starts with a given `ServiceSpecification` UUID and recursively retrieves related `ServiceSpecification` and `ResourceSpecification` objects, saving each as JSON files in a structured directory hierarchy. Attachments and LCM rule specifications are also fetched and saved, ensuring all related data is organized and stored appropriately.
- Java 17+
- Maven
- Docker (optional, for containerized deployment)
The application requires a configuration file named `config.properties` with the following properties:
```ini
keycloak.url=http://keycloak:8080/auth/realms/openslice/protocol/openid-connect/token
client.id=osapiWebClientId
client.secret=admin
username=admin
password=admin
sourceApiEndpoint.url=http://localhost/tmf-api
serviceSpecification.uuid=487b9377-460d-4498-a8f3-a23cd7595b06
```sh
java -cp target/servicespecificationfetcher.jar org.osl.etsi.util.ServiceSpecificationFetcher
```
```sh
docker build -t servicespecificationfetcher .
```
To run the Docker container, use the following command, ensuring to mount the configuration file and data folder:
```sh
docker run -v /local/path/to/config.properties:/app/config.properties -v /local/path/to/your-data-folder:/app/data-folder servicespecificationfetcher uuid
docker run -v C:\openslice\servicespecificationfetcher\src\main\resources\config.properties:/app/config.properties -v C:\openslice\servicespecificationfetcher:/app/data-folder servicespecificationfetcher f51cb185-6663-49e8-b195-83deeae32eed
```
The fetched data is saved in a structured directory hierarchy as follows:
```
root_directory/
├── serviceSpecificationId1/
│ ├── serviceSpecificationId1.json
│ ├── serviceSpecificationLcmRules/
│ │ ├── ruleId1.json
│ │ ├── ruleId2.json
│ │ └── ...
│ ├── serviceSpecificationServiceRelationships/
│ │ ├── relatedServiceSpecificationId1/
│ │ │ ├── relatedServiceSpecificationId1.json
│ │ │ ├── ...
│ │ └── ...
│ ├── serviceSpecificationResourceRelationships/
│ │ ├── relatedResourceSpecificationId1/
│ │ │ ├── relatedResourceSpecificationId1.json
│ │ │ ├── ...
│ │ └── ...
│ ├── attachments/
│ │ ├── attachment1.ext
│ │ ├── attachment2.ext
│ │ └── ...
│ └── ...
├── serviceSpecificationId2/
│ ├── serviceSpecificationId2.json
│ ├── ...
└── ...
```
- **HTTP Errors**: An `IOException` is thrown for non-200 HTTP status codes.
- **JSON Parsing Errors**: Errors are caught and printed to the console.
- **Logging**: `System.out.println` is used for logging.
This project is licensed under the Apache Version 2.0 License.
```