Changeset 621 for AE/installer2/src/net/oni2/aeinstaller/backend/depot
- Timestamp:
- Jan 15, 2013, 9:02:01 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/backend/depot
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotConfig.java
r604 r621 1 1 package net.oni2.aeinstaller.backend.depot; 2 3 import net.oni2.aeinstaller.backend.Settings; 2 4 3 5 /** … … 76 78 return 8000; 77 79 } 80 81 /** 82 * @return URL of Depot 83 */ 84 public static String getDepotUrl() { 85 return Settings.getInstance().get("depot_url", "http://mods.oni2.net/"); 86 } 87 88 /** 89 * @return URL of Depot API 90 */ 91 public static String getDepotApiUrl() { 92 return Settings.getInstance().get("depot_api_url", 93 "http://mods.oni2.net/?q=api/"); 94 } 78 95 } -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotManager.java
r605 r621 5 5 import java.io.FileOutputStream; 6 6 import java.io.IOException; 7 import java.io.UnsupportedEncodingException; 8 import java.net.UnknownHostException; 7 9 import java.util.HashMap; 8 10 import java.util.HashSet; … … 21 23 import net.oni2.aeinstaller.backend.network.DrupalJSONQuery; 22 24 25 import org.apache.http.HttpResponse; 26 import org.apache.http.client.methods.HttpGet; 27 import org.apache.http.client.methods.HttpRequestBase; 28 import org.apache.http.impl.client.DefaultHttpClient; 23 29 import org.json.JSONArray; 24 30 import org.json.JSONException; … … 221 227 222 228 /** 229 * @return Can we connect to the Depot? 230 */ 231 public boolean checkConnection() { 232 HttpRequestBase httpQuery = null; 233 234 try { 235 DefaultHttpClient httpclient = new DefaultHttpClient(); 236 httpQuery = new HttpGet(DepotConfig.getDepotUrl()); 237 238 HttpResponse response = httpclient.execute(httpQuery); 239 240 int code = response.getStatusLine().getStatusCode(); 241 242 return (code >= 200) && (code <= 299); 243 } catch (UnknownHostException e) { 244 } catch (UnsupportedEncodingException e) { 245 e.printStackTrace(); 246 } catch (IOException e) { 247 e.printStackTrace(); 248 } finally { 249 if (httpQuery != null) 250 httpQuery.releaseConnection(); 251 } 252 return false; 253 } 254 255 /** 223 256 * @return All TaxVocabs 224 257 */
Note:
See TracChangeset
for help on using the changeset viewer.