Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 312284
Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java (-11 / +25 lines)
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))
(-)src/org/eclipse/equinox/internal/p2/repository/helpers/LocationProperties.java (+4 lines)
Lines 51-56 Link Here
51
	private String[] artifactSearchOrder = new String[0]; // Version 1
51
	private String[] artifactSearchOrder = new String[0]; // Version 1
52
	private Map<String, Boolean> md5Hashes = null; // Version 1
52
	private Map<String, Boolean> md5Hashes = null; // Version 1
53
53
54
	public static LocationProperties createEmptyIndexFile() {
55
		return new LocationProperties();
56
	}
57
54
	/**
58
	/**
55
	 * Creates a LocationProperties Object from an input stream. If the LocationProperties
59
	 * Creates a LocationProperties Object from an input stream. If the LocationProperties
56
	 * could be created, it is returned.  If it could not be created, an empty LocationProperties
60
	 * could be created, it is returned.  If it could not be created, an empty LocationProperties

Return to bug 312284