| 6 |
|
import java.io.FileOutputStream; |
| 7 |
|
import java.io.IOException; |
| 8 |
|
import java.io.InputStreamReader; |
| 9 |
< |
import java.io.UnsupportedEncodingException; |
| 10 |
< |
import java.net.UnknownHostException; |
| 9 |
> |
import java.net.HttpURLConnection; |
| 10 |
> |
import java.net.URL; |
| 11 |
|
import java.util.Date; |
| 12 |
|
import java.util.Enumeration; |
| 13 |
|
import java.util.HashMap; |
| 15 |
|
import java.util.zip.ZipEntry; |
| 16 |
|
import java.util.zip.ZipFile; |
| 17 |
|
|
| 18 |
+ |
import net.oni2.ProxySettings; |
| 19 |
+ |
import net.oni2.httpfiledownloader.FileDownloader; |
| 20 |
|
import net.oni2.moddepot.model.File; |
| 21 |
|
import net.oni2.moddepot.model.Node; |
| 22 |
|
import net.oni2.moddepot.model.NodeField_Body; |
| 24 |
|
import net.oni2.moddepot.model.NodeMod; |
| 25 |
|
import net.oni2.moddepot.model.TaxonomyTerm; |
| 26 |
|
import net.oni2.moddepot.model.TaxonomyVocabulary; |
| 25 |
– |
import net.oni2.httpfiledownloader.FileDownloader; |
| 27 |
|
|
| 27 |
– |
import org.apache.http.HttpResponse; |
| 28 |
– |
import org.apache.http.client.methods.HttpHead; |
| 29 |
– |
import org.apache.http.client.methods.HttpRequestBase; |
| 30 |
– |
import org.apache.http.impl.client.DefaultHttpClient; |
| 28 |
|
import org.json.JSONArray; |
| 29 |
|
import org.json.JSONException; |
| 30 |
|
import org.json.JSONObject; |
| 210 |
|
* @return Can we connect to the Depot? |
| 211 |
|
*/ |
| 212 |
|
public boolean checkConnection() { |
| 216 |
– |
HttpRequestBase httpQuery = null; |
| 217 |
– |
|
| 213 |
|
try { |
| 214 |
< |
DefaultHttpClient httpclient = new DefaultHttpClient(); |
| 215 |
< |
httpQuery = new HttpHead(DepotConfig.depotUrl); |
| 216 |
< |
HttpResponse response = httpclient.execute(httpQuery); |
| 217 |
< |
int code = response.getStatusLine().getStatusCode(); |
| 214 |
> |
HttpURLConnection con = (HttpURLConnection) new URL( |
| 215 |
> |
DepotConfig.depotUrl).openConnection(ProxySettings |
| 216 |
> |
.getInstance().getProxy()); |
| 217 |
> |
con.setRequestMethod("HEAD"); |
| 218 |
> |
int code = con.getResponseCode(); |
| 219 |
|
return (code >= 200) && (code <= 299); |
| 224 |
– |
} catch (UnknownHostException e) { |
| 225 |
– |
} catch (UnsupportedEncodingException e) { |
| 226 |
– |
e.printStackTrace(); |
| 220 |
|
} catch (IOException e) { |
| 221 |
|
e.printStackTrace(); |
| 229 |
– |
} finally { |
| 230 |
– |
if (httpQuery != null) |
| 231 |
– |
httpQuery.releaseConnection(); |
| 222 |
|
} |
| 223 |
|
return false; |
| 224 |
|
} |