summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault (Ericsson)2012-12-10 16:06:38 (EST)
committerPascal Rapicault2012-12-18 10:04:14 (EST)
commit1d0f129ca70716e7a181631e1ba0e71f16e35e08 (patch)
tree67b8e8bc166341025f9dba45a529f66f569e5999
parent3134caecfd244fd88386f3ce4bd1a6fc71fe8007 (diff)
downloadrt.equinox.p2-1d0f129ca70716e7a181631e1ba0e71f16e35e08.zip
rt.equinox.p2-1d0f129ca70716e7a181631e1ba0e71f16e35e08.tar.gz
rt.equinox.p2-1d0f129ca70716e7a181631e1ba0e71f16e35e08.tar.bz2
Remember the timestamp of the base config.ini
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java65
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Messages.java2
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/messages.properties2
3 files changed, 50 insertions, 19 deletions
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java
index 7f19233..22d2e86 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java
@@ -30,6 +30,9 @@ public class EquinoxFwConfigFileParser {
private static final String KEY_ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_CONFIGURL = "org.eclipse.equinox.simpleconfigurator.configUrl"; //$NON-NLS-1$
private static final String REFERENCE_SCHEME = "reference:"; //$NON-NLS-1$
private static final String FILE_PROTOCOL = "file:"; //$NON-NLS-1$
+ private static final String BASE_TIMESTAMPS_FILE = ".baseTimestamps"; //$NON-NLS-1$
+ private static final String KEY_CONFIG_TIMESTAMP = "configIniTimestamp"; //$NON-NLS-1$
+
private static boolean DEBUG = false;
public EquinoxFwConfigFileParser(BundleContext context) {
@@ -208,7 +211,7 @@ public class EquinoxFwConfigFileParser {
Properties props = loadProperties(inputFile);
// load shared configuration properties
- Properties sharedConfigProperties = getSharedConfiguration(props.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA), ParserUtils.getOSGiInstallArea(Arrays.asList(manipulator.getLauncherData().getProgramArgs()), props, manipulator.getLauncherData()));
+ Properties sharedConfigProperties = getSharedConfiguration(ParserUtils.getOSGiInstallArea(Arrays.asList(manipulator.getLauncherData().getProgramArgs()), props, manipulator.getLauncherData()), props.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA));
if (sharedConfigProperties != null) {
sharedConfigProperties.putAll(props);
props = sharedConfigProperties;
@@ -293,7 +296,8 @@ public class EquinoxFwConfigFileParser {
props.load(is);
} finally {
try {
- is.close();
+ if (is != null)
+ is.close();
} catch (IOException e) {
Log.log(LogService.LOG_WARNING, NLS.bind(Messages.log_failed_reading_properties, inputFile));
}
@@ -302,7 +306,18 @@ public class EquinoxFwConfigFileParser {
return props;
}
- private File findSharedConfigIniFile(URL rootURL, String sharedConfigurationArea) {
+ private File findSharedConfigIniFile(File base, String sharedConfigurationArea) {
+ if (base == null)
+ return null;
+ URL rootURL;
+ try {
+ rootURL = base.toURL();
+ } catch (MalformedURLException e1) {
+ return null;
+ }
+ if (rootURL == null)
+ return null;
+
URL sharedConfigurationURL = null;
try {
sharedConfigurationURL = new URL(sharedConfigurationArea);
@@ -415,7 +430,6 @@ public class EquinoxFwConfigFileParser {
outputFile = new File(outputFile, EquinoxConstants.CONFIG_INI);
}
}
- String header = "This configuration file was written by: " + this.getClass().getName(); //$NON-NLS-1$
Properties configProps = new Properties();
//URI rootURI = launcherData.getLauncher() != null ? launcherData.getLauncher().getParentFile().toURI() : null;
@@ -459,13 +473,18 @@ public class EquinoxFwConfigFileParser {
Log.log(LogService.LOG_INFO, this, "saveFwConfig()", NLS.bind(Messages.log_renameSuccessful, outputFile, dest)); //$NON-NLS-1$
}
+ filterPropertiesFromSharedArea(configProps, manipulator);
+ saveProperties(outputFile, configProps);
+ rememberSharedConfigurationTimestamp(configProps, manipulator, outputFile.getParentFile());
+ }
+
+ private void saveProperties(File outputFile, Properties configProps) throws IOException {
+ String header = "This configuration file was written by: " + this.getClass().getName(); //$NON-NLS-1$
FileOutputStream out = null;
try {
out = new FileOutputStream(outputFile);
- // configProps = makeRelative(configProps, launcherData.getLauncher().getParentFile().toURI(), fwJar, outputFile.getParentFile(), getOSGiInstallArea(manipulator.getLauncherData()));
- filterPropertiesFromSharedArea(configProps, manipulator);
configProps.store(out, header);
- Log.log(LogService.LOG_INFO, NLS.bind(Messages.log_fwConfigSave, outputFile));
+ Log.log(LogService.LOG_INFO, NLS.bind(Messages.log_propertiesSaved, outputFile));
} finally {
try {
out.flush();
@@ -473,14 +492,13 @@ public class EquinoxFwConfigFileParser {
} catch (IOException e) {
e.printStackTrace();
}
- out = null;
}
}
private void filterPropertiesFromSharedArea(Properties configProps, Manipulator manipulator) {
LauncherData launcherData = manipulator.getLauncherData();
//Remove from the config file that we are about to write the properties that are unchanged compared to what is in the base
- Properties sharedConfigProperties = getSharedConfiguration(configProps.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA), ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), configProps, launcherData));
+ Properties sharedConfigProperties = getSharedConfiguration(ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), configProps, launcherData), configProps.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA));
if (sharedConfigProperties == null)
return;
Enumeration keys = configProps.propertyNames();
@@ -549,16 +567,28 @@ public class EquinoxFwConfigFileParser {
}
}
- private Properties getSharedConfiguration(String sharedConfigurationArea, File baseFile) {
- if (sharedConfigurationArea == null)
- return null;
- File sharedConfigIni;
+ private void rememberSharedConfigurationTimestamp(Properties configProps, Manipulator manipulator, File folder) throws IOException {
+ LauncherData launcherData = manipulator.getLauncherData();
+ //Remove from the config file that we are about to write the properties that are unchanged compared to what is in the base
+ File sharedConfigIni = findSharedConfigIniFile(ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), configProps, launcherData), configProps.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA));
+ if (sharedConfigIni == null)
+ return;
+ File timestampFile = new File(folder, BASE_TIMESTAMPS_FILE);
+ Properties timestamps;
try {
- sharedConfigIni = findSharedConfigIniFile(baseFile.toURL(), sharedConfigurationArea);
- } catch (MalformedURLException e) {
- return null;
+ timestamps = loadProperties(timestampFile);
+ } catch (IOException e) {
+ timestamps = new Properties();
}
- if (sharedConfigIni != null && sharedConfigIni.exists())
+ timestamps.setProperty(KEY_CONFIG_TIMESTAMP, String.valueOf(sharedConfigIni.lastModified()));
+ saveProperties(timestampFile, timestamps);
+ }
+
+ private Properties getSharedConfiguration(File baseFile, String sharedConfigurationArea) {
+ if (sharedConfigurationArea == null)
+ return null;
+ File sharedConfigIni = findSharedConfigIniFile(baseFile, sharedConfigurationArea);
+ if (sharedConfigIni != null && sharedConfigIni.exists()) {
try {
return loadProperties(sharedConfigIni);
} catch (FileNotFoundException e) {
@@ -566,6 +596,7 @@ public class EquinoxFwConfigFileParser {
} catch (IOException e) {
return null;
}
+ }
return null;
}
}
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Messages.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Messages.java
index 2453f7b..66920c2 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Messages.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Messages.java
@@ -31,7 +31,7 @@ public class Messages extends NLS {
public static String log_configFile;
public static String log_configProps;
public static String log_renameSuccessful;
- public static String log_fwConfigSave;
+ public static String log_propertiesSaved;
public static String log_launcherConfigSave;
public static String log_shared_config_url;
public static String log_shared_config_relative_url;
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/messages.properties b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/messages.properties
index a5d0d50..3c84f4d 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/messages.properties
+++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/messages.properties
@@ -26,7 +26,7 @@ exception_errorReadingFile = An error occured while reading {0}.
log_configFile= Configuration file ({0}) has been read successfully.
log_configProps= Configuration properties is empty.
log_renameSuccessful= Successfully renamed {0} to {1}.
-log_fwConfigSave= Framework Configuration was saved successfully in {0}.
+log_propertiesSaved= File {0} was saved successfully.
log_launcherConfigSave= Launcher Configuration was saved successfully in {0}.
log_shared_config_url=Failed creating shared configuration url for {0}.
log_shared_config_relative_url=Failed creating shared configuration url for root: {0} and sharedConfiguration: {1}.