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 302160
Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java (-2 / +31 lines)
Lines 12-26 Link Here
12
 *******************************************************************************/
12
 *******************************************************************************/
13
package org.eclipse.equinox.internal.p2.artifact.repository;
13
package org.eclipse.equinox.internal.p2.artifact.repository;
14
14
15
import org.eclipse.equinox.p2.core.ProvisionException;
16
17
import java.io.*;
15
import java.io.*;
16
import java.net.URI;
17
import java.net.URISyntaxException;
18
import java.util.HashMap;
18
import java.util.HashMap;
19
import java.util.Map;
19
import java.util.Map;
20
import org.eclipse.core.runtime.*;
20
import org.eclipse.core.runtime.*;
21
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor;
21
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor;
22
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
23
import org.eclipse.equinox.internal.p2.repository.RepositoryTransport;
22
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler;
24
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler;
23
import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
25
import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
26
import org.eclipse.equinox.p2.core.ProvisionException;
24
import org.eclipse.equinox.p2.metadata.IArtifactKey;
27
import org.eclipse.equinox.p2.metadata.IArtifactKey;
25
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
28
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
26
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
29
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
Lines 160-168 Link Here
160
		do {
163
		do {
161
			status = transferSingle(destinationDescriptor, sourceDescriptor, monitor);
164
			status = transferSingle(destinationDescriptor, sourceDescriptor, monitor);
162
		} while (status.getSeverity() == IStatus.ERROR && status.getCode() == IArtifactRepository.CODE_RETRY);
165
		} while (status.getSeverity() == IStatus.ERROR && status.getCode() == IArtifactRepository.CODE_RETRY);
166
		if (status.isOK())
167
			collectStats(sourceDescriptor, monitor);
163
		return status;
168
		return status;
164
	}
169
	}
165
170
171
	/**
172
	 * Collect download statistics, if specified by the descriptor and the source repository
173
	 */
174
	private void collectStats(IArtifactDescriptor descriptor, IProgressMonitor monitor) {
175
		final String statsProperty = descriptor.getProperty("download.stats");
176
		if (statsProperty == null)
177
			return;
178
		String statsRoot = descriptor.getRepository().getProperties().get("stats.url");
179
		if (statsRoot == null)
180
			return;
181
		URI statsURI;
182
		try {
183
			statsURI = URIUtil.append(new URI(statsRoot), statsProperty);
184
		} catch (URISyntaxException e) {
185
			LogHelper.log(new Status(IStatus.WARNING, Activator.ID, "Unable to report download statistics due to invalid URL: " + statsRoot + " suffix: " + statsProperty));
186
			return;
187
		}
188
		try {
189
			RepositoryTransport.getInstance().getLastModified(statsURI, monitor);
190
		} catch (Exception e) {
191
			LogHelper.log(new Status(IStatus.WARNING, Activator.ID, "Failure reporting download statistics to URL: " + statsURI, e));
192
		}
193
	}
194
166
	private IStatus transferSingle(IArtifactDescriptor destinationDescriptor, IArtifactDescriptor sourceDescriptor, IProgressMonitor monitor) {
195
	private IStatus transferSingle(IArtifactDescriptor destinationDescriptor, IArtifactDescriptor sourceDescriptor, IProgressMonitor monitor) {
167
		OutputStream destination;
196
		OutputStream destination;
168
		try {
197
		try {

Return to bug 302160