```markdown # ServiceSpecificationFetcher ## Overview 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. ## Prerequisites - Java 17+ - Maven - Docker (optional, for containerized deployment) ## Configuration 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 ``` ## Building the Project To build the project, use Maven: ```sh mvn clean install ``` ## Running the Project To run the project, execute the following command: ```sh java -cp target/servicespecificationfetcher.jar org.osl.etsi.util.ServiceSpecificationFetcher ``` ## Docker Deployment ### Building the Docker Image To build the Docker image, use the following command: ```sh docker build -t servicespecificationfetcher . ``` ### Running the Docker Container 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 ``` ## File Hierarchy Structure 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 │ ├── ... └── ... ``` ## Error Handling & Logging - **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. ## License This project is licensed under the Apache Version 2.0 License. ```