/hg/icedtea-web: Fixed loading of deployment.properties during 1...
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Thu Apr 23 10:05:36 UTC 2015
changeset b3c2e66b813a in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=b3c2e66b813a
author: Jiri Vanek <jvanek at redhat.com>
date: Thu Apr 23 12:04:56 2015 +0200
Fixed loading of deployment.properties during 1.4 migration to 1.5 fs.XdgSpecification test adapted to new deployment.manifest.attributes.check schema
diffstat:
ChangeLog | 18 ++
netx/net/sourceforge/jnlp/config/Defaults.java | 2 +-
netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java | 64 ++++---
netx/net/sourceforge/jnlp/config/PathsAndFiles.java | 18 +-
netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java | 3 +-
netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java | 13 +-
netx/net/sourceforge/jnlp/security/appletextendedsecurity/AppletStartupSecuritySettings.java | 8 +-
tests/reproducers/simple/simpletest1/testcases/XDGspecificationTests.java | 87 ++++++---
8 files changed, 137 insertions(+), 76 deletions(-)
diffs (truncated from 580 to 500 lines):
diff -r dd4f7ccae35e -r b3c2e66b813a ChangeLog
--- a/ChangeLog Mon Apr 20 14:13:08 2015 -0400
+++ b/ChangeLog Thu Apr 23 12:04:56 2015 +0200
@@ -1,3 +1,21 @@
+2015-04-20 Jiri Vanek <jvanek at redhat.com>
+
+ Fixed loading of deployment.properties during 1.4 migration to 1.5 fs.
+ * netx/net/sourceforge/jnlp/config/Defaults.java: hardcoded value of ALL fixed
+ * netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java: reused
+ first line of transfer moved to (TRANSFER_TITLE). Added possibility to specify
+ destination of source file. (move14AndOlderFilesTo15Structure) order of moving
+ files reorder, so deployment.properties go first and sensitive files after, setupable
+ files first. Used getDefaultFullPAth insted of getFullPath where suitable (everywhere in this method)
+ * netx/net/sourceforge/jnlp/config/PathsAndFiles.java: encapsualted security string,
+ generalized getAllFiles,a dd getAllSwcurityFiles
+ * netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java: Removed redundant
+ calls to DeplymentConfiguration. Used PathsAndFiles rather.
+ * netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java: same
+ * netx/net/sourceforge/jnlp/security/appletextendedsecurity/AppletStartupSecuritySettings.java:
+ * tests/reproducers/simple/simpletest1/testcases/XDGspecificationTests.java:
+ (fakeExtendedSecurity) adapted to new deployment.manifest.attributes.check schema
+
2015-04-20 Lukasz Dracz <ldracz at redhat.com>
Add Tab Completion for icedtea-web
diff -r dd4f7ccae35e -r b3c2e66b813a netx/net/sourceforge/jnlp/config/Defaults.java
--- a/netx/net/sourceforge/jnlp/config/Defaults.java Mon Apr 20 14:13:08 2015 -0400
+++ b/netx/net/sourceforge/jnlp/config/Defaults.java Thu Apr 23 12:04:56 2015 +0200
@@ -414,7 +414,7 @@
{
DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK,
BasicValueValidators.getManifestAttributeCheckValidator(),
- String.valueOf("ALL")
+ String.valueOf(ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.ALL)
}
};
diff -r dd4f7ccae35e -r b3c2e66b813a netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
--- a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java Mon Apr 20 14:13:08 2015 -0400
+++ b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java Thu Apr 23 12:04:56 2015 +0200
@@ -214,6 +214,10 @@
*/
public static final String KEY_PLUGIN_JVM_ARGUMENTS= "deployment.plugin.jvm.arguments";
public static final String KEY_JRE_DIR= "deployment.jre.dir";
+
+
+ public static final String TRANSFER_TITLE = "Legacy configuration and cache found. Those will be now transported to new locations";
+
private ConfigurationException loadingException = null;
public void setLoadingException(ConfigurationException ex) {
@@ -238,6 +242,8 @@
/** The system's subdirResult deployment.config file */
private File systemPropertiesFile = null;
+ /** Source of always right and only path to file (even if underlying path changes) */
+ private final InfrastructureFileDescriptor userDeploymentFileDescriptor;
/** The user's subdirResult deployment.config file */
private File userPropertiesFile = null;
@@ -248,6 +254,11 @@
private Map<String, Setting<String>> unchangeableConfiguration;
public DeploymentConfiguration() {
+ this(PathsAndFiles.USER_DEPLOYMENT_FILE);
+ }
+
+ public DeploymentConfiguration(InfrastructureFileDescriptor configFile) {
+ userDeploymentFileDescriptor = configFile;
currentConfiguration = new HashMap<>();
unchangeableConfiguration = new HashMap<>();
}
@@ -262,15 +273,6 @@
load(true);
}
- public static File getAppletTrustUserSettingsPath() {
- return PathsAndFiles.APPLET_TRUST_SETTINGS_USER.getFile();
- }
-
- public static File getAppletTrustGlobalSettingsPath() {
- return PathsAndFiles.APPLET_TRUST_SETTINGS_SYS.getFile();
-
- }
-
/**
* Initialize this deployment configuration by reading configuration files.
* Generally, it will try to continue and ignore errors it finds (such as file not found).
@@ -282,12 +284,12 @@
public void load(boolean fixIssues) throws ConfigurationException {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
- sm.checkRead(PathsAndFiles.USER_DEPLOYMENT_FILE.getFullPath());
+ sm.checkRead(userDeploymentFileDescriptor.getFullPath());
}
File systemConfigFile = findSystemConfigFile();
- load(systemConfigFile, PathsAndFiles.USER_DEPLOYMENT_FILE.getFile(), fixIssues);
+ load(systemConfigFile, userDeploymentFileDescriptor.getFile(), fixIssues);
}
void load(File systemConfigFile, File userFile, boolean fixIssues) throws ConfigurationException {
@@ -471,7 +473,7 @@
String jrePath = null;
try {
- Map<String, Setting<String>> tmpProperties = parsePropertiesFile(PathsAndFiles.USER_DEPLOYMENT_FILE.getFile());
+ Map<String, Setting<String>> tmpProperties = parsePropertiesFile(userDeploymentFileDescriptor.getFile());
Setting<String> jreSetting = tmpProperties.get(KEY_JRE_DIR);
if (jreSetting != null) {
jrePath = jreSetting.getValue();
@@ -731,11 +733,12 @@
int errors = 0;
String PRE_15_DEPLOYMENT_DIR = ".icedtea";
String LEGACY_USER_HOME = System.getProperty("user.home") + File.separator + PRE_15_DEPLOYMENT_DIR;
+ String legacyProperties = LEGACY_USER_HOME + File.separator + DEPLOYMENT_PROPERTIES;
File configDir = new File(PathsAndFiles.USER_CONFIG_HOME);
File cacheDir = new File(PathsAndFiles.USER_CACHE_HOME);
File legacyUserDir = new File(LEGACY_USER_HOME);
if (legacyUserDir.exists()) {
- OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Legacy configuration and cache found. Those will be now transported to new locations");
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, TRANSFER_TITLE);
OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, PathsAndFiles.USER_CONFIG_HOME + " and " + PathsAndFiles.USER_CACHE_HOME);
OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "You should not see this message next time you run icedtea-web!");
OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Your custom dirs will not be touched and will work");
@@ -746,18 +749,34 @@
errors += resultToStd(configDir.mkdirs());
OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, " " + PathsAndFiles.USER_CACHE_HOME);
errors += resultToStd(cacheDir.mkdirs());
+ //move this first, the creation of config singleton may happen anytime...
+ //but must not before USER_DEPLOYMENT_FILE is moved and should not in this block
+ String currentProperties = PathsAndFiles.USER_DEPLOYMENT_FILE.getDefaultFullPath();
+ errors += moveLegacyToCurrent(legacyProperties, currentProperties);
+
+ String legacyPropertiesOld = LEGACY_USER_HOME + File.separator + DEPLOYMENT_PROPERTIES + ".old";
+ String currentPropertiesOld = currentProperties + ".old";
+ errors += moveLegacyToCurrent(legacyPropertiesOld, currentPropertiesOld);
String legacySecurity = LEGACY_USER_HOME + File.separator + "security";
- String currentSecurity = PathsAndFiles.USER_SECURITY;
+ String currentSecurity = PathsAndFiles.USER_DEFAULT_SECURITY_DIR;
errors += moveLegacyToCurrent(legacySecurity, currentSecurity);
+
+ String legacyAppletTrust = LEGACY_USER_HOME + File.separator + APPLET_TRUST_SETTINGS;
+ String currentAppletTrust = PathsAndFiles.APPLET_TRUST_SETTINGS_USER.getDefaultFullPath();
+ errors += moveLegacyToCurrent(legacyAppletTrust, currentAppletTrust);
+
+ //note - all here use default path. Any call to getFullPAth will invoke creation of config singleton
+ // but: we DO copy only defaults. There is no need to copy nondefaults!
+ // nond-efault will be used thanks to config singleton read from copied deployment.properties
String legacyCache = LEGACY_USER_HOME + File.separator + "cache";
- String currentCache = PathsAndFiles.CACHE_DIR.getFullPath();
+ String currentCache = PathsAndFiles.CACHE_DIR.getDefaultFullPath();
errors += moveLegacyToCurrent(legacyCache, currentCache);
OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Adapting " + PathsAndFiles.CACHE_INDEX_FILE_NAME + " to new destination");
//replace all legacyCache by currentCache in new recently_used
try {
- File f = PathsAndFiles.getRecentlyUsedFile().getFile();
+ File f = PathsAndFiles.getRecentlyUsedFile().getDefaultFile();
String s = FileUtils.loadFileAsString(f);
s = s.replace(legacyCache, currentCache);
FileUtils.saveFile(s, f);
@@ -774,19 +793,6 @@
String currentLogDir = PathsAndFiles.LOG_DIR.getDefaultFullPath();
errors += moveLegacyToCurrent(legacyLogDir, currentLogDir);
- String legacyProperties = LEGACY_USER_HOME + File.separator + DEPLOYMENT_PROPERTIES;
- String currentProperties = PathsAndFiles.USER_CONFIG_HOME + File.separator + DEPLOYMENT_PROPERTIES;
- errors += moveLegacyToCurrent(legacyProperties, currentProperties);
-
- String legacyPropertiesOld = LEGACY_USER_HOME + File.separator + DEPLOYMENT_PROPERTIES + ".old";
- String currentPropertiesOld = PathsAndFiles.USER_CONFIG_HOME + File.separator + DEPLOYMENT_PROPERTIES + ".old";
- errors += moveLegacyToCurrent(legacyPropertiesOld, currentPropertiesOld);
-
-
- String legacyAppletTrust = LEGACY_USER_HOME + File.separator + APPLET_TRUST_SETTINGS;
- String currentAppletTrust = getAppletTrustUserSettingsPath().getAbsolutePath();
- errors += moveLegacyToCurrent(legacyAppletTrust, currentAppletTrust);
-
String legacyTmp = LEGACY_USER_HOME + File.separator + "tmp";
String currentTmp = PathsAndFiles.TMP_DIR.getDefaultFullPath();
errors += moveLegacyToCurrent(legacyTmp, currentTmp);
diff -r dd4f7ccae35e -r b3c2e66b813a netx/net/sourceforge/jnlp/config/PathsAndFiles.java
--- a/netx/net/sourceforge/jnlp/config/PathsAndFiles.java Mon Apr 20 14:13:08 2015 -0400
+++ b/netx/net/sourceforge/jnlp/config/PathsAndFiles.java Thu Apr 23 12:04:56 2015 +0200
@@ -57,7 +57,7 @@
private static final String RUNTIME_HOME;
public static final String USER_CONFIG_HOME;
public static final String USER_CACHE_HOME;
- public static final String USER_SECURITY;
+ public static final String USER_DEFAULT_SECURITY_DIR;
public static final String XDG_CONFIG_HOME_VAR = "XDG_CONFIG_HOME";
public static final String XDG_CACHE_HOME_VAR = "XDG_CACHE_HOME";
public static final String XDG_RUNTIME_DIR_VAR = "XDG_RUNTIME_DIR";
@@ -67,6 +67,7 @@
private static final String JAVA_PROP = "java.home";
private static final String USER_PROP = "user.name";
private static final String VARIABLE = JNLPRuntime.isWindows() ? "%" : "$";
+ private static final String securityWord = "security";
public static final String ICEDTEA_SO = "IcedTeaPlugin.so";
public static final String CACHE_INDEX_FILE_NAME = "recently_used";
@@ -101,7 +102,7 @@
}
USER_CONFIG_HOME = CONFIG_HOME + File.separator + DEPLOYMENT_SUBDIR_DIR;
USER_CACHE_HOME = CACHE_HOME + File.separator + DEPLOYMENT_SUBDIR_DIR;
- USER_SECURITY = USER_CONFIG_HOME + File.separator + "security";
+ USER_DEFAULT_SECURITY_DIR = USER_CONFIG_HOME + File.separator + securityWord;
}
/**
@@ -297,14 +298,21 @@
public static List<InfrastructureFileDescriptor> getAllFiles() {
return getAllFiles(null);
}
+
+ public static List<InfrastructureFileDescriptor> getAllSecurityFiles() {
+ return getAllFiles(null, UserSecurityConfigFileDescriptor.class);
+ }
private static List<InfrastructureFileDescriptor> getAllFiles(Target desired) {
+ return getAllFiles(desired, InfrastructureFileDescriptor.class);
+ }
+ private static List<InfrastructureFileDescriptor> getAllFiles(Target desired, Class c) {
List<InfrastructureFileDescriptor> r = new ArrayList<>();
Field[] all = PathsAndFiles.class.getDeclaredFields();
for (Field field : all) {
try {
Object o = field.get(null);
- if (o instanceof InfrastructureFileDescriptor) {
+ if (c.isInstance(o)) {
InfrastructureFileDescriptor i = (InfrastructureFileDescriptor) o;
for (Target targe : i.target) {
if (desired == null || targe == desired) {
@@ -396,7 +404,7 @@
private static class SystemJavaSecurityFileDescriptor extends SystemJavaLibFileDescriptor {
private SystemJavaSecurityFileDescriptor(String fileName) {
- super(fileName, "security", "FILEjavacerts", Target.JAVAWS);
+ super(fileName, securityWord, "FILEjavacerts", Target.JAVAWS);
}
}
@@ -479,7 +487,7 @@
private static class UserSecurityConfigFileDescriptor extends ItwConfigFileDescriptor {
private UserSecurityConfigFileDescriptor(String fileName, String description, Target... target) {
- super(fileName, "security", description, target);
+ super(fileName, securityWord, description, target);
}
}
diff -r dd4f7ccae35e -r b3c2e66b813a netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java
--- a/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java Mon Apr 20 14:13:08 2015 -0400
+++ b/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java Thu Apr 23 12:04:56 2015 +0200
@@ -56,7 +56,6 @@
import net.sourceforge.jnlp.config.PathsAndFiles;
import net.sourceforge.jnlp.controlpanel.JVMPanel.JvmValidationResult;
import net.sourceforge.jnlp.runtime.Translator;
-import net.sourceforge.jnlp.security.KeyStores;
import net.sourceforge.jnlp.security.viewer.CertificatePane;
import net.sourceforge.jnlp.util.ImageResources;
import net.sourceforge.jnlp.util.logging.OutputController;
@@ -265,7 +264,7 @@
new SettingsPanel(Translator.R("CPTabSecurity"), createSecuritySettingsPanel()),
//todo refactor to work with tmp file and apply as asu designed it
new SettingsPanel(Translator.R("CPTabPolicy"), createPolicySettingsPanel()),
- new SettingsPanel(Translator.R("APPEXTSECControlPanelExtendedAppletSecurityTitle"), new UnsignedAppletsTrustingListPanel(DeploymentConfiguration.getAppletTrustGlobalSettingsPath(), DeploymentConfiguration.getAppletTrustUserSettingsPath(), this.config))
+ new SettingsPanel(Translator.R("APPEXTSECControlPanelExtendedAppletSecurityTitle"), new UnsignedAppletsTrustingListPanel(PathsAndFiles.APPLET_TRUST_SETTINGS_SYS.getFile(), PathsAndFiles.APPLET_TRUST_SETTINGS_USER.getFile(), this.config))
};
// Add panels.
diff -r dd4f7ccae35e -r b3c2e66b813a netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java
--- a/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java Mon Apr 20 14:13:08 2015 -0400
+++ b/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java Thu Apr 23 12:04:56 2015 +0200
@@ -85,6 +85,7 @@
import javax.swing.table.TableRowSorter;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
+import net.sourceforge.jnlp.config.PathsAndFiles;
import net.sourceforge.jnlp.runtime.Translator;
import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityActions;
import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel;
@@ -244,8 +245,8 @@
if (askBeforeActionCheckBox.isSelected()) {
UnsignedAppletActionEntry[] items = model.back.toArray();
String s = Translator.R("APPEXTSECguiPanelConfirmDeletionOf", items.length) + ": \n";
- for (int i = 0; i < items.length; i++) {
- s += appletItemToCaption(items[i], " ") + "\n";
+ for (UnsignedAppletActionEntry item : items) {
+ s += appletItemToCaption(item, " ") + "\n";
}
int a = JOptionPane.showConfirmDialog(this, s);
if (a != JOptionPane.OK_OPTION) {
@@ -514,8 +515,8 @@
mainTabPanel.add(globalPanel);
mainTabPanel.setTitleAt(0, Translator.R("APPEXTSECguiPanelCustomDefs"));
mainTabPanel.setTitleAt(1, Translator.R("APPEXTSECguiPanelGlobalDefs"));
- mainTabPanel.setToolTipTextAt(0, DeploymentConfiguration.getAppletTrustUserSettingsPath().getAbsolutePath());
- mainTabPanel.setToolTipTextAt(1, DeploymentConfiguration.getAppletTrustGlobalSettingsPath().getAbsolutePath());
+ mainTabPanel.setToolTipTextAt(0, PathsAndFiles.APPLET_TRUST_SETTINGS_USER.getFile().getAbsolutePath());
+ mainTabPanel.setToolTipTextAt(1, PathsAndFiles.APPLET_TRUST_SETTINGS_SYS.getFile().getAbsolutePath());
mainTabPanel.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
@@ -609,8 +610,7 @@
bw.close();
UnsignedAppletActionStorageExtendedImpl copy = new UnsignedAppletActionStorageExtendedImpl(f);
UnsignedAppletActionEntry[] items = copy.toArray();
- for (int i = 0; i < items.length; i++) {
- UnsignedAppletActionEntry unsignedAppletActionEntry = items[i];
+ for (UnsignedAppletActionEntry unsignedAppletActionEntry : items) {
if (unsignedAppletActionEntry.getDocumentBase() != null && !unsignedAppletActionEntry.getDocumentBase().getRegEx().trim().isEmpty()) {
Pattern p = Pattern.compile(unsignedAppletActionEntry.getDocumentBase().getRegEx());
p.matcher("someInput").find();
@@ -624,7 +624,6 @@
throw new RuntimeException(Translator.R("APPEXTSECguiPanelEmptyCode"));
}
UnsignedAppletActionEntry.createArchivesString(UnsignedAppletActionEntry.createArchivesList(UnsignedAppletActionEntry.createArchivesString(unsignedAppletActionEntry.getArchives())));
-
}
JOptionPane.showMessageDialog(this, Translator.R("APPEXTSECguiPanelTableValid"));
} catch (Exception ex) {
diff -r dd4f7ccae35e -r b3c2e66b813a netx/net/sourceforge/jnlp/security/appletextendedsecurity/AppletStartupSecuritySettings.java
--- a/netx/net/sourceforge/jnlp/security/appletextendedsecurity/AppletStartupSecuritySettings.java Mon Apr 20 14:13:08 2015 -0400
+++ b/netx/net/sourceforge/jnlp/security/appletextendedsecurity/AppletStartupSecuritySettings.java Thu Apr 23 12:04:56 2015 +0200
@@ -35,11 +35,9 @@
*/
package net.sourceforge.jnlp.security.appletextendedsecurity;
-import javax.naming.ConfigurationException;
-import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel;
-import net.sourceforge.jnlp.security.appletextendedsecurity.UnsignedAppletActionStorage;
import net.sourceforge.jnlp.security.appletextendedsecurity.impl.UnsignedAppletActionStorageImpl;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
+import net.sourceforge.jnlp.config.PathsAndFiles;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.util.lockingfile.StorageIoException;
@@ -63,7 +61,7 @@
*/
public UnsignedAppletActionStorage getUnsignedAppletActionGlobalStorage() {
if (globalInstance == null) {
- globalInstance = new UnsignedAppletActionStorageImpl(DeploymentConfiguration.getAppletTrustGlobalSettingsPath());
+ globalInstance = new UnsignedAppletActionStorageImpl(PathsAndFiles.APPLET_TRUST_SETTINGS_SYS.getFile());
}
return globalInstance;
}
@@ -74,7 +72,7 @@
*/
public UnsignedAppletActionStorage getUnsignedAppletActionCustomStorage() {
if (customInstance == null) {
- customInstance = new UnsignedAppletActionStorageImpl(DeploymentConfiguration.getAppletTrustUserSettingsPath());
+ customInstance = new UnsignedAppletActionStorageImpl(PathsAndFiles.APPLET_TRUST_SETTINGS_USER.getFile());
}
return customInstance;
}
diff -r dd4f7ccae35e -r b3c2e66b813a tests/reproducers/simple/simpletest1/testcases/XDGspecificationTests.java
--- a/tests/reproducers/simple/simpletest1/testcases/XDGspecificationTests.java Mon Apr 20 14:13:08 2015 -0400
+++ b/tests/reproducers/simple/simpletest1/testcases/XDGspecificationTests.java Thu Apr 23 12:04:56 2015 +0200
@@ -56,6 +56,7 @@
import net.sourceforge.jnlp.browsertesting.Browsers;
import net.sourceforge.jnlp.browsertesting.browsers.firefox.FirefoxProfilesOperator;
import net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener;
+import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.config.PathsAndFiles;
import org.junit.Assert;
import org.junit.After;
@@ -90,7 +91,7 @@
static {
String configHome = System.getProperty("user.home") + File.separator + ".config";
String cacheHome = System.getProperty("user.home") + File.separator + ".cache";
- ;
+
String XDG_CONFIG_HOME_value = System.getenv(PathsAndFiles.XDG_CONFIG_HOME_VAR);
String XDG_CACHE_HOME_value = System.getenv(PathsAndFiles.XDG_CACHE_HOME_VAR);
if (XDG_CONFIG_HOME_value != null) {
@@ -165,7 +166,7 @@
config.mkdirs();
File cache = new File(base, "cache");
cache.mkdirs();
- List<Backup> l = new ArrayList<Backup>();
+ List<Backup> l = new ArrayList<>();
mv(oldRoot, base, l);
mv(realCache, cache, l);
mv(realConfig, config, l);
@@ -206,7 +207,7 @@
private String[] removeXdgVAlues() {
Map<String, String> p = System.getenv();
Set<Entry<String, String>> r = p.entrySet();
- List<Entry<String, String>> rr = new ArrayList<Entry<String, String>>(r);
+ List<Entry<String, String>> rr = new ArrayList<>(r);
Collections.sort(rr, new Comparator<Entry<String, String>>() {
@Override
@@ -214,7 +215,7 @@
return o1.getKey().compareTo(o2.getKey());
}
});
- List<String> l = new ArrayList<String>(p.size());
+ List<String> l = new ArrayList<>(p.size());
int i = 0;
int c = 0;
for (Iterator<Entry<String, String>> it = rr.iterator(); it.hasNext(); i++) {
@@ -244,7 +245,7 @@
boolean config = false;
Map<String, String> p = System.getenv();
Set<Entry<String, String>> r = p.entrySet();
- List<Entry<String, String>> rr = new ArrayList<Entry<String, String>>(r);
+ List<Entry<String, String>> rr = new ArrayList<>(r);
Collections.sort(rr, new Comparator<Entry<String, String>>() {
@Override
@@ -252,22 +253,25 @@
return o1.getKey().compareTo(o2.getKey());
}
});
- List<String> l = new ArrayList<String>(p.size() + 2);
+ List<String> l = new ArrayList<>(p.size() + 2);
int i = 0;
for (Iterator<Entry<String, String>> it = rr.iterator(); it.hasNext(); i++) {
Entry<String, String> entry = it.next();
String v = entry.getValue();
String s = entry.getKey() + "=" + v;
- if (entry.getKey().equals(PathsAndFiles.XDG_CACHE_HOME_VAR)) {
- ServerAccess.logOutputReprint(entry.getKey() + " was " + v);
- v = cacheF.getAbsolutePath();
- ServerAccess.logOutputReprint("set " + v);
- cache = true;
- } else if (entry.getKey().equals(PathsAndFiles.XDG_CONFIG_HOME_VAR)) {
- ServerAccess.logOutputReprint(entry.getKey() + " was " + v);
- v = configF.getAbsolutePath();
- ServerAccess.logOutputReprint("set " + v);
- config = true;
+ switch (entry.getKey()) {
+ case PathsAndFiles.XDG_CACHE_HOME_VAR:
+ ServerAccess.logOutputReprint(entry.getKey() + " was " + v);
+ v = cacheF.getAbsolutePath();
+ ServerAccess.logOutputReprint("set " + v);
+ cache = true;
+ break;
+ case PathsAndFiles.XDG_CONFIG_HOME_VAR:
+ ServerAccess.logOutputReprint(entry.getKey() + " was " + v);
+ v = configF.getAbsolutePath();
+ ServerAccess.logOutputReprint("set " + v);
+ config = true;
+ break;
}
s = entry.getKey() + "=" + v;
l.add(s);
@@ -346,7 +350,6 @@
Assert.assertTrue("creation of old config by renaming " + currentConfigCache + " to " + oldIcedTea + " failed", a);
assertOldConfigFilesInHome(true, true, true);
assertNotConfigFilesInHome(true, true, true);
- ;
} finally {
ServerAccess.PROCESS_TIMEOUT = t;
deleteRecursively(tmp);
@@ -367,27 +370,24 @@
}
private static List<File> getContentOfDirectory(File f) {
- List<File> result = new ArrayList<File>();
+ List<File> result = new ArrayList<>();
if (f == null || !f.exists() || !f.isDirectory()) {
return result;
}
File[] files = f.listFiles();
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
+ for (File file : files) {
if (file.isDirectory()) {
result.addAll(getContentOfDirectory(file));
} else {
result.add(file);
}
-
}
return result;
}
private static String listToString(List<File>... l) {
StringBuilder sb = new StringBuilder();
- for (int i = 0; i < l.length; i++) {
- List<File> list = l[i];
+ for (List<File> list : l) {
for (File s : list) {
sb.append(s.getAbsolutePath()).append('\n');
}
@@ -494,8 +494,8 @@
//runs
private static final RulesFolowingClosingListener.ContainsRule simpletests1Run = new RulesFolowingClosingListener.ContainsRule("Good simple javaws exapmle");
private static final RulesFolowingClosingListener.ContainsRule simpletests2Run = new RulesFolowingClosingListener.ContainsRule("Correct exception");
- private static final RulesFolowingClosingListener.ContainsRule moving = new RulesFolowingClosingListener.ContainsRule("Legacy configuration and cache found. Those will be now transported to new location");
- private static final RulesFolowingClosingListener.NotContainsRule notMoving = new RulesFolowingClosingListener.NotContainsRule("Legacy configuration and cache found. Those will be now transported to new location");
+ private static final RulesFolowingClosingListener.ContainsRule moving = new RulesFolowingClosingListener.ContainsRule(DeploymentConfiguration.TRANSFER_TITLE);
+ private static final RulesFolowingClosingListener.NotContainsRule notMoving = new RulesFolowingClosingListener.NotContainsRule(DeploymentConfiguration.TRANSFER_TITLE);
private static final RulesFolowingClosingListener.ContainsRule unknownProperty = new RulesFolowingClosingListener.ContainsRule("WARNING: Unknown property name");
More information about the distro-pkg-dev
mailing list