5858import java .io .IOException ;
5959import java .io .InputStream ;
6060import java .net .http .HttpClient ;
61+ import java .net .http .HttpRequest ;
6162import java .util .*;
63+ import java .util .function .Consumer ;
6264
6365import static eu .europa .ec .itb .validation .commons .web .Constants .*;
6466
@@ -213,7 +215,7 @@ public UploadResult<Translations> handleUpload(@PathVariable("domain") String do
213215 List <FileInfo > externalSchemas = new ArrayList <>();
214216 boolean proceedToValidate = true ;
215217 try {
216- externalSchemas = getExternalFiles (externalSchemaContentType , externalSchemaFiles , externalSchemaUri , externalSchemaString , config .getSchemaInfo (validationType ), tempFolderForRequest , config .getHttpVersion ());
218+ externalSchemas = getExternalFiles (externalSchemaContentType , externalSchemaFiles , externalSchemaUri , externalSchemaString , config .getSchemaInfo (validationType ), tempFolderForRequest , config .getHttpVersion (), config );
217219 } catch (IOException e ) {
218220 logger .error ("Error while reading uploaded file [{}]" , e .getMessage (), e );
219221 result .setMessage (localisationHelper .localise ("validator.label.exception.errorInUpload" , e .getMessage ()));
@@ -374,13 +376,15 @@ private ValidationArtifactCombinationApproach getSchemaCombinationApproach(Strin
374376 * @param schemaInfo The schema information from the domain.
375377 * @param parentFolder The temporary folder to use for file system storage.
376378 * @param httpVersion The HTTP version to use.
379+ * @param domainConfig The domain configuration.
377380 * @return The list of user-provided artifacts.
378381 * @throws IOException If an IO error occurs.
379382 */
380383 private List <FileInfo > getExternalFiles (String [] externalContentType , MultipartFile [] externalFiles , String [] externalUri , String [] externalString ,
381- ValidationArtifactInfo schemaInfo , File parentFolder , HttpClient .Version httpVersion ) throws IOException {
384+ ValidationArtifactInfo schemaInfo , File parentFolder , HttpClient .Version httpVersion , DomainConfig domainConfig ) throws IOException {
382385 List <FileInfo > lis = new ArrayList <>();
383386 if (externalContentType != null ) {
387+ Consumer <HttpRequest .Builder > requestDecorator = fileManager .createRemoteFileRequestDecorator (domainConfig , schemaInfo );
384388 for (int i =0 ; i <externalContentType .length ; i ++) {
385389 if (StringUtils .isNotBlank (externalContentType [i ])) {
386390 File inputFile ;
@@ -396,10 +400,9 @@ private List<FileInfo> getExternalFiles(String[] externalContentType, MultipartF
396400 if (externalString != null && externalString .length > i ) {
397401 currentExtString = externalString [i ];
398402 }
399-
400- inputFile = getInputFile (externalContentType [i ], currentExtFile , currentExtUri , currentExtString , parentFolder , httpVersion );
403+ inputFile = getInputFile (externalContentType [i ], currentExtFile , currentExtUri , currentExtString , parentFolder , httpVersion , requestDecorator );
401404 if (inputFile != null ) {
402- lis .add (new FileInfo (inputFile ));
405+ lis .add (new FileInfo (inputFile , null , null , requestDecorator ));
403406 }
404407 }
405408 }
@@ -452,10 +455,11 @@ private boolean validateExternalFiles(List<FileInfo> lis, ValidationArtifactInfo
452455 * @param inputString The provided direct input string to load the content from.
453456 * @param parentFolder The temporary folder to use.
454457 * @param httpVersion The HTTP version to use.
458+ * @param requestDecorator The request decorator to use.
455459 * @return The input content's file.
456460 * @throws IOException If an error occurs.
457461 */
458- private File getInputFile (String contentType , MultipartFile inputFile , String inputUri , String inputString , File parentFolder , HttpClient .Version httpVersion ) throws IOException {
462+ private File getInputFile (String contentType , MultipartFile inputFile , String inputUri , String inputString , File parentFolder , HttpClient .Version httpVersion , Consumer < HttpRequest . Builder > requestDecorator ) throws IOException {
459463 File file = null ;
460464 if (CONTENT_TYPE_FILE .equals (contentType )) {
461465 if (inputFile !=null && !inputFile .isEmpty ()) {
@@ -465,7 +469,7 @@ private File getInputFile(String contentType, MultipartFile inputFile, String in
465469 }
466470 } else if (CONTENT_TYPE_URI .equals (contentType )) {
467471 if (StringUtils .isNotBlank (inputUri )) {
468- file = this .fileManager .getFileFromURL (parentFolder , inputUri , httpVersion );
472+ file = this .fileManager .getFileFromURL (parentFolder , inputUri , null , null , null , null , null , null , httpVersion , requestDecorator ). getFile ( );
469473 }
470474 } else if (CONTENT_TYPE_STRING .equals (contentType )) {
471475 if (StringUtils .isNotBlank (inputString )) {
0 commit comments