develop #38

Merged
bboterm merged 451 commits from develop into main 2025-11-19 14:28:14 +00:00
3 changed files with 9 additions and 5 deletions
Showing only changes of commit d1a9cb4cd0 - Show all commits

View File

@ -5,6 +5,8 @@ Simple tool to quickly edit HTM products via ABTProducts REST API.
- Run via: `java -jar ABTProductsPUTGenerator.jar` - Run via: `java -jar ABTProductsPUTGenerator.jar`
- Specify custom input/output path via: `java -jar ABTProductsPUTGenerator.jar <inputPath> <outputPath>` - Specify custom input/output path via: `java -jar ABTProductsPUTGenerator.jar <inputPath> <outputPath>`
- Takes a ABTProducts GET response body in JSON format (product details) - Takes a ABTProducts GET response body in JSON format (product details)
- Generates the equivalent PUT request body - Generates the equivalent PUT request body - send via either:
- Postman WSO2 ABTProducts collection
- `curl -X PUT -H 'Content-Type: application/json' {baseUrl}/abt/abtproducts/1.0/38 --data @output.json`
- Default input path: /input.json - Default input path: /input.json
- Default output path: /output.json (output is overwritten if it exists) - Default output path: /output.json (output is overwritten if it exists)

View File

@ -27,15 +27,17 @@ public class ABTProductsPUTGenerator {
try (InputStream is = getInputStream(inputFile)) { try (InputStream is = getInputStream(inputFile)) {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readTree(is); JsonNode jsonNode = mapper.readTree(is);
Long productId = jsonNode.get("productId").asLong();
LOGGER.info("Successfully parsed product with productId {} from JSON:\n{}\n", jsonNode.get("productId").asLong(), jsonNode.toPrettyString()); LOGGER.info("Successfully parsed product with productId {} from JSON:\n{}\n", productId, jsonNode.toPrettyString());
JsonNode putJsonNode = processJsonNode(jsonNode); JsonNode putJsonNode = processJsonNode(jsonNode);
writeToFile(putJsonNode, outputFile); writeToFile(putJsonNode, outputFile);
}
LOGGER.info("DONE! Modify the output JSON as desired and send it as ABTProducts PUT request body."); LOGGER.info("DONE! Modify the output JSON as desired and send it as ABTProducts PUT request body:");
LOGGER.info("curl -X PUT -H 'Content-Type: application/json' {baseUrl}/abt/abtproducts/1.0/products/{} --data @{}", productId, outputFile);
}
} }
private static InputStream getInputStream(String filePath) throws IOException { private static InputStream getInputStream(String filePath) throws IOException {