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

Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/p2/artifact/processors/md5/MD5ArtifactComparator.java (-3 / +2 lines)
Lines 9-16 Link Here
9
9
10
package org.eclipse.equinox.internal.p2.artifact.processors.md5;
10
package org.eclipse.equinox.internal.p2.artifact.processors.md5;
11
11
12
import org.eclipse.core.runtime.IStatus;
12
import org.eclipse.core.runtime.*;
13
import org.eclipse.core.runtime.Status;
14
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
13
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
15
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
14
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
16
import org.eclipse.osgi.util.NLS;
15
import org.eclipse.osgi.util.NLS;
Lines 35-40 Link Here
35
		if (sourceMD5.equals(destMD5))
34
		if (sourceMD5.equals(destMD5))
36
			return Status.OK_STATUS;
35
			return Status.OK_STATUS;
37
36
38
		return new Status(IStatus.WARNING, Activator.ID, NLS.bind(Messages.warning_differentMD5, new Object[] {source, destination, sourceDescriptor}));
37
		return new Status(IStatus.WARNING, Activator.ID, NLS.bind(Messages.warning_differentMD5, new Object[] {URIUtil.toUnencodedString(sourceDescriptor.getRepository().getLocation()), URIUtil.toUnencodedString(destDescriptor.getRepository().getLocation()), sourceDescriptor}));
39
	}
38
	}
40
}
39
}
(-)src/org/eclipse/equinox/internal/p2/artifact/processors/md5/messages.properties (-3 / +3 lines)
Lines 13-19 Link Here
13
Error_MD5_unavailable=Could not create MD5 algorithm.
13
Error_MD5_unavailable=Could not create MD5 algorithm.
14
Error_unexpected_hash=MD5 hash is not as expected. Expected: {0} and found {1}.
14
Error_unexpected_hash=MD5 hash is not as expected. Expected: {0} and found {1}.
15
15
16
info_noMD5Infomation = No MD5 information available for the artifact {0}.
16
info_noMD5Infomation=No MD5 information available for the artifact [{0}].
17
info_noMD5InRepository = The repository {0} does not contain MD5 information for {1}.
17
info_noMD5InRepository=The repository {0} does not contain MD5 information for [{1}].
18
18
19
warning_differentMD5 = The respositories {0} and {1} have different MD5 sums for {2}.
19
warning_differentMD5=The repositories {0} and {1} have different MD5 sums for [{2}].
(-)src/org/eclipse/equinox/p2/internal/repository/comparator/JarComparator.java (-4 / +11 lines)
Lines 36-42 Link Here
36
	private static final String RSA_EXT = ".rsa"; //$NON-NLS-1$
36
	private static final String RSA_EXT = ".rsa"; //$NON-NLS-1$
37
	private static final String SF_EXT = ".sf"; //$NON-NLS-1$
37
	private static final String SF_EXT = ".sf"; //$NON-NLS-1$
38
38
39
	private String sourceLocation, destinationLocation, descriptorString;
40
39
	public IStatus compare(IArtifactRepository source, IArtifactDescriptor sourceDescriptor, IArtifactRepository destination, IArtifactDescriptor destinationDescriptor) {
41
	public IStatus compare(IArtifactRepository source, IArtifactDescriptor sourceDescriptor, IArtifactRepository destination, IArtifactDescriptor destinationDescriptor) {
42
		// Cache information for potential error messages
43
		sourceLocation = URIUtil.toUnencodedString(sourceDescriptor.getRepository().getLocation());
44
		destinationLocation = URIUtil.toUnencodedString(destination.getLocation());
45
		descriptorString = sourceDescriptor.toString();
46
40
		String classifier = sourceDescriptor.getArtifactKey().getClassifier();
47
		String classifier = sourceDescriptor.getArtifactKey().getClassifier();
41
		if (!OSGI_BUNDLE_CLASSIFIER.equals(classifier)) {
48
		if (!OSGI_BUNDLE_CLASSIFIER.equals(classifier)) {
42
			return Status.OK_STATUS;
49
			return Status.OK_STATUS;
Lines 71-77 Link Here
71
			final int firstFileSize = firstFile.size();
78
			final int firstFileSize = firstFile.size();
72
			final int secondFileSize = secondFile.size();
79
			final int secondFileSize = secondFile.size();
73
			if (firstFileSize != secondFileSize) {
80
			if (firstFileSize != secondFileSize) {
74
				return newErrorStatus(NLS.bind(Messages.differentNumberOfEntries, new String[] {sourceFile.getName(), Integer.toString(firstFileSize), destinationFile.getName(), Integer.toString(secondFileSize)}));
81
				return newErrorStatus(NLS.bind(Messages.differentNumberOfEntries, new String[] {descriptorString, sourceLocation, Integer.toString(firstFileSize), destinationLocation, Integer.toString(secondFileSize)}));
75
			}
82
			}
76
			for (Enumeration enumeration = firstFile.entries(); enumeration.hasMoreElements();) {
83
			for (Enumeration enumeration = firstFile.entries(); enumeration.hasMoreElements();) {
77
				ZipEntry entry = (ZipEntry) enumeration.nextElement();
84
				ZipEntry entry = (ZipEntry) enumeration.nextElement();
Lines 93-99 Link Here
93
							try {
100
							try {
94
								result = compareClasses(firstStream, entry.getSize(), secondStream, entry2.getSize());
101
								result = compareClasses(firstStream, entry.getSize(), secondStream, entry2.getSize());
95
							} catch (ClassFormatException e) {
102
							} catch (ClassFormatException e) {
96
								return newErrorStatus(NLS.bind(Messages.differentEntry, entryName, sourceFile.getAbsolutePath()), e);
103
								return newErrorStatus(NLS.bind(Messages.differentEntry, new String[] {entryName, descriptorString, sourceLocation}), e);
97
							}
104
							}
98
						} else if (lowerCase.endsWith(JAR_EXTENSION)) {
105
						} else if (lowerCase.endsWith(JAR_EXTENSION)) {
99
							result = compareNestedJars(firstStream, entry.getSize(), secondStream, entry2.getSize(), entryName);
106
							result = compareNestedJars(firstStream, entry.getSize(), secondStream, entry2.getSize(), entryName);
Lines 105-118 Link Here
105
							result = compareBytes(firstStream, entry.getSize(), secondStream, entry2.getSize());
112
							result = compareBytes(firstStream, entry.getSize(), secondStream, entry2.getSize());
106
						}
113
						}
107
						if (!result)
114
						if (!result)
108
							return newErrorStatus(NLS.bind(Messages.differentEntry, entryName, sourceFile.getAbsolutePath()));
115
							return newErrorStatus(NLS.bind(Messages.differentEntry, new String[] {entryName, descriptorString, sourceLocation}));
109
					} finally {
116
					} finally {
110
						Utility.close(firstStream);
117
						Utility.close(firstStream);
111
						Utility.close(secondStream);
118
						Utility.close(secondStream);
112
					}
119
					}
113
				} else if (!entry.isDirectory()) {
120
				} else if (!entry.isDirectory()) {
114
					// missing entry, entry2 == null
121
					// missing entry, entry2 == null
115
					return newErrorStatus(NLS.bind(Messages.missingEntry, entryName, sourceFile.getAbsolutePath()));
122
					return newErrorStatus(NLS.bind(Messages.missingEntry, new String[] {entryName, descriptorString, sourceLocation}));
116
				}
123
				}
117
			}
124
			}
118
		} catch (CoreException e) {
125
		} catch (CoreException e) {
(-)src/org/eclipse/equinox/p2/internal/repository/comparator/messages.properties (-3 / +3 lines)
Lines 8-16 Link Here
8
# Contributors:
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
10
###############################################################################
11
differentNumberOfEntries=Difference: {0} contains {1} files and {2} contains {3} files
11
differentNumberOfEntries=Difference in [{0}]: {1} contains {2} files and {3} contains {4} files
12
differentEntry=Difference found for {0} within {1}
12
differentEntry=Difference found for {0} within [{1}] from {2}
13
missingEntry=Missing {0} withim {1}
13
missingEntry=Missing {0} within [{1}] from {2}
14
ioexception=IOException comparing {0} and {1} 
14
ioexception=IOException comparing {0} and {1} 
15
ioexceptioninentry=IOException checking {0} within {1}
15
ioexceptioninentry=IOException checking {0} within {1}
16
filenotfoundexception=FileNotFoundException checking {0} within {1}
16
filenotfoundexception=FileNotFoundException checking {0} within {1}
(-)src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java (-2 / +2 lines)
Lines 1189-1195 Link Here
1189
		IArtifactDescriptor[] destDescriptors = repo2.getArtifactDescriptors(descriptor2.getArtifactKey());
1189
		IArtifactDescriptor[] destDescriptors = repo2.getArtifactDescriptors(descriptor2.getArtifactKey());
1190
		assertEquals("Ensuring destination has correct number of descriptors", 1, destDescriptors.length);
1190
		assertEquals("Ensuring destination has correct number of descriptors", 1, destDescriptors.length);
1191
		assertEquals("Ensuring proper descriptor exists in destination", descriptor2.getProperty(IArtifactDescriptor.DOWNLOAD_MD5), destDescriptors[0].getProperty(IArtifactDescriptor.DOWNLOAD_MD5));
1191
		assertEquals("Ensuring proper descriptor exists in destination", descriptor2.getProperty(IArtifactDescriptor.DOWNLOAD_MD5), destDescriptors[0].getProperty(IArtifactDescriptor.DOWNLOAD_MD5));
1192
		String msg = NLS.bind(Messages.warning_differentMD5, new Object[] {repo1, repo2, descriptor1});
1192
		String msg = NLS.bind(Messages.warning_differentMD5, new Object[] {URIUtil.toUnencodedString(repo1.getLocation()), URIUtil.toUnencodedString(repo2.getLocation()), descriptor1});
1193
		try {
1193
		try {
1194
			assertLogContainsLine(TestActivator.getLogFile(), msg);
1194
			assertLogContainsLine(TestActivator.getLogFile(), msg);
1195
		} catch (Exception e) {
1195
		} catch (Exception e) {
Lines 1266-1272 Link Here
1266
		IArtifactDescriptor[] destDescriptors = destination.getArtifactDescriptors(descriptor2.getArtifactKey());
1266
		IArtifactDescriptor[] destDescriptors = destination.getArtifactDescriptors(descriptor2.getArtifactKey());
1267
		assertEquals("Ensuring destination has correct number of descriptors", 1, destDescriptors.length);
1267
		assertEquals("Ensuring destination has correct number of descriptors", 1, destDescriptors.length);
1268
		assertEquals("Ensuring destination contains the descriptor from the baseline", descriptor2.getProperty(IArtifactDescriptor.DOWNLOAD_MD5), destDescriptors[0].getProperty(IArtifactDescriptor.DOWNLOAD_MD5));
1268
		assertEquals("Ensuring destination contains the descriptor from the baseline", descriptor2.getProperty(IArtifactDescriptor.DOWNLOAD_MD5), destDescriptors[0].getProperty(IArtifactDescriptor.DOWNLOAD_MD5));
1269
		String msg = NLS.bind(Messages.warning_differentMD5, new Object[] {baseline, repo, descriptor1});
1269
		String msg = NLS.bind(Messages.warning_differentMD5, new Object[] {URIUtil.toUnencodedString(baseline.getLocation()), URIUtil.toUnencodedString(repo.getLocation()), descriptor1});
1270
		try {
1270
		try {
1271
			assertLogContainsLine(TestActivator.getLogFile(), msg);
1271
			assertLogContainsLine(TestActivator.getLogFile(), msg);
1272
		} catch (Exception e) {
1272
		} catch (Exception e) {

Return to bug 271792