/hg/icedtea-web: 2 new changesets
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Fri Apr 10 10:57:09 UTC 2015
changeset 03e42ec1bc49 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=03e42ec1bc49
author: Jiri Vanek <jvanek at redhat.com>
date: Fri Apr 10 12:47:01 2015 +0200
Cache now uses PathsAndFiles instances instead of various duplications
changeset 7f012876934e in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=7f012876934e
author: Jiri Vanek <jvanek at redhat.com>
date: Fri Apr 10 12:56:35 2015 +0200
ok/apply/cancel mechanism in itweb-settings fixed to work again. Added rest button for cache path.
diffstat:
ChangeLog | 52 ++
netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java | 74 ++-
netx/net/sourceforge/jnlp/cache/CacheUtil.java | 12 +-
netx/net/sourceforge/jnlp/config/InfrastructureFileDescriptor.java | 191 ++++++++++
netx/net/sourceforge/jnlp/config/PathsAndFiles.java | 128 +------
netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java | 2 +-
netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsPane.java | 2 +-
netx/net/sourceforge/jnlp/controlpanel/CachePane.java | 13 +-
netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java | 10 +-
netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java | 4 +-
netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java | 4 +-
netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java | 2 +-
netx/net/sourceforge/jnlp/controlpanel/JVMPanel.java | 2 +-
netx/net/sourceforge/jnlp/controlpanel/PolicyPanel.java | 7 +-
netx/net/sourceforge/jnlp/controlpanel/SecuritySettingsPanel.java | 2 +-
netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java | 36 +-
netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java | 2 +-
netx/net/sourceforge/jnlp/security/KeyStores.java | 4 +-
netx/net/sourceforge/jnlp/util/docprovider/ItwebSettingsTextsProvider.java | 5 +-
netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java | 12 +-
plugin/icedteanp/java/sun/applet/PluginProxySelector.java | 2 +-
tests/netx/unit/net/sourceforge/jnlp/cache/CacheLRUWrapperTest.java | 36 +-
tests/netx/unit/net/sourceforge/jnlp/controlpanel/CommandLineTest.java | 7 +-
tests/netx/unit/net/sourceforge/jnlp/security/KeyStoresTest.java | 10 +-
tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropetiesModifier.java | 5 +-
25 files changed, 409 insertions(+), 215 deletions(-)
diffs (truncated from 1293 to 500 lines):
diff -r 7de7aa9d01c2 -r 7f012876934e ChangeLog
--- a/ChangeLog Thu Apr 09 11:31:31 2015 -0400
+++ b/ChangeLog Fri Apr 10 12:56:35 2015 +0200
@@ -1,3 +1,55 @@
+2015-04-10 Jiri Vanek <jvanek at redhat.com>
+
+ ok/apply/cancel mechanism in itweb-settings fixed to work again. Added rest button for cache path.
+ *netx/net/sourceforge/jnlp/config/InfrastructureFileDescriptor.java: added
+ setValue and getFullPaths overloads with DeploymentConfiguration param to
+ allow itweb-settings work with two copies of properties.
+ *netx/net/sourceforge/jnlp/controlpanel/CachePane.java: returned config.
+ Calls to PathsAndFiles made with this config.
+ *netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java: same
+ *netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java: same
+ *netx/net/sourceforge/jnlp/controlpanel/PolicyPanel.java: same
+ *netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java: Calls to
+ PathsAndFiles made with config.
+ *netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java: usableDiskSpace
+ removed, and replaced by dynamic getter to react on change of cache dir.
+ Added button resting cache to default.
+
+2015-04-10 Jiri Vanek <jvanek at redhat.com>
+
+ Cache now uses PathsAndFiles instances instead of various duplications
+ * netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java: using InfrastructureFileDescriptor
+ instead of copied Files. Same with recentlyUsedPropertiesFile. Both made final privat
+ and accessible only via getter. (getRecentlyUsedPropertiesFile) redesigned, to use cached
+ PropertiesFile. If underlying InfrastructureFileDescriptor changes, the cached
+ PropertiesFile is closed and new created and returned.
+ * netx/net/sourceforge/jnlp/cache/CacheUtil.java: Are using getters from
+ CacheLRUWrapper singleton to atomic approach. Not storing those values anymore.
+ * netx/net/sourceforge/jnlp/config/InfrastructureFileDescriptor.java: Moved out
+ from inner class in PathsAndFiles
+ * netx/net/sourceforge/jnlp/config/PathsAndFiles.java:Lost InfrastructureFileDescriptor
+ in favour of outer one.
+ * netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java: config
+ made final
+ * netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsPane.java: same
+ * netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java: same
+ * netx/net/sourceforge/jnlp/controlpanel/JVMPanel.java: same
+ * netx/net/sourceforge/jnlp/controlpanel/SecuritySettingsPanel.java: same
+ * netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java: removed config
+ * netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java: adapted to above
+ * netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java: moved to diamond
+ * netx/net/sourceforge/jnlp/security/KeyStores.java: adapted to InfrastructureFileDescriptor
+ * netx/net/sourceforge/jnlp/util/docprovider/ItwebSettingsTextsProvider.java: same
+ * netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java: same
+ * sun/applet/PluginProxySelector.java: same
+ * tests/netx/unit/net/sourceforge/jnlp/security/KeyStoresTest.java: same
+ * tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropetiesModifier.java:
+ same
+ * tests/netx/unit/net/sourceforge/jnlp/cache/CacheLRUWrapperTest.java: is now
+ using dummy InfrastructureFileDescriptor to allow fake CacheLRUWrapper tests
+ * tests/netx/unit/net/sourceforge/jnlp/controlpanel/CommandLineTest.java: small
+ fixes to unlcear strings
+
2015-04-09 Lukasz Dracz <ldracz at redhat.com>
fix lines displayed in javaws help
diff -r 7de7aa9d01c2 -r 7f012876934e netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java
--- a/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java Thu Apr 09 11:31:31 2015 -0400
+++ b/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java Fri Apr 10 12:56:35 2015 +0200
@@ -48,6 +48,7 @@
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import net.sourceforge.jnlp.config.InfrastructureFileDescriptor;
import net.sourceforge.jnlp.config.PathsAndFiles;
import net.sourceforge.jnlp.util.FileUtils;
@@ -67,11 +68,11 @@
* accessed) followed by folder of item. value = path to file.
*/
- private final PropertiesFile recentlyUsedPropertiesFile;
- private final File cacheDir;
+ private final InfrastructureFileDescriptor recentlyUsedPropertiesFile;
+ private final InfrastructureFileDescriptor cacheDir;
public CacheLRUWrapper() {
- this(PathsAndFiles.getRecentlyUsedFile().getFile(), PathsAndFiles.CACHE_DIR.getFile());
+ this(PathsAndFiles.getRecentlyUsedFile(), PathsAndFiles.CACHE_DIR);
}
@@ -80,13 +81,13 @@
* @param recentlyUsed file to be used as recently_used file
* @param cacheDir dir with cache
*/
- public CacheLRUWrapper(final File recentlyUsed, final File cacheDir) {
- recentlyUsedPropertiesFile = new PropertiesFile(recentlyUsed);
+ public CacheLRUWrapper(final InfrastructureFileDescriptor recentlyUsed, final InfrastructureFileDescriptor cacheDir) {
+ recentlyUsedPropertiesFile = recentlyUsed;
this.cacheDir = cacheDir;
- if (!recentlyUsed.exists()) {
+ if (!recentlyUsed.getFile().exists()) {
try {
- FileUtils.createParentDir(recentlyUsed);
- FileUtils.createRestrictedFile(recentlyUsed, true);
+ FileUtils.createParentDir(recentlyUsed.getFile());
+ FileUtils.createRestrictedFile(recentlyUsed.getFile(), true);
} catch (IOException e) {
OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
}
@@ -102,25 +103,44 @@
return CacheLRUWrapperHolder.INSTANCE;
}
+
+ private PropertiesFile cachedRecentlyUsedPropertiesFile = null ;
/**
* @return the recentlyUsedPropertiesFile
*/
- public PropertiesFile getRecentlyUsedPropertiesFile() {
- return recentlyUsedPropertiesFile;
+ synchronized PropertiesFile getRecentlyUsedPropertiesFile() {
+ if (cachedRecentlyUsedPropertiesFile == null) {
+ //no properties file yet, create it
+ cachedRecentlyUsedPropertiesFile = new PropertiesFile(recentlyUsedPropertiesFile.getFile());
+ return cachedRecentlyUsedPropertiesFile;
+ }
+ if (recentlyUsedPropertiesFile.getFile().equals(cachedRecentlyUsedPropertiesFile.getStoreFile())){
+ //The underlying InfrastructureFileDescriptor is still pointing to the same file, use current properties file
+ return cachedRecentlyUsedPropertiesFile;
+ } else {
+ //the InfrastructureFileDescriptor was set to different location, move to it
+ if (cachedRecentlyUsedPropertiesFile.tryLock()) {
+ cachedRecentlyUsedPropertiesFile.store();
+ cachedRecentlyUsedPropertiesFile.unlock();
+ }
+ cachedRecentlyUsedPropertiesFile = new PropertiesFile(recentlyUsedPropertiesFile.getFile());
+ return cachedRecentlyUsedPropertiesFile;
+ }
+
}
/**
* @return the cacheDir
*/
- public File getCacheDir() {
+ public InfrastructureFileDescriptor getCacheDir() {
return cacheDir;
}
/**
* @return the recentlyUsedFile
*/
- public File getRecentlyUsedFile() {
- return recentlyUsedPropertiesFile.getStoreFile();
+ public InfrastructureFileDescriptor getRecentlyUsedFile() {
+ return recentlyUsedPropertiesFile;
}
private static class CacheLRUWrapperHolder{
@@ -170,7 +190,7 @@
// 2. check path format - does the path look correct?
if (path != null) {
- if (!path.contains(getCacheDir().getAbsolutePath())) {
+ if (!path.contains(getCacheDir().getFullPath())) {
it.remove();
modified = true;
}
@@ -185,6 +205,7 @@
/**
* Write file to disk.
+ * @return true if properties were successfully stored, false otherwise
*/
public synchronized boolean store() {
if (getRecentlyUsedPropertiesFile().isHeldByCurrentThread()) {
@@ -202,10 +223,11 @@
* @return true if we successfully added to map, false otherwise.
*/
public synchronized boolean addEntry(String key, String path) {
- if (getRecentlyUsedPropertiesFile().containsKey(key)) {
+ PropertiesFile props = getRecentlyUsedPropertiesFile();
+ if (props.containsKey(key)) {
return false;
}
- getRecentlyUsedPropertiesFile().setProperty(key, path);
+ props.setProperty(key, path);
return true;
}
@@ -216,15 +238,16 @@
* @return true if we successfully removed key from map, false otherwise.
*/
public synchronized boolean removeEntry(String key) {
- if (!recentlyUsedPropertiesFile.containsKey(key)) {
+ PropertiesFile props = getRecentlyUsedPropertiesFile();
+ if (!props.containsKey(key)) {
return false;
}
- getRecentlyUsedPropertiesFile().remove(key);
+ props.remove(key);
return true;
}
private String getIdForCacheFolder(String folder) {
- int len = getCacheDir().getAbsolutePath().length();
+ int len = getCacheDir().getFullPath().length();
int index = folder.indexOf(File.separatorChar, len + 1);
return folder.substring(len + 1, index);
}
@@ -236,12 +259,15 @@
* @return true if we successfully updated value, false otherwise.
*/
public synchronized boolean updateEntry(String oldKey) {
- if (!recentlyUsedPropertiesFile.containsKey(oldKey)) return false;
- String value = getRecentlyUsedPropertiesFile().getProperty(oldKey);
+ PropertiesFile props = getRecentlyUsedPropertiesFile();
+ if (!props.containsKey(oldKey)) {
+ return false;
+ }
+ String value = props.getProperty(oldKey);
String folder = getIdForCacheFolder(value);
- getRecentlyUsedPropertiesFile().remove(oldKey);
- getRecentlyUsedPropertiesFile().setProperty(Long.toString(System.currentTimeMillis()) + "," + folder, value);
+ props.remove(oldKey);
+ props.setProperty(Long.toString(System.currentTimeMillis()) + "," + folder, value);
return true;
}
@@ -257,7 +283,7 @@
List<Entry<String, String>> entries = new ArrayList<>();
for (Entry e : getRecentlyUsedPropertiesFile().entrySet()) {
- entries.add(new AbstractMap.SimpleImmutableEntry<String, String>(e));
+ entries.add(new AbstractMap.SimpleImmutableEntry<>(e));
}
// sort by keys in descending order.
diff -r 7de7aa9d01c2 -r 7f012876934e netx/net/sourceforge/jnlp/cache/CacheUtil.java
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java Thu Apr 09 11:31:31 2015 -0400
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java Fri Apr 10 12:56:35 2015 +0200
@@ -145,7 +145,7 @@
}
CacheLRUWrapper lruHandler = CacheLRUWrapper.getInstance();
- File cacheDir = lruHandler.getCacheDir();
+ File cacheDir = lruHandler.getCacheDir().getFile();
if (!(cacheDir.isDirectory())) {
return false;
}
@@ -342,7 +342,7 @@
* Get the path to file minus the cache directory and indexed folder.
*/
private static String pathToURLPath(String path) {
- int len = CacheLRUWrapper.getInstance().getCacheDir().getAbsolutePath().length();
+ int len = CacheLRUWrapper.getInstance().getCacheDir().getFullPath().length();
int index = path.indexOf(File.separatorChar, len + 1);
return path.substring(index);
}
@@ -354,7 +354,7 @@
public static String getCacheParentDirectory(String filePath) {
String path = filePath;
String tempPath = "";
- String cacheDir = CacheLRUWrapper.getInstance().getCacheDir().getAbsolutePath();
+ String cacheDir = CacheLRUWrapper.getInstance().getCacheDir().getFullPath();
while(path.startsWith(cacheDir) && !path.equals(cacheDir)){
tempPath = new File(path).getParent();
@@ -384,7 +384,7 @@
lruHandler.lock();
lruHandler.load();
for (long i = 0; i < Long.MAX_VALUE; i++) {
- String path = lruHandler.getCacheDir().getAbsolutePath() + File.separator + i;
+ String path = lruHandler.getCacheDir().getFullPath()+ File.separator + i;
File cDir = new File(path);
if (!cDir.exists()) {
// We can use this directory.
@@ -591,8 +591,8 @@
* rStr first becomes: /0/http/www.example.com/subdir/a.jar
* then rstr becomes: /home/user1/.icedtea/cache/0
*/
- String rStr = file.getPath().substring(lruHandler.getCacheDir().getAbsolutePath().length());
- rStr =lruHandler.getCacheDir().getAbsolutePath() + rStr.substring(0, rStr.indexOf(File.separatorChar, 1));
+ String rStr = file.getPath().substring(lruHandler.getCacheDir().getFullPath().length());
+ rStr = lruHandler.getCacheDir().getFullPath()+ rStr.substring(0, rStr.indexOf(File.separatorChar, 1));
long len = file.length();
if (keep.contains(file.getPath().substring(rStr.length()))) {
diff -r 7de7aa9d01c2 -r 7f012876934e netx/net/sourceforge/jnlp/config/InfrastructureFileDescriptor.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/netx/net/sourceforge/jnlp/config/InfrastructureFileDescriptor.java Fri Apr 10 12:56:35 2015 +0200
@@ -0,0 +1,191 @@
+/*
+ Copyright (C) 2012 Red Hat
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+*/
+
+package net.sourceforge.jnlp.config;
+
+import java.io.File;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.runtime.Translator;
+
+
+public class InfrastructureFileDescriptor {
+ private final String fileName;
+ private final String pathStub;
+ private final String systemPathStub;
+ private final String descriptionKey;
+ final PathsAndFiles.Target[] target;
+
+
+ //simple constructor to allow testing instances based on overrides
+ protected InfrastructureFileDescriptor() {
+ this("undef", "undef", "undef", "undef");
+ }
+
+ InfrastructureFileDescriptor(String fileName, String pathStub, String systemPathStub, String descriptionKey, PathsAndFiles.Target... target) {
+ this.fileName = fileName;
+ this.pathStub = pathStub;
+ this.systemPathStub = systemPathStub;
+ 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 void setValue(String value) {
+ setValue(value, JNLPRuntime.getConfiguration());
+ }
+
+ public String getFullPath() {
+ return getFullPath(JNLPRuntime.getConfiguration());
+ }
+
+ /**
+ * overload version for control panel, which is saving to internal copy.
+ * @param value
+ * @param config
+ */
+ public void setValue(String value, DeploymentConfiguration config) {
+ String key = getPropertiesKey();
+ if (key == null) {
+ throw new IllegalStateException("This file is read only");
+ } else {
+ config.setProperty(key, value);
+ }
+ }
+
+ /**
+ * overload version for control panel, which is saving to internal copy.
+ * @param config
+ * @return
+ */
+ public String getFullPath(DeploymentConfiguration config) {
+ String key = getPropertiesKey();
+ if (key == null) {
+ return getDefaultFullPath();
+ } else {
+ return config.getProperty(key);
+ }
+ }
+
+ public File getDefaultFile() {
+ return new File(getDefaultFullPath());
+ }
+
+ public String getDefaultDir() {
+ return clean(systemPathStub + File.separator + pathStub);
+ }
+
+ public String getDefaultFullPath() {
+ return clean(systemPathStub + File.separator + pathStub + File.separator + fileName);
+ }
+
+ //returns path acronym for default location
+ protected String getSystemPathStubAcronym() {
+ return systemPathStub;
+ }
+
+ protected String getFileName() {
+ return fileName;
+ }
+
+ protected String getDescriptionKey() {
+ return descriptionKey;
+ }
+
+ /**
+ * This remaining part of file declaration, when acronym is removed.
+ * See getDirViaAcronym.
+ *
+ * @return
+ */
+ private String getStub() {
+ return clean(pathStub + File.separator + fileName);
+ }
+
+ @Override
+ public String toString() {
+ return clean(getSystemPathStubAcronym() + File.separator + getStub());
+ }
+
+ /**
+ * For documentation purposes, the descriptor may be created as VARIABLE/custom/path.
+ *
+ * This is whole part, which is considered as setup-able.
+ * @return
+ */
+ public String getDirViaAcronym() {
+ return clean(getSystemPathStubAcronym() + File.separator + pathStub);
+ }
+
+ /**
+ * Remove garbage from paths.
+ *
+ * Currently this methods unify all multiple occurrences of separators
+ * to single one. Eg /path/to//file will become /path/to/file.
+ *
+ * Those artifacts maybe spread during various s=path+deparator+subdir+separator
+ * file=s+separator+filename
+ *
+ * @param s string to be cleaned
+ * @return cleaned string
+ */
+ protected String clean(String s) {
+ while (s.contains(File.separator + File.separator)) {
+ s = s.replace(File.separator + File.separator, File.separator);
+ }
+ return s;
+ }
+
+ /**
+ * @return the translated description
+ */
+ public String getDescription() {
+ return Translator.R(descriptionKey);
+ }
+
+}
diff -r 7de7aa9d01c2 -r 7f012876934e netx/net/sourceforge/jnlp/config/PathsAndFiles.java
--- a/netx/net/sourceforge/jnlp/config/PathsAndFiles.java Thu Apr 09 11:31:31 2015 -0400
+++ b/netx/net/sourceforge/jnlp/config/PathsAndFiles.java Fri Apr 10 12:56:35 2015 +0200
@@ -290,7 +290,7 @@
};
public static final InfrastructureFileDescriptor USER_DEPLOYMENT_FILE = new ItwConfigFileDescriptor(DEPLOYMENT_PROPERTIES, "FILEuserdp", Target.JAVAWS, Target.ITWEB_SETTINGS);
- private static enum Target {
+ static enum Target {
JAVAWS, PLUGIN, ITWEB_SETTINGS, POLICY_EDITOR;
}
@@ -338,132 +338,6 @@
return getAllFiles(Target.PLUGIN);
}
- public static class InfrastructureFileDescriptor {
-
- private final String fileName;
- private final String pathStub;
- private final String systemPathStub;
More information about the distro-pkg-dev
mailing list