11package com .mindee .v1 ;
22
33import com .mindee .MindeeException ;
4- import com .mindee .input .InputSourceUtils ;
54import com .mindee .input .LocalInputSource ;
65import com .mindee .input .PageOptions ;
6+ import com .mindee .input .URLInputSource ;
77import com .mindee .pdf .PDFBoxApi ;
88import com .mindee .pdf .PDFOperation ;
99import com .mindee .v1 .clientOptions .PollingOptions ;
@@ -203,7 +203,6 @@ public <T extends Inference> AsyncPredictResponse<T> enqueue(
203203 Class <T > type ,
204204 URL sourceUrl
205205 ) throws IOException {
206- InputSourceUtils .validateUrl (sourceUrl );
207206 return this .enqueue (type , new Endpoint (type ), null , null , null , sourceUrl );
208207 }
209208
@@ -222,7 +221,6 @@ public <T extends Inference> AsyncPredictResponse<T> enqueue(
222221 URL sourceUrl ,
223222 PredictOptions predictOptions
224223 ) throws IOException {
225- InputSourceUtils .validateUrl (sourceUrl );
226224 return this .enqueue (type , new Endpoint (type ), null , null , predictOptions , sourceUrl );
227225 }
228226
@@ -232,8 +230,12 @@ private <T extends Inference> AsyncPredictResponse<T> enqueue(
232230 byte [] file ,
233231 String filename ,
234232 PredictOptions predictOptions ,
235- URL urlInputSource
233+ URL url
236234 ) throws IOException {
235+ URLInputSource urlInputSource = null ;
236+ if (url != null ) {
237+ urlInputSource = new URLInputSource .Builder (url ).build ();
238+ }
237239 RequestParameters params = RequestParameters
238240 .builder ()
239241 .file (file )
@@ -402,7 +404,6 @@ public <T extends Inference> AsyncPredictResponse<T> enqueueAndParse(
402404 Class <T > type ,
403405 URL sourceUrl
404406 ) throws IOException , InterruptedException {
405- InputSourceUtils .validateUrl (sourceUrl );
406407 return this .enqueueAndParse (type , new Endpoint (type ), null , null , null , null , sourceUrl );
407408 }
408409
@@ -441,11 +442,18 @@ private <T extends Inference> AsyncPredictResponse<T> enqueueAndParse(
441442 byte [] file ,
442443 String filename ,
443444 PredictOptions predictOptions ,
444- URL urlInputSource
445+ URL url
445446 ) throws IOException , InterruptedException {
446447 if (pollingOptions == null ) {
447448 pollingOptions = PollingOptions .builder ().build ();
448449 }
450+ URL validatedUrl = null ;
451+ if (url != null ) {
452+ var urlInputSource = new URLInputSource .Builder (url ).build ();
453+ urlInputSource .validateSecure ();
454+ validatedUrl = urlInputSource .getUrl ();
455+ }
456+
449457 this .validateAsyncParams (pollingOptions );
450458 final int initialDelaySec = (int ) (pollingOptions .getInitialDelaySec () * 1000 );
451459 final int intervalSec = (int ) (pollingOptions .getIntervalSec () * 1000 );
@@ -456,7 +464,7 @@ private <T extends Inference> AsyncPredictResponse<T> enqueueAndParse(
456464 file ,
457465 filename ,
458466 predictOptions ,
459- urlInputSource
467+ validatedUrl
460468 );
461469
462470 String jobId = enqueueResponse .getJob ().getId ();
@@ -648,7 +656,6 @@ public <T extends Inference> PredictResponse<T> parse(
648656 Class <T > type ,
649657 URL urlInputSource
650658 ) throws IOException {
651- InputSourceUtils .validateUrl (urlInputSource );
652659 return this .parse (type , new Endpoint (type ), null , null , null , urlInputSource );
653660 }
654661
@@ -667,7 +674,6 @@ public <T extends Inference> PredictResponse<T> parse(
667674 URL urlInputSource ,
668675 PredictOptions predictOptions
669676 ) throws IOException {
670- InputSourceUtils .validateUrl (urlInputSource );
671677 return this .parse (type , new Endpoint (type ), null , null , predictOptions , urlInputSource );
672678 }
673679
@@ -677,8 +683,12 @@ private <T extends Inference> PredictResponse<T> parse(
677683 byte [] file ,
678684 String filename ,
679685 PredictOptions predictOptions ,
680- URL urlInputSource
686+ URL url
681687 ) throws IOException {
688+ URLInputSource urlInputSource = null ;
689+ if (url != null ) {
690+ urlInputSource = new URLInputSource .Builder (url ).build ();
691+ }
682692 RequestParameters params = RequestParameters
683693 .builder ()
684694 .file (file )
@@ -760,7 +770,6 @@ public <T extends GeneratedV1> AsyncPredictResponse<T> enqueue(
760770 Endpoint endpoint ,
761771 URL sourceUrl
762772 ) throws IOException {
763- InputSourceUtils .validateUrl (sourceUrl );
764773 return this .enqueue (type , endpoint , null , null , null , sourceUrl );
765774 }
766775
@@ -781,7 +790,6 @@ public <T extends GeneratedV1> AsyncPredictResponse<T> enqueue(
781790 URL sourceUrl ,
782791 PredictOptions predictOptions
783792 ) throws IOException {
784- InputSourceUtils .validateUrl (sourceUrl );
785793 return this .enqueue (type , endpoint , null , null , predictOptions , sourceUrl );
786794 }
787795
@@ -893,7 +901,6 @@ public <T extends GeneratedV1> AsyncPredictResponse<T> enqueueAndParse(
893901 Endpoint endpoint ,
894902 URL sourceUrl
895903 ) throws IOException , InterruptedException {
896- InputSourceUtils .validateUrl (sourceUrl );
897904 return this .enqueueAndParse (type , endpoint , null , null , null , null , sourceUrl );
898905 }
899906
@@ -1024,7 +1031,6 @@ public <T extends GeneratedV1> PredictResponse<T> parse(
10241031 Endpoint endpoint ,
10251032 URL documentUrl
10261033 ) throws IOException {
1027- InputSourceUtils .validateUrl (documentUrl );
10281034 return this .parse (type , endpoint , null , null , null , documentUrl );
10291035 }
10301036
@@ -1045,7 +1051,6 @@ public <T extends GeneratedV1> PredictResponse<T> parse(
10451051 URL documentUrl ,
10461052 PredictOptions predictOptions
10471053 ) throws IOException {
1048- InputSourceUtils .validateUrl (documentUrl );
10491054 return this .parse (type , endpoint , null , null , predictOptions , documentUrl );
10501055 }
10511056
0 commit comments