View | Details | Raw Unified | Return to bug 249996 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/AggregatedBundleRepository.java (+4 lines)
Lines 93-98 Link Here
93
		throw new UnsupportedOperationException(Messages.artifact_retrieval_unsupported);
93
		throw new UnsupportedOperationException(Messages.artifact_retrieval_unsupported);
94
	}
94
	}
95
95
96
	public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
97
		throw new UnsupportedOperationException(Messages.artifact_retrieval_unsupported);
98
	}
99
96
	public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
100
	public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
97
		throw new UnsupportedOperationException(Messages.artifact_retrieval_unsupported);
101
		throw new UnsupportedOperationException(Messages.artifact_retrieval_unsupported);
98
	}
102
	}
(-)src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationArtifactRepository.java (+5 lines)
Lines 169-174 Link Here
169
		return artifactRepository.getArtifact(descriptor, destination, monitor);
169
		return artifactRepository.getArtifact(descriptor, destination, monitor);
170
	}
170
	}
171
171
172
	public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
173
		ensureInitialized();
174
		return artifactRepository.getRawArtifact(descriptor, destination, monitor);
175
	}
176
172
	public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
177
	public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
173
		ensureInitialized();
178
		ensureInitialized();
174
		return artifactRepository.getArtifactDescriptors(key);
179
		return artifactRepository.getArtifactDescriptors(key);
(-)src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java (+4 lines)
Lines 157-162 Link Here
157
		return Status.OK_STATUS;
157
		return Status.OK_STATUS;
158
	}
158
	}
159
159
160
	public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
161
		return getArtifact(descriptor, destination, monitor);
162
	}
163
160
	public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
164
	public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
161
		Set/*<IArtifactDescriptor>*/result = new HashSet/*<IArtifactDescriptor>*/();
165
		Set/*<IArtifactDescriptor>*/result = new HashSet/*<IArtifactDescriptor>*/();
162
		for (Iterator/*<IArtifactDescriptor>*/iterator = repo.keySet().iterator(); iterator.hasNext();) {
166
		for (Iterator/*<IArtifactDescriptor>*/iterator = repo.keySet().iterator(); iterator.hasNext();) {
(-)src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java (+5 lines)
Lines 128-133 Link Here
128
		return Status.OK_STATUS;
128
		return Status.OK_STATUS;
129
	}
129
	}
130
130
131
	public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
132
		testhandler.download((String) keysToLocations.get(descriptor.getArtifactKey()), destination, monitor);
133
		return Status.OK_STATUS;
134
	}
135
131
	public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
136
	public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
132
		if (!contains(key))
137
		if (!contains(key))
133
			return null;
138
			return null;
(-)src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java (-4 / +58 lines)
Lines 13-26 Link Here
13
import java.io.File;
13
import java.io.File;
14
import java.net.MalformedURLException;
14
import java.net.MalformedURLException;
15
import java.net.URL;
15
import java.net.URL;
16
import java.util.HashMap;
16
import java.util.*;
17
import java.util.Map;
18
import org.eclipse.equinox.app.IApplicationContext;
17
import org.eclipse.equinox.app.IApplicationContext;
19
import org.eclipse.equinox.internal.p2.artifact.mirror.MirrorApplication;
18
import org.eclipse.equinox.internal.p2.artifact.mirror.MirrorApplication;
19
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository;
20
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
20
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
21
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
21
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
22
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
23
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
22
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
23
import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
24
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
24
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
25
import org.eclipse.equinox.p2.tests.TestActivator;
25
import org.eclipse.equinox.p2.tests.TestActivator;
26
import org.osgi.framework.Bundle;
26
import org.osgi.framework.Bundle;
Lines 308-313 Link Here
308
	}
308
	}
309
309
310
	/**
310
	/**
311
	 * ensures that all files with entries in the repo have corresponding files on disk.
312
	 */
313
	private void assertFileSizes(String message, SimpleArtifactRepository expected, SimpleArtifactRepository actual) {
314
		IArtifactKey[] expectedKeys = expected.getArtifactKeys();
315
		for (int i = 0; i < expectedKeys.length; i++) {
316
			IArtifactDescriptor[] expectedDescriptors = expected.getArtifactDescriptors(expectedKeys[i]);
317
			IArtifactDescriptor[] actualDescriptors = actual.getArtifactDescriptors(expectedKeys[i]);
318
319
			top: for (int j = 0; j < expectedDescriptors.length; j++) {
320
				for (int j2 = 0; j2 < actualDescriptors.length; j2++) {
321
					if (Arrays.equals(expectedDescriptors[j].getProcessingSteps(), actualDescriptors[j2].getProcessingSteps())) {
322
						File expectedFile = expected.getArtifactFile(expectedDescriptors[j]);
323
						File actualFile = actual.getArtifactFile(actualDescriptors[j2]);
324
						if (expectedFile == null || actualFile == null)
325
							fail(message + " descriptor mismatch");
326
						if (!(expectedFile.exists() && actualFile.exists()))
327
							fail(message + " file does not exist");
328
						assertTrue(expectedFile.length() == actualFile.length());
329
						continue top;
330
					}
331
				}
332
				fail(message + "Missing expected descriptor" + expectedDescriptors[j]);
333
			}
334
		}
335
	}
336
337
	/**
311
	 * Tests mirroring all artifacts in a repository to an empty repository with "-append"
338
	 * Tests mirroring all artifacts in a repository to an empty repository with "-append"
312
	 * Source contains A, B
339
	 * Source contains A, B
313
	 * Target contains
340
	 * Target contains
Lines 855-858 Link Here
855
			fail("25.6", e);
882
			fail("25.6", e);
856
		}
883
		}
857
	}
884
	}
885
886
	/**
887
	 * Verifies that the mirror application copies files (including packed files) correctly
888
	 */
889
	public void testArtifactFileCopying() {
890
		//Setup: load the repository containing packed data
891
		File packedRepoLocation = getTestData("26.0", "/testData/mirror/mirrorPackedRepo");
892
893
		try {
894
			basicRunMirrorApplication("26.1", packedRepoLocation.toURL(), destRepoLocation.toURL(), false);
895
		} catch (MalformedURLException e) {
896
			fail("26.2", e);
897
		} catch (Exception e) {
898
			fail("26.3", e);
899
		}
900
901
		try {
902
			//Verify Contents
903
			assertContentEquals("26.4", getManager().loadRepository(packedRepoLocation.toURL(), null), getManager().loadRepository(destRepoLocation.toURL(), null));
904
			//Verify files on disk
905
			assertFileSizes("26.5", (SimpleArtifactRepository) getManager().loadRepository(packedRepoLocation.toURL(), null), (SimpleArtifactRepository) getManager().loadRepository(destRepoLocation.toURL(), null));
906
		} catch (ProvisionException e) {
907
			fail("26.6", e);
908
		} catch (MalformedURLException e) {
909
			fail("26.7", e);
910
		}
911
	}
858
}
912
}
(-)src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository.java (+4 lines)
Lines 126-131 Link Here
126
		return innerRepo.getArtifact(descriptor, destination, monitor);
126
		return innerRepo.getArtifact(descriptor, destination, monitor);
127
	}
127
	}
128
128
129
	public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
130
		return innerRepo.getRawArtifact(descriptor, destination, monitor);
131
	}
132
129
	public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
133
	public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
130
		return Status.OK_STATUS;
134
		return Status.OK_STATUS;
131
	}
135
	}
(-)src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/IArtifactRepository.java (+5 lines)
Lines 69-74 Link Here
69
	public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor);
69
	public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor);
70
70
71
	/**
71
	/**
72
	 * Write to the given output stream the bytes represented by the artifact descriptor without processing by the steps of the given descriptor. 
73
	 */
74
	public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor);
75
76
	/**
72
	 * Return the set of artifact descriptors describing the ways that this repository
77
	 * Return the set of artifact descriptors describing the ways that this repository
73
	 * can supply the artifact associated with the given artifact key
78
	 * can supply the artifact associated with the given artifact key
74
	 * @param key the artifact key to lookup
79
	 * @param key the artifact key to lookup
(-)src/org/eclipse/equinox/internal/p2/artifact/mirror/Mirroring.java (-1 / +1 lines)
Lines 54-60 Link Here
54
				if (repositoryStream == null)
54
				if (repositoryStream == null)
55
					return;
55
					return;
56
				// TODO Is that ok to ignore the result?
56
				// TODO Is that ok to ignore the result?
57
				source.getArtifact(descriptor, repositoryStream, new NullProgressMonitor());
57
				source.getRawArtifact(descriptor, repositoryStream, new NullProgressMonitor());
58
			} finally {
58
			} finally {
59
				if (repositoryStream != null)
59
				if (repositoryStream != null)
60
					repositoryStream.close();
60
					repositoryStream.close();
(-)src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java (+4 lines)
Lines 515-520 Link Here
515
		return downloadArtifact(descriptor, destination, monitor);
515
		return downloadArtifact(descriptor, destination, monitor);
516
	}
516
	}
517
517
518
	public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
519
		return downloadArtifact(descriptor, destination, monitor);
520
	}
521
518
	public synchronized IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
522
	public synchronized IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
519
		Collection result = (Collection) artifactMap.get(key);
523
		Collection result = (Collection) artifactMap.get(key);
520
		if (result == null)
524
		if (result == null)

Return to bug 249996