Skip to content

Commit

Permalink
Corrective NetworkService to adapt changes which demand caseFormat from
Browse files Browse the repository at this point in the history
  • Loading branch information
thangqp committed Jun 25, 2024
1 parent a68849c commit ec9c63c
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public NetworkValues getNetworkValues(MultipartFile multipartFile) {
parts.add(HttpHeaders.CONTENT_DISPOSITION, contentDisposition.toString());
HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<>(parts, headers);

// upload case
ResponseEntity<String> response = restTemplate.exchange(
caseServerBaseUri + "/" + CASE_API_VERSION + "/cases",
HttpMethod.POST,
Expand All @@ -272,7 +273,15 @@ public NetworkValues getNetworkValues(MultipartFile multipartFile) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST);
}
UUID caseUuid = UUID.fromString(responseBody.substring(1, 37));
String url = networkConversionServerBaseUri + "/" + NETWORK_CONVERSION_API_VERSION + "/networks?caseUuid=" + caseUuid + "&isAsyncRun=false";

// get case format after uploaded
String caseFormat = restTemplate.getForEntity(
caseServerBaseUri + "/" + CASE_API_VERSION + "/cases/" + caseUuid + "/format",
String.class
).getBody();

// do conversion
String url = networkConversionServerBaseUri + "/" + NETWORK_CONVERSION_API_VERSION + "/networks?caseUuid=" + caseUuid + "&caseFormat=" + caseFormat + "&isAsyncRun=false";
NetworkIdentification networkIdentification = restTemplate.postForEntity(url, Collections.emptyMap(), NetworkIdentification.class).getBody();
if (networkIdentification == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST);
Expand Down

0 comments on commit ec9c63c

Please sign in to comment.