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,12 @@ 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+
449451 this .validateAsyncParams (pollingOptions );
450452 final int initialDelaySec = (int ) (pollingOptions .getInitialDelaySec () * 1000 );
451453 final int intervalSec = (int ) (pollingOptions .getIntervalSec () * 1000 );
@@ -456,7 +458,7 @@ private <T extends Inference> AsyncPredictResponse<T> enqueueAndParse(
456458 file ,
457459 filename ,
458460 predictOptions ,
459- urlInputSource
461+ url
460462 );
461463
462464 String jobId = enqueueResponse .getJob ().getId ();
@@ -648,7 +650,6 @@ public <T extends Inference> PredictResponse<T> parse(
648650 Class <T > type ,
649651 URL urlInputSource
650652 ) throws IOException {
651- InputSourceUtils .validateUrl (urlInputSource );
652653 return this .parse (type , new Endpoint (type ), null , null , null , urlInputSource );
653654 }
654655
@@ -667,7 +668,6 @@ public <T extends Inference> PredictResponse<T> parse(
667668 URL urlInputSource ,
668669 PredictOptions predictOptions
669670 ) throws IOException {
670- InputSourceUtils .validateUrl (urlInputSource );
671671 return this .parse (type , new Endpoint (type ), null , null , predictOptions , urlInputSource );
672672 }
673673
@@ -677,8 +677,12 @@ private <T extends Inference> PredictResponse<T> parse(
677677 byte [] file ,
678678 String filename ,
679679 PredictOptions predictOptions ,
680- URL urlInputSource
680+ URL url
681681 ) throws IOException {
682+ URLInputSource urlInputSource = null ;
683+ if (url != null ) {
684+ urlInputSource = new URLInputSource .Builder (url ).build ();
685+ }
682686 RequestParameters params = RequestParameters
683687 .builder ()
684688 .file (file )
@@ -760,7 +764,6 @@ public <T extends GeneratedV1> AsyncPredictResponse<T> enqueue(
760764 Endpoint endpoint ,
761765 URL sourceUrl
762766 ) throws IOException {
763- InputSourceUtils .validateUrl (sourceUrl );
764767 return this .enqueue (type , endpoint , null , null , null , sourceUrl );
765768 }
766769
@@ -781,7 +784,6 @@ public <T extends GeneratedV1> AsyncPredictResponse<T> enqueue(
781784 URL sourceUrl ,
782785 PredictOptions predictOptions
783786 ) throws IOException {
784- InputSourceUtils .validateUrl (sourceUrl );
785787 return this .enqueue (type , endpoint , null , null , predictOptions , sourceUrl );
786788 }
787789
@@ -893,7 +895,6 @@ public <T extends GeneratedV1> AsyncPredictResponse<T> enqueueAndParse(
893895 Endpoint endpoint ,
894896 URL sourceUrl
895897 ) throws IOException , InterruptedException {
896- InputSourceUtils .validateUrl (sourceUrl );
897898 return this .enqueueAndParse (type , endpoint , null , null , null , null , sourceUrl );
898899 }
899900
@@ -1024,7 +1025,6 @@ public <T extends GeneratedV1> PredictResponse<T> parse(
10241025 Endpoint endpoint ,
10251026 URL documentUrl
10261027 ) throws IOException {
1027- InputSourceUtils .validateUrl (documentUrl );
10281028 return this .parse (type , endpoint , null , null , null , documentUrl );
10291029 }
10301030
@@ -1045,7 +1045,6 @@ public <T extends GeneratedV1> PredictResponse<T> parse(
10451045 URL documentUrl ,
10461046 PredictOptions predictOptions
10471047 ) throws IOException {
1048- InputSourceUtils .validateUrl (documentUrl );
10491048 return this .parse (type , endpoint , null , null , predictOptions , documentUrl );
10501049 }
10511050
0 commit comments