|
Lines 638-654
Link Here
|
| 638 |
//add the repository first so that it will be enabled, but don't send add event until after the load |
638 |
//add the repository first so that it will be enabled, but don't send add event until after the load |
| 639 |
added = addRepository(location, true, false); |
639 |
added = addRepository(location, true, false); |
| 640 |
|
640 |
|
| 641 |
// get the search order from the server, if it's available |
641 |
LocationProperties indexFile = loadIndexFile(location, monitor); |
| 642 |
ByteArrayOutputStream index = new ByteArrayOutputStream(); |
|
|
| 643 |
LocationProperties locationProperties = null; |
| 644 |
try { |
| 645 |
getTransport().download(getIndexFile(location), index, monitor); |
| 646 |
} catch (Throwable e) { |
| 647 |
// If any exceptions are thrown, just ignore the index file |
| 648 |
} |
| 649 |
|
642 |
|
| 650 |
locationProperties = LocationProperties.create(new ByteArrayInputStream(index.toByteArray())); |
643 |
String[] preferredOrder = getPreferredRepositorySearchOrder(indexFile); |
| 651 |
String[] preferredOrder = getPreferredRepositorySearchOrder(locationProperties); |
|
|
| 652 |
String[] suffixes = sortSuffixes(getAllSuffixes(), location, preferredOrder); |
644 |
String[] suffixes = sortSuffixes(getAllSuffixes(), location, preferredOrder); |
| 653 |
|
645 |
|
| 654 |
SubMonitor sub = SubMonitor.convert(monitor, NLS.bind(Messages.repoMan_adding, location), suffixes.length * 100); |
646 |
SubMonitor sub = SubMonitor.convert(monitor, NLS.bind(Messages.repoMan_adding, location), suffixes.length * 100); |
|
Lines 694-699
Link Here
|
| 694 |
} |
686 |
} |
| 695 |
|
687 |
|
| 696 |
/** |
688 |
/** |
|
|
689 |
* Fetches the p2.index file from the server. If the file could not be fetched |
| 690 |
* a NullSafe version is returned. |
| 691 |
*/ |
| 692 |
private LocationProperties loadIndexFile(URI location, IProgressMonitor monitor) { |
| 693 |
// get the search order from the server, if it's available |
| 694 |
ByteArrayOutputStream index = new ByteArrayOutputStream(); |
| 695 |
LocationProperties locationProperties = LocationProperties.createEmptyIndexFile(); |
| 696 |
IStatus indexFileStatus = null; |
| 697 |
try { |
| 698 |
indexFileStatus = getTransport().download(getIndexFileURI(location), index, monitor); |
| 699 |
} catch (URISyntaxException uriSyntaxException) { |
| 700 |
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, uriSyntaxException.getMessage(), uriSyntaxException)); |
| 701 |
indexFileStatus = null; |
| 702 |
} |
| 703 |
|
| 704 |
if (indexFileStatus != null && indexFileStatus.isOK()) |
| 705 |
locationProperties = LocationProperties.create(new ByteArrayInputStream(index.toByteArray())); |
| 706 |
|
| 707 |
return locationProperties; |
| 708 |
} |
| 709 |
|
| 710 |
/** |
| 697 |
* Basic sanity checking on location argument |
711 |
* Basic sanity checking on location argument |
| 698 |
*/ |
712 |
*/ |
| 699 |
private URI checkValidLocation(URI location) { |
713 |
private URI checkValidLocation(URI location) { |
|
Lines 1121-1127
Link Here
|
| 1121 |
} |
1135 |
} |
| 1122 |
} |
1136 |
} |
| 1123 |
|
1137 |
|
| 1124 |
private static URI getIndexFile(URI base) throws URISyntaxException { |
1138 |
private static URI getIndexFileURI(URI base) throws URISyntaxException { |
| 1125 |
final String name = INDEX_FILE; |
1139 |
final String name = INDEX_FILE; |
| 1126 |
String spec = base.toString(); |
1140 |
String spec = base.toString(); |
| 1127 |
if (spec.endsWith(name)) |
1141 |
if (spec.endsWith(name)) |