Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2009-04-23 19:05:45 +0000
committerPascal Rapicault2009-04-23 19:05:45 +0000
commitb2f91490d6e00d62ee2bbff8bfa8ddccbeb3c221 (patch)
treef0613fab39b7ac2e1205e4b108c7c0a7bf352daa /bundles/org.eclipse.equinox.p2.repository.tools
parent2f6105e62205827b9e7e5cdb9592f2ebd1ef8137 (diff)
downloadrt.equinox.p2-b2f91490d6e00d62ee2bbff8bfa8ddccbeb3c221.tar.gz
rt.equinox.p2-b2f91490d6e00d62ee2bbff8bfa8ddccbeb3c221.tar.xz
rt.equinox.p2-b2f91490d6e00d62ee2bbff8bfa8ddccbeb3c221.zip
Improve error message when jar comparison is failing
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository.tools')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/JarComparator.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/messages.properties6
2 files changed, 14 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/JarComparator.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/JarComparator.java
index 66a373256..5dbb891bc 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/JarComparator.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/JarComparator.java
@@ -36,7 +36,14 @@ public class JarComparator implements IArtifactComparator {
private static final String RSA_EXT = ".rsa"; //$NON-NLS-1$
private static final String SF_EXT = ".sf"; //$NON-NLS-1$
+ private String sourceLocation, destinationLocation, descriptorString;
+
public IStatus compare(IArtifactRepository source, IArtifactDescriptor sourceDescriptor, IArtifactRepository destination, IArtifactDescriptor destinationDescriptor) {
+ // Cache information for potential error messages
+ sourceLocation = URIUtil.toUnencodedString(sourceDescriptor.getRepository().getLocation());
+ destinationLocation = URIUtil.toUnencodedString(destinationDescriptor.getRepository().getLocation());
+ descriptorString = sourceDescriptor.toString();
+
String classifier = sourceDescriptor.getArtifactKey().getClassifier();
if (!OSGI_BUNDLE_CLASSIFIER.equals(classifier)) {
return Status.OK_STATUS;
@@ -71,7 +78,7 @@ public class JarComparator implements IArtifactComparator {
final int firstFileSize = firstFile.size();
final int secondFileSize = secondFile.size();
if (firstFileSize != secondFileSize) {
- return newErrorStatus(NLS.bind(Messages.differentNumberOfEntries, new String[] {sourceFile.getName(), Integer.toString(firstFileSize), destinationFile.getName(), Integer.toString(secondFileSize)}));
+ return newErrorStatus(NLS.bind(Messages.differentNumberOfEntries, new String[] {descriptorString, sourceLocation, Integer.toString(firstFileSize), destinationLocation, Integer.toString(secondFileSize)}));
}
for (Enumeration enumeration = firstFile.entries(); enumeration.hasMoreElements();) {
ZipEntry entry = (ZipEntry) enumeration.nextElement();
@@ -93,7 +100,7 @@ public class JarComparator implements IArtifactComparator {
try {
result = compareClasses(firstStream, entry.getSize(), secondStream, entry2.getSize());
} catch (ClassFormatException e) {
- return newErrorStatus(NLS.bind(Messages.differentEntry, entryName, sourceFile.getAbsolutePath()), e);
+ return newErrorStatus(NLS.bind(Messages.differentEntry, new String[] {entryName, descriptorString, sourceLocation}), e);
}
} else if (lowerCase.endsWith(JAR_EXTENSION)) {
result = compareNestedJars(firstStream, entry.getSize(), secondStream, entry2.getSize(), entryName);
@@ -105,14 +112,14 @@ public class JarComparator implements IArtifactComparator {
result = compareBytes(firstStream, entry.getSize(), secondStream, entry2.getSize());
}
if (!result)
- return newErrorStatus(NLS.bind(Messages.differentEntry, entryName, sourceFile.getAbsolutePath()));
+ return newErrorStatus(NLS.bind(Messages.differentEntry, new String[] {entryName, descriptorString, sourceLocation}));
} finally {
Utility.close(firstStream);
Utility.close(secondStream);
}
} else if (!entry.isDirectory()) {
// missing entry, entry2 == null
- return newErrorStatus(NLS.bind(Messages.missingEntry, entryName, sourceFile.getAbsolutePath()));
+ return newErrorStatus(NLS.bind(Messages.missingEntry, new String[] {entryName, descriptorString, sourceLocation}));
}
}
} catch (CoreException e) {
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/messages.properties b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/messages.properties
index 65fbf5568..a1b0812b2 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/messages.properties
@@ -8,9 +8,9 @@
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
-differentNumberOfEntries=Difference: {0} contains {1} files and {2} contains {3} files
-differentEntry=Difference found for {0} within {1}
-missingEntry=Missing {0} withim {1}
+differentNumberOfEntries=Difference in [{0}]: {1} contains {2} files and {3} contains {4} files
+differentEntry=Difference found for {0} within [{1}] from {2}
+missingEntry=Missing {0} within [{1}] from {2}
ioexception=IOException comparing {0} and {1}
ioexceptioninentry=IOException checking {0} within {1}
filenotfoundexception=FileNotFoundException checking {0} within {1}

Back to the top