use of java.util.prefs.BackingStoreException in project cayenne by apache.
the class RenamedPreferences method childrenCopy.
private static ArrayList<Preferences> childrenCopy(Preferences pref, String oldPath, String newPath) {
try {
String[] children = pref.childrenNames();
ArrayList<Preferences> prefChild = new ArrayList<Preferences>();
for (int j = 0; j < children.length; j++) {
String child = children[j];
// get old preference
Preferences childNode = pref.node(child);
if (!equalsPath(oldNode, childNode)) {
// path to node
String path = childNode.absolutePath().replace(oldPath, newPath);
// copy all preferences in this node
String[] names = childNode.keys();
Preferences newPref = Preferences.userRoot().node(path);
for (int i = 0; i < names.length; i++) {
newPref.put(names[i], childNode.get(names[i], ""));
}
prefChild.add(newPref);
}
}
return prefChild;
} catch (BackingStoreException e) {
}
return null;
}
use of java.util.prefs.BackingStoreException in project cayenne by apache.
the class RenamedPreferences method removeOldPreferences.
public static void removeOldPreferences() {
if (oldNode != null) {
Iterator<Preferences> it = oldNode.iterator();
while (it.hasNext()) {
Preferences pref = it.next();
try {
pref.removeNode();
} catch (BackingStoreException e) {
} catch (IllegalStateException e) {
// do nothing
}
}
clearPreferences();
}
}
use of java.util.prefs.BackingStoreException in project tigervnc by TigerVNC.
the class UserPreferences method save.
public static void save(String nName) {
try {
Preferences node = root.node(nName);
node.sync();
String[] keys = root.keys();
for (int i = 0; i < keys.length; i++) vlog.debug(keys[i] + " = " + node.get(keys[i], null));
} catch (BackingStoreException e) {
vlog.error(e.getMessage());
}
}
use of java.util.prefs.BackingStoreException in project tigervnc by TigerVNC.
the class UserPreferences method load.
public static void load(String nName) {
// Sets the value of any corresponding Configuration parameters
try {
Preferences node = root.node(nName);
String[] keys = node.keys();
for (int i = 0; i < keys.length; i++) {
String key = keys[i];
VoidParameter p = Configuration.getParam(key);
if (p == null)
continue;
String valueStr = node.get(key, null);
if (valueStr == null)
valueStr = p.getDefaultStr();
Configuration.setParam(key, valueStr);
}
} catch (BackingStoreException e) {
vlog.error(e.getMessage());
}
}
use of java.util.prefs.BackingStoreException in project jgnash by ccavanaugh.
the class PortablePreferences method deleteUserPreferences.
public static void deleteUserPreferences() {
try {
final Preferences p = Preferences.userRoot();
if (p.nodeExists("/jgnash")) {
Preferences jgnash = p.node("/jgnash");
jgnash.removeNode();
p.flush();
System.out.println(ResourceUtils.getString("Message.UninstallGood"));
} else {
System.err.println(ResourceUtils.getString("Message.PrefFail"));
}
} catch (final BackingStoreException bse) {
LogUtil.logSevere(PortablePreferences.class, bse);
System.err.println(ResourceUtils.getString("Message.UninstallBad"));
}
}
Aggregations