66import edu .caltech .ipac .astro .ibe .datasource .AtlasIbeDataSource ;
77import edu .caltech .ipac .firefly .data .FileInfo ;
88import edu .caltech .ipac .firefly .server .network .HttpServiceInput ;
9+ import edu .caltech .ipac .firefly .server .network .HttpServices ;
910import edu .caltech .ipac .firefly .server .query .DataAccessException ;
1011import edu .caltech .ipac .firefly .server .query .URLFileInfoProcessor ;
1112import edu .caltech .ipac .table .DataGroup ;
1920
2021import java .io .File ;
2122import java .io .IOException ;
22- import java .net .MalformedURLException ;
2323import java .net .URL ;
24- import java .util .Collections ;
2524import java .util .Map ;
2625
2726import static edu .caltech .ipac .astro .ibe .BaseIbeDataSource .addUrlParam ;
@@ -39,7 +38,6 @@ public class IBE {
3938 public static final String POS = "POS" ;
4039
4140 private IbeDataSource ibeDataSource ;
42- private IbeFileUploader fileUploader ;
4341
4442
4543 public IBE (IbeDataSource ibeDataSource ) {
@@ -50,10 +48,6 @@ public IbeDataSource getIbeDataSource() {
5048 return ibeDataSource ;
5149 }
5250
53- public void setFileUploader (IbeFileUploader fileUploader ) {
54- this .fileUploader = fileUploader ;
55- }
56-
5751 public void getMetaData (File results ) throws IOException {
5852
5953 String url = ibeDataSource .getMetaDataUrl ();
@@ -66,22 +60,17 @@ public void query(File results, IbeQueryParam param) throws IOException {
6660 }
6761
6862 public void multipleQueries (File results , File posFile , IbeQueryParam param ) {
69- if (fileUploader == null ) {
70- try {
71- fileUploader = (IbeFileUploader ) Class .forName ("edu.caltech.ipac.firefly.server.query.ibe.IbeFileUploaderImpl" ).newInstance ();
72- } catch (Exception e ) {
73- throw new UnsupportedOperationException ("You need an IbeFileUploader to do multiple queries search." );
74- }
75- }
76-
7763 String url = ibeDataSource .getSearchUrl ();
7864
7965 Map <String , String > paramMap = ibeDataSource .getMulipleQueryParam (param );
8066 paramMap .remove (POS );
81- try {
82- fileUploader .post (results , POS , posFile , new URL (url ), paramMap );
83- } catch (MalformedURLException e ) {
84- throw new IllegalArgumentException ("IBE URL is bad." );
67+ HttpServiceInput input = HttpServiceInput .createWithCredential (url );
68+ paramMap .forEach (input ::setParam );
69+ input .setFile (POS , posFile );
70+
71+ HttpServices .Status status = HttpServices .postData (input , results );
72+ if (status .isError ()) {
73+ throw new RuntimeException (String .format ("IBE multi POS search failed with (%d) - %s" , status .getStatusCode (), status .getErrMsg ()));
8574 }
8675 }
8776
@@ -173,7 +162,10 @@ private FileInfo downloadViaUrl(URL url, Map<String, String> sourceParams, File
173162
174163 private void downloadViaUrlToFile (URL url , File results ) throws IOException {
175164 try {
176- URLDownload .getDataToFile (url , results , null , Collections .singletonMap ("Accept" , "text/plain" ));
165+ HttpServiceInput addtlInfo = HttpServiceInput .createWithCredential (url .toString ());
166+ addtlInfo .setHeader ("Accept" , "text/plain" );
167+
168+ URLDownload .getDataToFile (url , results , addtlInfo .getCookies (), addtlInfo .getHeaders ());
177169 } catch (FailedRequestException e ) {
178170 throw new IOException (e .getUserMessage (), e );
179171 }
0 commit comments