/hg/icedtea-web: InfrastructureFileDescriptor got setter
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Thu Apr 2 19:28:22 UTC 2015
changeset 85505d8c9f3c in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=85505d8c9f3c
author: Jiri Vanek <jvanek at redhat.com>
date: Thu Apr 02 21:28:10 2015 +0200
InfrastructureFileDescriptor got setter
diffstat:
ChangeLog | 21 ++
netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java | 2 +-
netx/net/sourceforge/jnlp/config/PathsAndFiles.java | 102 +++++----
netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java | 2 +-
netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java | 2 +-
netx/net/sourceforge/jnlp/util/docprovider/ItwebPluginTextProvider.java | 10 +-
tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java | 4 +-
tests/netx/unit/net/sourceforge/jnlp/cache/ResourceDownloaderTest.java | 4 +-
tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java | 4 +-
9 files changed, 93 insertions(+), 58 deletions(-)
diffs (395 lines):
diff -r 1dc3e6bdf364 -r 85505d8c9f3c ChangeLog
--- a/ChangeLog Thu Apr 02 20:48:51 2015 +0200
+++ b/ChangeLog Thu Apr 02 21:28:10 2015 +0200
@@ -1,3 +1,24 @@
+2015-04-02 Jiri Vanek <jvanek at redhat.com>
+
+ InfrastructureFileDescriptor got setter
+ *netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java: minor formating
+ *netx/net/sourceforge/jnlp/config/PathsAndFiles.java: all getFullPath replaced by
+ getPropertiesKey, and instead of config, value, returns key. Added setValue,
+ solution. Adapted getFullPath. (gcpd) removed. (getDir) removed - is now
+ confusing.
+ *netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java: setter into
+ property KEY_USER_LOG_DIR replaced by setter into LOG_DIR.
+ *netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java:
+ same for KEY_USER_CACHE_DIR -> CACHE_DIR
+ *netx/net/sourceforge/jnlp/util/docprovider/ItwebPluginTextProvider.java:
+ All browser directories adapted to missing getDir.
+ *tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java:
+ KEY_USER_CACHE_DIR -> CACHE_DIR
+ *tests/netx/unit/net/sourceforge/jnlp/cache/ResourceDownloaderTest.java:
+ KEY_USER_CACHE_DIR -> CACHE_DIR
+ *tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java:
+ KEY_USER_CACHE_DIR -> CACHE_DIR
+
2015-04-02 Jiri Vanek <jvanek at redhat.com>
All reading from file properties repalced by getter from PathsAndFiles
diff -r 1dc3e6bdf364 -r 85505d8c9f3c netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java
--- a/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java Thu Apr 02 20:48:51 2015 +0200
+++ b/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java Thu Apr 02 21:28:10 2015 +0200
@@ -71,7 +71,7 @@
private final File cacheDir;
public CacheLRUWrapper() {
- this(PathsAndFiles.getRecentlyUsedFile().getFile(), PathsAndFiles.CACHE_DIR.getFile());
+ this(PathsAndFiles.getRecentlyUsedFile().getFile(), PathsAndFiles.CACHE_DIR.getFile());
}
diff -r 1dc3e6bdf364 -r 85505d8c9f3c netx/net/sourceforge/jnlp/config/PathsAndFiles.java
--- a/netx/net/sourceforge/jnlp/config/PathsAndFiles.java Thu Apr 02 20:48:51 2015 +0200
+++ b/netx/net/sourceforge/jnlp/config/PathsAndFiles.java Thu Apr 02 21:28:10 2015 +0200
@@ -118,8 +118,8 @@
public static final InfrastructureFileDescriptor CACHE_DIR = new ItwCacheFileDescriptor("cache", "FILEcache", Target.JAVAWS, Target.ITWEB_SETTINGS) {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_CACHE_DIR);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_CACHE_DIR;
}
};
@@ -144,15 +144,15 @@
public static final InfrastructureFileDescriptor PCACHE_DIR = new ItwCacheFileDescriptor("pcache", "FILEappdata", Target.JAVAWS, Target.ITWEB_SETTINGS){
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_PERSISTENCE_CACHE_DIR);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_PERSISTENCE_CACHE_DIR;
}
};
public static final InfrastructureFileDescriptor LOG_DIR = new ItwConfigFileDescriptor("log", "FILElogs", Target.JAVAWS, Target.ITWEB_SETTINGS){
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_LOG_DIR);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_LOG_DIR;
}
@@ -168,32 +168,32 @@
public static final InfrastructureFileDescriptor TMP_DIR = new ItwCacheFileDescriptor("tmp", "FILEtmpappdata", Target.JAVAWS, Target.ITWEB_SETTINGS){
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_TMP_DIR);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_TMP_DIR;
}
};
public static final InfrastructureFileDescriptor LOCKS_DIR = new TmpUsrFileDescriptor("locks", "netx", "FILElocksdir", Target.JAVAWS) {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_LOCKS_DIR);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_LOCKS_DIR;
}
};
public static final InfrastructureFileDescriptor MAIN_LOCK = new TmpUsrFileDescriptor("netx_running", "netx" + File.separator + "locks", "FILEmainlock", Target.JAVAWS) {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_NETX_RUNNING_FILE);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_NETX_RUNNING_FILE;
}
};
public static final InfrastructureFileDescriptor JAVA_POLICY = new UserSecurityConfigFileDescriptor("java.policy", "FILEpolicy", Target.JAVAWS, Target.POLICY_EDITOR){
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_SECURITY_POLICY);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_SECURITY_POLICY;
}
@Override
@@ -209,74 +209,74 @@
};
public static final InfrastructureFileDescriptor USER_CACERTS = new UserCacertsFileDescriptor("trusted.cacerts") {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_TRUSTED_CA_CERTS);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_TRUSTED_CA_CERTS;
}
};
public static final InfrastructureFileDescriptor USER_JSSECAC = new UserCacertsFileDescriptor("trusted.jssecacerts") {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_TRUSTED_JSSE_CA_CERTS);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_TRUSTED_JSSE_CA_CERTS;
}
};
public static final InfrastructureFileDescriptor USER_CERTS = new UserCacertsFileDescriptor("trusted.certs") {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_TRUSTED_CERTS);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_TRUSTED_CERTS;
}
};
public static final InfrastructureFileDescriptor USER_JSSECER = new UserCacertsFileDescriptor("trusted.jssecerts") {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_TRUSTED_JSSE_CERTS);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_TRUSTED_JSSE_CERTS;
}
};
public static final InfrastructureFileDescriptor USER_CLIENTCERT = new UserCacertsFileDescriptor("trusted.clientcerts") {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_USER_TRUSTED_CLIENT_CERTS);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_USER_TRUSTED_CLIENT_CERTS;
}
};
public static final InfrastructureFileDescriptor SYS_CACERT = new SystemJavaSecurityFileDescriptor("cacerts") {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_SYSTEM_TRUSTED_CA_CERTS);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_SYSTEM_TRUSTED_CA_CERTS;
}
};
public static final InfrastructureFileDescriptor SYS_JSSECAC = new SystemJavaSecurityFileDescriptor("jssecacerts") {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_SYSTEM_TRUSTED_JSSE_CA_CERTS);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_SYSTEM_TRUSTED_JSSE_CA_CERTS;
}
};
public static final InfrastructureFileDescriptor SYS_CERT = new SystemJavaSecurityFileDescriptor("trusted.certs"){
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_SYSTEM_TRUSTED_CERTS);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_SYSTEM_TRUSTED_CERTS;
}
};
public static final InfrastructureFileDescriptor SYS_JSSECERT = new SystemJavaSecurityFileDescriptor("trusted.jssecerts") {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_SYSTEM_TRUSTED_JSSE_CERTS);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_SYSTEM_TRUSTED_JSSE_CERTS;
}
};
public static final InfrastructureFileDescriptor SYS_CLIENTCERT = new SystemJavaSecurityFileDescriptor("trusted.clientcerts") {
@Override
- public String getFullPath() {
- return gcpd(DeploymentConfiguration.KEY_SYSTEM_TRUSTED_CLIENT_CERTS);
+ public String getPropertiesKey() {
+ return DeploymentConfiguration.KEY_SYSTEM_TRUSTED_CLIENT_CERTS;
}
};
@@ -353,20 +353,38 @@
this.descriptionKey = descriptionKey;
this.target = target;
}
+
+ /** setup-able files have to override this
+ * if they don't, they are read only, and set value will fail
+ * if it is desired to write value of property, then override and use known key.
+ * @return null by default. Should return key to configuration if overriden.
+ */
+ protected String getPropertiesKey() {
+ return null;
+ }
+
public File getFile() {
return new File(getFullPath());
}
- public String getDir() {
- return getFile().getParent();
+ public void setValue(String value) {
+ String key = getPropertiesKey();
+ if (key == null) {
+ throw new IllegalStateException("This file is read only");
+ } else {
+ JNLPRuntime.getConfiguration().setProperty(key, value);
+ }
}
- //setupable files may override this (and maybe also getDir if needed)
public String getFullPath() {
- return getDefaultFullPath();
+ String key = getPropertiesKey();
+ if (key == null) {
+ return getDefaultFullPath();
+ } else {
+ return JNLPRuntime.getConfiguration().getProperty(key);
+ }
}
- //its not recommended to override default locations methods
-
+
public File getDefaultFile() {
return new File(getDefaultFullPath());
}
@@ -624,8 +642,4 @@
};
- private static String gcpd(String key) {
- return JNLPRuntime.getConfiguration().getProperty(key);
- }
-
}
diff -r 1dc3e6bdf364 -r 85505d8c9f3c netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
--- a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java Thu Apr 02 20:48:51 2015 +0200
+++ b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java Thu Apr 02 21:28:10 2015 +0200
@@ -107,7 +107,7 @@
}
private void save() {
- config.setProperty(DeploymentConfiguration.KEY_USER_LOG_DIR, logsDestination.getText());
+ PathsAndFiles.LOG_DIR.setValue(logsDestination.getText());
}
});
final JButton logsDestinationReset = new JButton(Translator.R("CPFilesLogsDestDirResert"));
diff -r 1dc3e6bdf364 -r 85505d8c9f3c netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java
--- a/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java Thu Apr 02 20:48:51 2015 +0200
+++ b/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java Thu Apr 02 21:28:10 2015 +0200
@@ -217,7 +217,7 @@
if (canWrite) {
location.setText(result);
- config.setProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR, result);
+ PathsAndFiles.CACHE_DIR.setValue(result);
}
}
}
diff -r 1dc3e6bdf364 -r 85505d8c9f3c netx/net/sourceforge/jnlp/util/docprovider/ItwebPluginTextProvider.java
--- a/netx/net/sourceforge/jnlp/util/docprovider/ItwebPluginTextProvider.java Thu Apr 02 20:48:51 2015 +0200
+++ b/netx/net/sourceforge/jnlp/util/docprovider/ItwebPluginTextProvider.java Thu Apr 02 21:28:10 2015 +0200
@@ -71,7 +71,7 @@
String mozillas;
if (expandVariables) {
- mozillas = getFormatter().getOption(PathsAndFiles.MOZILA_USER.getDir(), PathsAndFiles.MOZILA_USER.getDescription());
+ mozillas = getFormatter().getOption(PathsAndFiles.MOZILA_USER.getFile().getParent(), PathsAndFiles.MOZILA_USER.getDescription());
} else {
mozillas = getFormatter().getOption(PathsAndFiles.MOZILA_USER.getDirViaAcronym(), PathsAndFiles.MOZILA_USER.getDescription());
}
@@ -79,14 +79,14 @@
if (expandVariables) {
mozillas += getFormatter().getOption(PathsAndFiles.MOZILA_GLOBAL_64.getDirViaAcronym(), PathsAndFiles.MOZILA_GLOBAL_64.getDescription());
} else {
- mozillas += getFormatter().getOption(PathsAndFiles.MOZILA_GLOBAL_64.getDir(), PathsAndFiles.MOZILA_GLOBAL_64.getDescription());
+ mozillas += getFormatter().getOption(PathsAndFiles.MOZILA_GLOBAL_64.getFile().getParent(), PathsAndFiles.MOZILA_GLOBAL_64.getDescription());
}
}
if (!expandVariables || !jdkArch.endsWith("64")) {
if (expandVariables) {
mozillas += getFormatter().getOption(PathsAndFiles.MOZILA_GLOBAL_32.getDirViaAcronym(), PathsAndFiles.MOZILA_GLOBAL_32.getDescription());
} else {
- mozillas += getFormatter().getOption(PathsAndFiles.MOZILA_GLOBAL_32.getDir(), PathsAndFiles.MOZILA_GLOBAL_32.getDescription());
+ mozillas += getFormatter().getOption(PathsAndFiles.MOZILA_GLOBAL_32.getFile().getParent(), PathsAndFiles.MOZILA_GLOBAL_32.getDescription());
}
}
@@ -95,14 +95,14 @@
if (expandVariables) {
operas += getFormatter().getOption(PathsAndFiles.OPERA_64.getDirViaAcronym(), PathsAndFiles.OPERA_64.getDescription());
} else {
- operas += getFormatter().getOption(PathsAndFiles.OPERA_64.getDir(), PathsAndFiles.OPERA_64.getDescription());
+ operas += getFormatter().getOption(PathsAndFiles.OPERA_64.getFile().getParent(), PathsAndFiles.OPERA_64.getDescription());
}
}
if (!expandVariables || !jdkArch.endsWith("64")) {
if (expandVariables) {
operas += getFormatter().getOption(PathsAndFiles.OPERA_32.getDirViaAcronym(), PathsAndFiles.OPERA_32.getDescription());
} else {
- operas += getFormatter().getOption(PathsAndFiles.OPERA_32.getDir(), PathsAndFiles.OPERA_32.getDescription());
+ operas += getFormatter().getOption(PathsAndFiles.OPERA_32.getFile().getParent(), PathsAndFiles.OPERA_32.getDescription());
}
}
return super.getSynopsis()
diff -r 1dc3e6bdf364 -r 85505d8c9f3c tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java Thu Apr 02 20:48:51 2015 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java Thu Apr 02 21:28:10 2015 +0200
@@ -87,13 +87,13 @@
@BeforeClass
public static void setup() {
originalCacheDir = PathsAndFiles.CACHE_DIR.getFullPath();
- JNLPRuntime.getConfiguration().setProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR, System.getProperty("java.io.tmpdir") + File.separator + "tempcache");
+ PathsAndFiles.CACHE_DIR.setValue(System.getProperty("java.io.tmpdir") + File.separator + "tempcache");
}
@AfterClass
public static void teardown() {
CacheUtil.clearCache();
- JNLPRuntime.getConfiguration().setProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR, originalCacheDir);
+ PathsAndFiles.CACHE_DIR.setValue(originalCacheDir);
}
@Test
diff -r 1dc3e6bdf364 -r 85505d8c9f3c tests/netx/unit/net/sourceforge/jnlp/cache/ResourceDownloaderTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceDownloaderTest.java Thu Apr 02 20:48:51 2015 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceDownloaderTest.java Thu Apr 02 21:28:10 2015 +0200
@@ -312,7 +312,7 @@
redirectErrBack();
cacheDir = PathsAndFiles.CACHE_DIR.getFullPath();
- JNLPRuntime.getConfiguration().setProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR, System.getProperty("java.io.tmpdir") + File.separator + "tempcache");
+ PathsAndFiles.CACHE_DIR.setValue(System.getProperty("java.io.tmpdir") + File.separator + "tempcache");
}
@AfterClass
@@ -320,7 +320,7 @@
downloadServer.stop();
CacheUtil.clearCache();
- JNLPRuntime.getConfiguration().setProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR, cacheDir);
+ PathsAndFiles.CACHE_DIR.setValue(cacheDir);
}
private File setupFile(String fileName, String text) throws IOException {
diff -r 1dc3e6bdf364 -r 85505d8c9f3c tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java Thu Apr 02 20:48:51 2015 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java Thu Apr 02 21:28:10 2015 +0200
@@ -251,7 +251,7 @@
redirectErrBack();
cacheDir = PathsAndFiles.CACHE_DIR.getFullPath();
- JNLPRuntime.getConfiguration().setProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR, System.getProperty("java.io.tmpdir") + File.separator + "tempcache");
+ PathsAndFiles.CACHE_DIR.setValue(System.getProperty("java.io.tmpdir") + File.separator + "tempcache");
}
@AfterClass
@@ -259,7 +259,7 @@
downloadServer.stop();
CacheUtil.clearCache();
- JNLPRuntime.getConfiguration().setProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR, cacheDir);
+ PathsAndFiles.CACHE_DIR.setValue(cacheDir);
}
@Test
More information about the distro-pkg-dev
mailing list