|
13 | 13 |
|
14 | 14 |
|
15 | 15 | import java.io.IOException;
|
| 16 | +import java.net.URLEncoder; |
16 | 17 | import java.util.Base64;
|
17 | 18 | import java.util.Collections;
|
18 | 19 | import java.util.HashMap;
|
@@ -205,43 +206,32 @@ public static void insertDigitalDoubleData(MultipartFile image, MultipartFile vi
|
205 | 206 | }
|
206 | 207 |
|
207 | 208 |
|
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"); |
210 | 213 |
|
211 |
| - // Use POST instead of GET |
212 |
| - String url = AIApplication.ORDS_OMLOPSENDPOINT_URL + "modelurls/geturls"; |
213 | 214 |
|
214 |
| - // Prepare headers |
215 | 215 | HttpHeaders headers = new HttpHeaders();
|
216 | 216 | headers.setContentType(MediaType.APPLICATION_JSON);
|
217 | 217 |
|
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); |
231 | 220 |
|
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); |
237 | 223 |
|
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 | + } |
243 | 234 |
|
244 |
| - return modelFbxUrl; |
245 | 235 | }
|
246 | 236 | }
|
247 | 237 |
|
0 commit comments