Revision 38421 branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/DefaultPackageInfo.java
DefaultPackageInfo.java | ||
---|---|---|
394 | 394 |
|
395 | 395 |
Download download = new Download(taskStatus); |
396 | 396 |
|
397 |
// First download from the index base URL this package info has |
|
398 |
// been downloaded from. If not there, download from the URL |
|
399 |
// available in the downloadURL property. |
|
400 |
InstallerManager manager = InstallerLocator.getInstallerManager(); |
|
401 |
URL baseURL = manager.getDownloadBaseURL(); |
|
402 |
String relativePath = |
|
403 |
"../../pool/" + getCode() + "/" + getPackageFileName(); |
|
404 |
try { |
|
405 |
URL downloadURL = new URL(baseURL, relativePath); |
|
406 |
return download.downloadFile(downloadURL, null); |
|
407 |
} catch (IOException e) { |
|
408 |
LOG.debug("Package " + getName() |
|
409 |
+ " not found relative to the index URL: " + baseURL, e); |
|
410 |
try { |
|
411 |
return download.downloadFile(this.getDownloadURL(), null); |
|
412 |
} catch (IOException e2) { |
|
413 |
throw new FileDownloadException(this.getDownloadURL(), e); |
|
414 |
} |
|
415 |
} |
|
416 |
} |
|
397 |
// First try to download from the index base URL this package info has |
|
398 |
// been downloaded from, looking first as if the index is located in the |
|
399 |
// main version folder, and if not in the build folder. |
|
400 |
// If also not there, download from the URL available in the |
|
401 |
// downloadURL property. |
|
402 |
// Example baseURL: http://downloads.gvsig.org/download/gvsig-desktop/dists/2.0.0/ |
|
403 |
String versionRelativePath = "../../pool/" + getCode() + "/" |
|
404 |
+ getPackageFileName(); |
|
405 |
File file = downloadFromRelativeURL(download, versionRelativePath); |
|
417 | 406 |
|
407 |
if (file == null) { |
|
408 |
// Example baseURL: http://downloads.gvsig.org/download/gvsig-desktop/dists/2.0.0/builds/2048/ |
|
409 |
String buildRelativePath = "../../../../pool/" + getCode() + "/" |
|
410 |
+ getPackageFileName(); |
|
411 |
file = downloadFromRelativeURL(download, buildRelativePath); |
|
412 |
} |
|
413 |
|
|
414 |
if (file == null) { |
|
415 |
file = downloadFromPackageInfoURL(download); |
|
416 |
} |
|
417 |
|
|
418 |
return file; |
|
419 |
} |
|
420 |
|
|
421 |
private File downloadFromRelativeURL(Download download, |
|
422 |
String buildRelativePath) { |
|
423 |
InstallerManager manager = InstallerLocator.getInstallerManager(); |
|
424 |
URL baseURL = manager.getDownloadBaseURL(); |
|
425 |
try { |
|
426 |
URL downloadURL = new URL(baseURL, buildRelativePath); |
|
427 |
return download.downloadFile(downloadURL, null); |
|
428 |
} catch (IOException e) { |
|
429 |
LOG.debug("Package " + getName() |
|
430 |
+ " not found relative to the build index URL: " + baseURL |
|
431 |
+ ", in the URL: " + buildRelativePath, e); |
|
432 |
} |
|
433 |
return null; |
|
434 |
} |
|
435 |
|
|
436 |
private File downloadFromPackageInfoURL(Download download) throws FileDownloadException { |
|
437 |
try { |
|
438 |
return download.downloadFile(this.getDownloadURL(), null); |
|
439 |
} catch (IOException ex3) { |
|
440 |
throw new FileDownloadException(this.getDownloadURL(), ex3); |
|
441 |
} |
|
442 |
} |
|
443 |
|
|
418 | 444 |
private String getPackageFileName() { |
419 | 445 |
Object[] values = |
420 | 446 |
new Object[] { "gvSIG-desktop", getGvSIGVersion(), getCode(), |
Also available in: Unified diff