Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2016-04-27 11:03:48 +0000
committerPascal Rapicault2016-04-27 19:01:59 +0000
commitb97ef3f4f4fc248edcabf714c36ad7980529f399 (patch)
treea531dbf3dd4d5609907bd06ce975691876458a49
parent8e84db691394e6ecf6fd8ddacbdb5bca6df551d3 (diff)
downloadeclipse.platform.runtime-Y20160428-1430.tar.gz
eclipse.platform.runtime-Y20160428-1430.tar.xz
eclipse.platform.runtime-Y20160428-1430.zip
Change-Id: Ib3bcbe28218cb33116e44d30590024c966fa2731 Signed-off-by: Pascal Rapicault <pascal@rapicorp.com>
-rw-r--r--bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
index a5cbb50b2..728f4eb63 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
@@ -84,7 +84,9 @@ public final class InternalPlatform {
public static final String PROP_PRODUCT = "eclipse.product"; //$NON-NLS-1$
public static final String PROP_WS = "osgi.ws"; //$NON-NLS-1$
public static final String PROP_ACTIVATE_PLUGINS = "eclipse.activateRuntimePlugins"; //$NON-NLS-1$
+ public static final String PROP_UUID = "eclipse.uuid"; //$NON-NLS-1$
+ private static final String UUID_PATH = "/.eclipse/eclipse.uuid"; //$NON-NLS-1$
private static final InternalPlatform singleton = new InternalPlatform();
private static final String[] WS_LIST = {Platform.WS_CARBON, Platform.WS_COCOA, Platform.WS_GTK, Platform.WS_MOTIF, Platform.WS_PHOTON, Platform.WS_WIN32, Platform.WS_WPF};
@@ -718,6 +720,54 @@ public final class InternalPlatform {
// activate Jobs plugin by creating a class from it:
org.eclipse.core.runtime.jobs.Job.getJobManager();
}
+ loadMachineUUID();
+ }
+
+ private void loadMachineUUID() {
+ EnvironmentInfo environment = environmentTracker.getService();
+ if (environment != null) {
+ if (environment.getProperty(PROP_UUID) != null)
+ return;
+ }
+ String uuid = loadExistingUUID();
+ if (uuid == null) {
+ uuid = UUID.randomUUID().toString();
+ saveUUID(uuid);
+ }
+ if (environment != null) {
+ environment.setProperty(PROP_UUID, uuid);
+ } else {
+ System.setProperty(PROP_UUID, uuid);
+ }
+ }
+
+ private void saveUUID(String uuid) {
+ File eclipseUUIDFile = new File(System.getProperty("user.home") + UUID_PATH); //$NON-NLS-1$
+ if (!eclipseUUIDFile.getParentFile().exists()) {
+ if (!eclipseUUIDFile.getParentFile().mkdirs())
+ return;
+ }
+ try (OutputStream os = new BufferedOutputStream(new FileOutputStream(eclipseUUIDFile))){
+ Properties prop = new Properties();
+ prop.setProperty(PROP_UUID, uuid);
+ prop.setProperty("version", "1"); //$NON-NLS-1$//$NON-NLS-2$
+ prop.store(os, ""); //$NON-NLS-1$
+ } catch (IOException e) {
+ return;
+ }
+ }
+
+ private String loadExistingUUID() {
+ File eclipseUUIDFile = new File(System.getProperty("user.home") + UUID_PATH); //$NON-NLS-1$
+ if (!eclipseUUIDFile.exists())
+ return null;
+ try(InputStream in = new BufferedInputStream(new FileInputStream(eclipseUUIDFile))) {
+ Properties prop = new Properties();
+ prop.load(in);
+ return (String) prop.get(PROP_UUID);
+ } catch (IOException e) {
+ return null;
+ }
}
/**

Back to the top