Skip to content

Commit d2cdd4c

Browse files
committed
digital double logic
1 parent a4ba247 commit d2cdd4c

File tree

1 file changed

+19
-29
lines changed

1 file changed

+19
-29
lines changed

java-ai/src/main/java/oracleai/services/ORDSCalls.java

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414

1515
import java.io.IOException;
16+
import java.net.URLEncoder;
1617
import java.util.Base64;
1718
import java.util.Collections;
1819
import java.util.HashMap;
@@ -205,43 +206,32 @@ public static void insertDigitalDoubleData(MultipartFile image, MultipartFile vi
205206
}
206207

207208

208-
public static @Nullable String getDigitalDoubleData(String email) throws JsonProcessingException {
209-
System.out.println("DigitalDoubles.downloaddigitaldouble lookup email: " + email);
209+
public static @Nullable String getDigitalDoubleData(String email) throws Exception {
210+
System.out.println("DigitalDoubles.downloaddigitaldouble lookup email:" + email);
211+
// String url = AIApplication.ORDS_OMLOPSENDPOINT_URL + "modelurls/geturls/" + email;
212+
String url = AIApplication.ORDS_OMLOPSENDPOINT_URL + "/digitaldouble/fbxurl/" + URLEncoder.encode(email, "UTF-8");
210213

211-
// Use POST instead of GET
212-
String url = AIApplication.ORDS_OMLOPSENDPOINT_URL + "modelurls/geturls";
213214

214-
// Prepare headers
215215
HttpHeaders headers = new HttpHeaders();
216216
headers.setContentType(MediaType.APPLICATION_JSON);
217217

218-
// Prepare the request body (email passed in the request body)
219-
Map<String, String> requestBody = new HashMap<>();
220-
requestBody.put("p_participant_email", email);
221-
222-
// Wrap the request body and headers into an HttpEntity
223-
HttpEntity<Map<String, String>> entity = new HttpEntity<>(requestBody, headers);
224-
225-
// Execute the POST request using RestTemplate
226-
ResponseEntity<String> response = new RestTemplate().exchange(url, HttpMethod.POST, entity, String.class);
227-
228-
// Parse the JSON response using Jackson ObjectMapper
229-
ObjectMapper objectMapper = new ObjectMapper();
230-
JsonNode rootNode = objectMapper.readTree(response.getBody());
218+
// Prepare the request entity with headers
219+
HttpEntity<String> entity = new HttpEntity<>(headers);
231220

232-
// Extract the fields
233-
String modelGlbUrl = rootNode.path("MODELGLBURL_OUT").asText();
234-
String modelFbxUrl = rootNode.path("MODELFBXURL_OUT").asText();
235-
String modelUsdzUrl = rootNode.path("MODELUSDZURL_OUT").asText();
236-
String thumbnailUrl = rootNode.path("THUMBNAILURL_OUT").asText();
221+
// Execute the GET request
222+
ResponseEntity<String> response = new RestTemplate().exchange(url, HttpMethod.GET, entity, String.class);
237223

238-
// Print extracted URLs
239-
System.out.println("MODELGLBURL_OUT: " + modelGlbUrl);
240-
System.out.println("MODELFBXURL_OUT: " + modelFbxUrl);
241-
System.out.println("MODELUSDZURL_OUT: " + modelUsdzUrl);
242-
System.out.println("THUMBNAILURL_OUT: " + thumbnailUrl);
224+
// Check if the response is successful (status code 200)
225+
if (response.getStatusCode().is2xxSuccessful()) {
226+
// Get the body of the response, which is the FBX URL
227+
String modelFbxUrl = response.getBody();
228+
System.out.println("MODELFBXURL_OUT: " + modelFbxUrl);
229+
return modelFbxUrl;
230+
} else {
231+
System.err.println("Failed to retrieve FBX URL. Status code: " + response.getStatusCode());
232+
return null;
233+
}
243234

244-
return modelFbxUrl;
245235
}
246236
}
247237

0 commit comments

Comments
 (0)