Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2009-12-10 17:39:00 +0000
committerPascal Rapicault2009-12-10 17:39:00 +0000
commit52bc357ccd51d0b2e627b41360d8b316459c8f59 (patch)
tree04e0359c8fce523b88a61eb3acd768c0942f9903
parent0bf7cdf41aa5455bc8423a82d636b4ddc045dfe9 (diff)
downloadrt.equinox.p2-52bc357ccd51d0b2e627b41360d8b316459c8f59.tar.gz
rt.equinox.p2-52bc357ccd51d0b2e627b41360d8b316459c8f59.tar.xz
rt.equinox.p2-52bc357ccd51d0b2e627b41360d8b316459c8f59.zip
Change the digest to be UUID
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ILicense.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/MetadataFactory.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/rawData/Test Data Generator.launch5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/SimpleLicenseManager.java14
9 files changed, 28 insertions, 33 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java
index 112956f26..d6449580a 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/License.java
@@ -38,7 +38,7 @@ public class License implements ILicense {
/**
* The <code>digest</code> is the cached message digest of the normalized body
*/
- private BigInteger digest;
+ private String digest;
/**
* Creates a new license object which is identified by users using the <code>body</code> field.
@@ -49,11 +49,12 @@ public class License implements ILicense {
* @param body the license body, cannot be <code>null</code>
* @throws IllegalArgumentException when the <code>body</code> is <code>null</code>
*/
- public License(URI location, String body) {
+ public License(URI location, String body, String uuid) {
if (body == null)
throw new IllegalArgumentException("body cannot be null"); //$NON-NLS-1$
this.body = body;
this.location = location;
+ this.digest = uuid;
}
/**
@@ -78,9 +79,10 @@ public class License implements ILicense {
* version of the license where all whitespace has been reduced to one space.
* @return the message digest as a <code>BigInteger</code>, never <code>null</code>
*/
- public synchronized BigInteger getDigest() {
+ public synchronized String getUUID() {
if (digest == null)
- digest = calculateLicenseDigest();
+ digest = calculateLicenseDigest().toString(16);
+
return digest;
}
@@ -94,7 +96,7 @@ public class License implements ILicense {
return false;
if (obj instanceof ILicense) {
ILicense other = (ILicense) obj;
- if (other.getDigest().equals(getDigest()))
+ if (other.getUUID().equals(getUUID()))
return true;
}
return false;
@@ -104,7 +106,7 @@ public class License implements ILicense {
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
- return getDigest().hashCode();
+ return getUUID().hashCode();
}
private BigInteger calculateLicenseDigest() {
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ILicense.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ILicense.java
index 99916dec8..0f056ab44 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ILicense.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/ILicense.java
@@ -10,7 +10,6 @@
******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata;
-import java.math.BigInteger;
import java.net.URI;
/**
@@ -40,11 +39,9 @@ public interface ILicense {
* Returns the message digest of the license body. The digest is calculated on a normalized
* version of the license where all whitespace has been reduced to one space.
*
- * Any SPI must maintain the same semantics as:
- * <code>{@link org.eclipse.equinox.internal.provisional.p2.metadata.ILicense#getDigest()}</code>
* @return the message digest as a <code>BigInteger</code>, never <code>null</code>
*/
- public BigInteger getDigest();
+ public String getUUID();
/**
* Returns whether this license is equal to the given object.
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/MetadataFactory.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/MetadataFactory.java
index 30a37c368..2b013f5b2 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/MetadataFactory.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/MetadataFactory.java
@@ -12,8 +12,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata;
-import org.eclipse.equinox.p2.metadata.ICopyright;
-
import java.net.URI;
import java.util.*;
import java.util.Map.Entry;
@@ -352,7 +350,7 @@ public class MetadataFactory {
* @throws IllegalArgumentException when the <code>body</code> is <code>null</code>
*/
public static ILicense createLicense(URI location, String body) {
- return new License(location, body);
+ return new License(location, body, null);
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java
index c79520b87..d01619697 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java
@@ -45,7 +45,7 @@ public class InstallWizardTest extends WizardTest {
iu.setProperty(InstallableUnitDescription.PROP_TYPE_GROUP, "true");
iu.setVersion(Version.createOSGi(1, 0, 0));
iu.setSingleton(true);
- iu.setLicenses(new ILicense[] {new License(null, "There is a license to accept!")});
+ iu.setLicenses(new ILicense[] {new License(null, "There is a license to accept!", null)});
iu.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, MAIN_IU, iu.getVersion())});
toInstall = MetadataFactory.createInstallableUnit(iu);
createTestMetdataRepository(new IInstallableUnit[] {toInstall});
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java
index f086a1e30..bf432e8dc 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java
@@ -51,7 +51,7 @@ public class UpdateWizardTest extends WizardTest {
iu.setVersion(Version.createOSGi(4, 0, 0));
iu.setSingleton(true);
iu.setUpdateDescriptor(update);
- iu.setLicenses(new ILicense[] {new License(null, "Update Wizard Test License to Accept")});
+ iu.setLicenses(new ILicense[] {new License(null, "Update Wizard Test License to Accept", null)});
iu.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, MAIN_IU, iu.getVersion())});
mainUpgradeWithLicense = MetadataFactory.createInstallableUnit(iu);
createTestMetdataRepository(new IInstallableUnit[] {main, mainUpgrade1, mainUpgrade2, mainUpgradeWithLicense});
diff --git a/bundles/org.eclipse.equinox.p2.tests/rawData/Test Data Generator.launch b/bundles/org.eclipse.equinox.p2.tests/rawData/Test Data Generator.launch
index ad9a6a439..8db6aec9a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/rawData/Test Data Generator.launch
+++ b/bundles/org.eclipse.equinox.p2.tests/rawData/Test Data Generator.launch
@@ -16,10 +16,9 @@
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="pde.version" value="3.3"/>
<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="target_bundles" value="org.eclipse.core.contenttype@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.runtime@default:default,org.eclipse.core.runtime.compatibility.registry@default:default,org.eclipse.equinox.app@default:true,org.eclipse.equinox.common@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.launcher.win32.win32.x86@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.osgi@:,org.eclipse.osgi.services@default:default,org.eclipse.update.configurator@default:default"/>
+<stringAttribute key="target_bundles" value="org.eclipse.core.runtime@default:true,org.eclipse.core.contenttype@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.core.jobs@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.osgi,org.eclipse.equinox.common@2:true,org.eclipse.osgi.services@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.equinox.app@default:true,org.eclipse.update.configurator@3:true"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useDefaultConfigArea" value="true"/>
<booleanAttribute key="useNamedJRE" value="false"/>
-<stringAttribute key="vminstall" value="ibm1.5sr1"/>
-<stringAttribute key="workspace_bundles" value="org.eclipse.ecf@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:true,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.download@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.equinox.p2.metadata.repository@default:default"/>
+<stringAttribute key="workspace_bundles" value="org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:true"/>
</launchConfiguration>
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java
index c51d3097c..7b26944e4 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java
@@ -22,10 +22,10 @@ public class LicenseTest extends TestCase {
public void testNormalize() {
ILicense licenseOne = MetadataFactory.createLicense(null, "a b");
ILicense licenseTwo = MetadataFactory.createLicense(null, "a\t\n\r \t\n\r b");
- assertEquals("1.0", licenseOne.getDigest(), licenseTwo.getDigest());
+ assertEquals("1.0", licenseOne.getUUID(), licenseTwo.getUUID());
licenseOne = MetadataFactory.createLicense(null, " a b c ");
licenseTwo = MetadataFactory.createLicense(null, "a\t\nb\r \t\n\r c");
- assertEquals("1.1", licenseOne.getDigest(), licenseTwo.getDigest());
+ assertEquals("1.1", licenseOne.getUUID(), licenseTwo.getUUID());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
index e868210ea..b3106436b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
@@ -9,8 +9,6 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata.repository;
-import org.eclipse.equinox.p2.metadata.ICopyright;
-
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
@@ -546,6 +544,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
private String body;
private URI location;
+ private String uuid;
public SPILicense(String body, URI location) {
this.body = body;
@@ -556,8 +555,10 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
return this.body;
}
- public BigInteger getDigest() {
- return this.calculateLicenseDigest();
+ public String getUUID() {
+ if (uuid == null)
+ uuid = this.calculateLicenseDigest().toString(16);
+ return uuid;
}
public URI getLocation() {
@@ -571,7 +572,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
return false;
if (obj instanceof ILicense) {
ILicense other = (ILicense) obj;
- if (other.getDigest().equals(getDigest()))
+ if (other.getUUID().equals(getUUID()))
return true;
}
return false;
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/SimpleLicenseManager.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/SimpleLicenseManager.java
index 0b7e2538f..e492a237e 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/SimpleLicenseManager.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/SimpleLicenseManager.java
@@ -12,7 +12,6 @@
package org.eclipse.equinox.internal.p2.ui.sdk;
import java.io.*;
-import java.math.BigInteger;
import java.util.*;
import javax.xml.parsers.*;
import org.eclipse.core.runtime.IStatus;
@@ -34,17 +33,17 @@ public class SimpleLicenseManager extends LicenseManager {
java.util.Set accepted = new HashSet();
public boolean accept(ILicense license) {
- accepted.add(license.getDigest());
+ accepted.add(license.getUUID());
return true;
}
public boolean reject(ILicense license) {
- accepted.remove(license.getDigest());
+ accepted.remove(license.getUUID());
return true;
}
public boolean isAccepted(ILicense license) {
- return accepted.contains(license.getDigest());
+ return accepted.contains(license.getUUID());
}
public boolean hasAcceptedLicenses() {
@@ -83,8 +82,8 @@ public class SimpleLicenseManager extends LicenseManager {
writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$
writer.println("<licenses>"); //$NON-NLS-1$
for (Iterator i = accepted.iterator(); i.hasNext();) {
- BigInteger digest = (BigInteger) i.next();
- writer.print(" " + "<license digest=\"" + digest.toString(16) + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ String digest = (String) i.next();
+ writer.print(" " + "<license digest=\"" + digest + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
} finally {
writer.println("</licenses>"); //$NON-NLS-1$
@@ -110,8 +109,7 @@ public class SimpleLicenseManager extends LicenseManager {
NamedNodeMap atts = child.getAttributes();
Node digestAtt = atts.getNamedItem("digest"); //$NON-NLS-1$
if (digestAtt != null) {
- BigInteger digest = new BigInteger(digestAtt.getNodeValue(), 16);
- licenses.add(digest);
+ licenses.add(digestAtt.getNodeValue());
}
}
}

Back to the top