Changeset 857 for java/installer2/src/net/oni2/aeinstaller/backend/packages
- Timestamp:
- May 3, 2013, 11:52:50 PM (12 years ago)
- Location:
- java/installer2/src/net/oni2/aeinstaller/backend/packages
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
java/installer2/src/net/oni2/aeinstaller/backend/packages/Package.java
r804 r857 37 37 private String submitter = ""; 38 38 private String creator = ""; 39 private EBSLInstallType bslInstallType = EBSLInstallType.NORMAL;39 private transient EBSLInstallType bslInstallType = EBSLInstallType.NORMAL; 40 40 private String description = ""; 41 private double aeVersion = 0;41 private transient double aeVersion = 0; 42 42 private int zipSize = 0; 43 private NodeMod node = null; 44 private net.oni2.moddepot.model.File file = null; 45 46 private File exeFile = null; 47 private EExeType exeType = EExeType.OSBINARY; 48 private File iconFile = null; 49 private String workingDir = "Base"; 50 51 private HashSet<Integer> incompatibilities = new HashSet<Integer>(); 52 private HashSet<Integer> dependencies = new HashSet<Integer>(); 53 private HashSet<Integer> unlockLevel = new HashSet<Integer>(); 54 55 private long localTimestamp = 0; 43 44 private URI nodeUrl = null; 45 private String fileUrl = null; 46 47 private long createdMillis = -1; 48 private long updatedMillis = -1; 49 50 private transient File exeFile = null; 51 private transient EExeType exeType = EExeType.OSBINARY; 52 private transient File iconFile = null; 53 private transient String workingDir = "Base"; 54 55 private transient HashSet<Integer> incompatibilities = new HashSet<Integer>(); 56 private transient HashSet<Integer> dependencies = new HashSet<Integer>(); 57 private transient HashSet<Integer> unlockLevel = new HashSet<Integer>(); 58 59 private transient long localTimestamp = 0; 56 60 57 61 /** … … 62 66 */ 63 67 public Package(NodeMod nm) { 64 node = nm;65 68 name = nm.getTitle(); 66 69 packageNumber = nm.getPackageNumber(); … … 73 76 t.addEntry(this); 74 77 } 78 79 createdMillis = nm.getCreated(); 80 updatedMillis = nm.getUploads().firstElement().getTimestamp(); 81 82 try { 83 nodeUrl = new URI(nm.getPath()); 84 } catch (URISyntaxException e) { 85 e.printStackTrace(); 86 } 87 88 fileUrl = nm.getUploads().firstElement().getUri_full(); 89 zipSize = nm.getUploads().firstElement().getFilesize(); 90 75 91 version = nm.getVersion(); 76 92 submitter = nm.getName(); … … 81 97 description = "<p>" + description + "</p>"; 82 98 } 83 file = nm.getUploads().firstElement();84 zipSize = file.getFilesize();85 99 86 100 if (isLocalAvailable()) … … 115 129 aeVersion = mi.getAeVersion(); 116 130 bslInstallType = mi.getBslInstallType(); 117 if ( node == null) {131 if (isLocalOnly()) { 118 132 name = mi.getName(); 119 133 creator = mi.getCreator(); … … 132 146 } else { 133 147 clearLocalOnlyInfo(); 134 System.err.println("No config found for mod folder: "135 + getLocalPath().getPath());148 // System.err.println("No config found for mod folder: " 149 // + getLocalPath().getPath()); 136 150 } 137 151 if (aeicfg.exists()) { … … 159 173 } 160 174 } 161 if ( node == null)175 if (isLocalOnly()) 162 176 tool = plain.exists(); 163 177 } … … 212 226 */ 213 227 public boolean isNewerAvailable() { 214 if ( file != null)215 return file.getTimestamp()> localTimestamp;228 if (!isLocalOnly()) 229 return updatedMillis > localTimestamp; 216 230 else 217 231 return false; … … 226 240 227 241 /** 242 * @return If this mod is only locally available (not on Depot) 243 */ 244 public boolean isLocalOnly() { 245 return nodeUrl == null; 246 } 247 248 /** 228 249 * @return Is mod installed? 229 250 */ 230 251 public boolean isInstalled() { 231 252 if (tool) 232 return ToolInstallationList.getInstance().isInstalled(packageNumber); 253 return ToolInstallationList.getInstance() 254 .isInstalled(packageNumber); 233 255 else 234 256 return PackageManager.getInstance().isModInstalled(this); … … 320 342 321 343 /** 344 * @return the createdMillis 345 */ 346 public long getCreatedMillis() { 347 return createdMillis; 348 } 349 350 /** 351 * @return the updatedMillis 352 */ 353 public long getUpdatedMillis() { 354 return updatedMillis; 355 } 356 357 /** 358 * @return the fileUrl 359 */ 360 public String getFileUrl() { 361 return fileUrl; 362 } 363 364 /** 322 365 * @return Is a package that is always installed? 323 366 */ … … 327 370 328 371 /** 329 * @return Get the depot file entry330 */331 public net.oni2.moddepot.model.File getFile() {332 return file;333 }334 335 /**336 * @return Get the depot Node337 */338 public NodeMod getNode() {339 return node;340 }341 342 /**343 372 * @return Depot page URI 344 373 */ 345 374 public URI getUrl() { 346 if (node == null) 347 return null; 348 if (node.getPath() == null) 349 return null; 350 URI res = null; 351 try { 352 res = new URI(node.getPath()); 353 } catch (URISyntaxException e) { 354 e.printStackTrace(); 355 } 356 return res; 375 return nodeUrl; 357 376 } 358 377 -
java/installer2/src/net/oni2/aeinstaller/backend/packages/PackageManager.java
r809 r857 21 21 22 22 import com.thoughtworks.xstream.XStream; 23 import com.thoughtworks.xstream.XStreamException; 23 24 import com.thoughtworks.xstream.io.xml.StaxDriver; 24 25 … … 32 33 private HashMap<Integer, Package> mods = new HashMap<Integer, Package>(); 33 34 private HashMap<Integer, Package> tools = new HashMap<Integer, Package>(); 35 private Type localType = null; 34 36 35 37 /** … … 88 90 mods = new HashMap<Integer, Package>(); 89 91 90 TypelocalType = new Type("-Local-");92 localType = new Type("-Local-"); 91 93 types.put("-Local-", localType); 92 94 93 95 for (TaxonomyTerm tt : DepotManager.getInstance().getTypes()) { 94 96 types.put(tt.getName(), new Type(tt.getName())); 95 }96 97 HashMap<Integer, Package> modFolders = new HashMap<Integer, Package>();98 if (Paths.getModsPath().exists()) {99 for (File f : Paths.getModsPath().listFiles(new FileFilter() {100 @Override101 public boolean accept(File pathname) {102 return pathname.isDirectory();103 }104 })) {105 Package m = new Package(f);106 modFolders.put(m.getPackageNumber(), m);107 }108 97 } 109 98 … … 115 104 else 116 105 mods.put(m.getPackageNumber(), m); 117 modFolders.remove(m.getPackageNumber()); 118 } 119 } 120 121 for (Package m : modFolders.values()) { 122 if (!m.isCorePackage()) { 123 localType.addEntry(m); 124 m.getTypes().add(localType); 125 } 126 if (m.isTool()) 127 tools.put(m.getPackageNumber(), m); 128 else 129 mods.put(m.getPackageNumber(), m); 130 } 106 } 107 } 108 109 updateLocalData(); 131 110 } 132 111 … … 345 324 */ 346 325 boolean isModInstalled(Package m) { 347 return ModInstallationList.getInstance().isInstalled(m.getPackageNumber()); 326 return ModInstallationList.getInstance().isInstalled( 327 m.getPackageNumber()); 328 } 329 330 private void updateLocalData() { 331 if (Paths.getModsPath().exists()) { 332 for (File f : Paths.getModsPath().listFiles(new FileFilter() { 333 @Override 334 public boolean accept(File pathname) { 335 return pathname.isDirectory(); 336 } 337 })) { 338 Package m = new Package(f); 339 HashMap<Integer, Package> map = null; 340 if (m.isTool()) 341 map = tools; 342 else 343 map = mods; 344 345 if (!map.containsKey(m.getPackageNumber())) { 346 map.put(m.getPackageNumber(), m); 347 if (!m.isCorePackage()) { 348 localType.addEntry(m); 349 m.getTypes().add(localType); 350 } 351 } 352 } 353 } 354 355 for (Package p : mods.values()) { 356 p.updateLocalData(); 357 } 358 for (Package p : tools.values()) { 359 p.updateLocalData(); 360 } 361 } 362 363 private static XStream getXStream() { 364 XStream xs = new XStream(new StaxDriver()); 365 xs.alias("Packages", PackageManager.class); 366 xs.alias("Type", Type.class); 367 xs.alias("Package", Package.class); 368 return xs; 369 } 370 371 /** 372 * Save Depot cache instance to file 373 * 374 * @param cacheFile 375 * File to save to 376 */ 377 public void saveToCacheFile(java.io.File cacheFile) { 378 try { 379 FileOutputStream fos = new FileOutputStream(cacheFile); 380 XStream xs = getXStream(); 381 xs.toXML(this, fos); 382 fos.close(); 383 } catch (FileNotFoundException e) { 384 e.printStackTrace(); 385 } catch (IOException e) { 386 e.printStackTrace(); 387 } 388 } 389 390 /** 391 * Load cache from file 392 * 393 * @param cacheFile 394 * File to load 395 */ 396 public static void loadFromCacheFile(java.io.File cacheFile) { 397 try { 398 FileInputStream fis = new FileInputStream(cacheFile); 399 XStream xs = getXStream(); 400 Object obj = xs.fromXML(fis); 401 fis.close(); 402 if (obj instanceof PackageManager) { 403 instance = (PackageManager) obj; 404 instance.updateLocalData(); 405 } 406 } catch (XStreamException e) { 407 } catch (FileNotFoundException e) { 408 } catch (IOException e) { 409 } 348 410 } 349 411 } -
java/installer2/src/net/oni2/aeinstaller/backend/packages/download/ModDownload.java
r741 r857 74 74 targetFolder = mod.getLocalPath(); 75 75 try { 76 downloader = new FileDownloader(mod.getFile().getUri_full(), 77 zipFile); 76 downloader = new FileDownloader(mod.getFileUrl(), zipFile); 78 77 downloader.addListener(this); 79 78 unpacker = new Unpacker(zipFile, targetFolder, this); … … 130 129 try { 131 130 log = new PrintWriter(logFile); 132 log.println("Timestamp -> " + mod.get File().getTimestamp());131 log.println("Timestamp -> " + mod.getUpdatedMillis()); 133 132 } catch (FileNotFoundException e) { 134 133 e.printStackTrace();
Note:
See TracChangeset
for help on using the changeset viewer.