Changeset 621 for AE/installer2/src/net/oni2/aeinstaller/backend
- Timestamp:
- Jan 15, 2013, 9:02:01 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/backend
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/backend/Settings.java
r619 r621 65 65 66 66 private boolean printNamesNotInMap = false; 67 68 private boolean offlineMode = false; 67 69 68 70 /** … … 161 163 162 164 /** 165 * @return Is offline? 166 */ 167 public boolean isOfflineMode() { 168 return offlineMode; 169 } 170 171 /** 172 * @param offline 173 * Is offline? 174 */ 175 public void setOfflineMode(boolean offline) { 176 this.offlineMode = offline; 177 } 178 179 /** 163 180 * @return Mod Depot cache filename 164 181 */ -
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 */ -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/ModManager.java
r608 r621 182 182 183 183 /** 184 * @return Mods which are already locally available 185 */ 186 public TreeSet<Mod> getLocalAvailableMods() { 187 TreeSet<Mod> res = new TreeSet<Mod>(); 188 for (Mod m : mods.values()) { 189 if (m.isLocalAvailable()) 190 res.add(m); 191 } 192 return res; 193 } 194 195 /** 196 * @return Mods which can be updated 197 */ 198 public TreeSet<Mod> getUpdatableMods() { 199 TreeSet<Mod> res = new TreeSet<Mod>(); 200 for (Mod m : getLocalAvailableMods()) { 201 if (m.isNewerAvailable()) 202 res.add(m); 203 } 204 return res; 205 } 206 207 /** 184 208 * @return Collection of tools valid on this platform and not mandatory 185 209 */ … … 199 223 for (Mod m : tools.values()) { 200 224 if (m.isValidOnPlatform() && m.isMandatoryMod()) 225 res.add(m); 226 } 227 return res; 228 } 229 230 /** 231 * @return Tools which are already locally available 232 */ 233 public TreeSet<Mod> getLocalAvailableTools() { 234 TreeSet<Mod> res = new TreeSet<Mod>(); 235 for (Mod m : tools.values()) { 236 if (m.isLocalAvailable()) 237 res.add(m); 238 } 239 return res; 240 } 241 242 /** 243 * @return Tools which can be updated 244 */ 245 public TreeSet<Mod> getUpdatableTools() { 246 TreeSet<Mod> res = new TreeSet<Mod>(); 247 for (Mod m : getLocalAvailableTools()) { 248 if (m.isNewerAvailable()) 201 249 res.add(m); 202 250 } -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/download/ModDownload.java
r605 r621 80 80 unpacker = new Unpacker(zipFile, targetFolder, this); 81 81 } catch (IOException e) { 82 // TODO Auto-generated catch block83 82 e.printStackTrace(); 84 83 } -
AE/installer2/src/net/oni2/aeinstaller/backend/network/DrupalJSONQuery.java
r605 r621 9 9 import java.util.List; 10 10 11 import net.oni2.aeinstaller.backend. Settings;11 import net.oni2.aeinstaller.backend.depot.DepotConfig; 12 12 13 13 import org.apache.http.HttpEntity; … … 29 29 */ 30 30 public class DrupalJSONQuery { 31 32 private static String getDepotUrl() {33 return Settings.getInstance().get("depot_api_url",34 "http://mods.oni2.net/?q=api/");35 }36 31 37 32 /** … … 56 51 } 57 52 HttpEntity data = new UrlEncodedFormEntity(nvps); 58 return executeQuery( getDepotUrl() + resource + "/" + action53 return executeQuery(DepotConfig.getDepotApiUrl() + resource + "/" + action 59 54 + ".json", data); 60 55 } catch (UnsupportedEncodingException e) { … … 80 75 String refName) throws Exception { 81 76 return executeQuery( 82 getDepotUrl() + resource + "/" + Integer.toString(index) + "/"77 DepotConfig.getDepotApiUrl() + resource + "/" + Integer.toString(index) + "/" 83 78 + refName + ".json", null); 84 79 } … … 100 95 String parameters) throws Exception { 101 96 return executeQuery( 102 getDepotUrl() + resource + "/" + Integer.toString(index)97 DepotConfig.getDepotApiUrl() + resource + "/" + Integer.toString(index) 103 98 + ".json" + parameters, null); 104 99 } … … 126 121 if (pagesize >= 0) 127 122 pagesizeN = "&pagesize=" + Integer.toString(pagesize); 128 return executeQuery( getDepotUrl() + resource + ".json" + pageN123 return executeQuery(DepotConfig.getDepotApiUrl() + resource + ".json" + pageN 129 124 + pagesizeN, null); 130 125 }
Note:
See TracChangeset
for help on using the changeset viewer.