use of java.util.prefs.BackingStoreException in project certmgr by hdecarne.
the class CertOptionsTemplates method load.
public static List<Template> load() {
List<Template> templates = new ArrayList<>();
try {
Preferences templateStore;
if (TEMPLATE_STORE_INITIALIZED.getBoolean(false)) {
templateStore = TEMPLATE_STORE;
} else {
try (InputStream standardTemplatesStream = getStandardTemplatesUrl().openStream()) {
Properties standardTemplates = new Properties();
standardTemplates.load(standardTemplatesStream);
templateStore = FilePreferencesFactory.customRoot(standardTemplates);
}
}
String[] templateNodeNames = templateStore.childrenNames();
Arrays.sort(templateNodeNames);
for (String templateNodeName : templateNodeNames) {
Preferences templateNode = templateStore.node(templateNodeName);
@Nullable Template template = loadTemplate(templateNode);
if (template != null) {
templates.add(template);
}
}
} catch (IOException | BackingStoreException e) {
Exceptions.warn(e);
}
return templates;
}
use of java.util.prefs.BackingStoreException in project certmgr by hdecarne.
the class CertOptionsTemplates method loadTemplate.
@Nullable
private static Template loadTemplate(Preferences templateNode) {
@Nullable Template template = null;
@Nullable String name = templateNode.get(Template.KEY_NAME, null);
@Nullable String aliasInput = templateNode.get(Template.KEY_ALIAS, null);
@Nullable String dnInput = templateNode.get(Template.KEY_DN, null);
if (Strings.notEmpty(name) && Strings.notEmpty(aliasInput) && Strings.notEmpty(dnInput)) {
assert name != null;
assert aliasInput != null;
assert dnInput != null;
template = new Template(name, new CertOptionsPreset(aliasInput, dnInput));
@Nullable String keyAlg = templateNode.get(Template.KEY_KEYALG, null);
if (keyAlg != null) {
template.setKeyAlg(KeyHelper.getKeyAlg(keyAlg));
}
int keySize = templateNode.getInt(Template.KEY_KEYSIZE, 0);
if (keySize != 0) {
template.setKeySize(keySize);
}
try {
String[] extensionNodeNames = templateNode.childrenNames();
for (String extensionNodeName : extensionNodeNames) {
Preferences extensionNode = templateNode.node(extensionNodeName);
@Nullable String oid = extensionNode.get(Template.KEY_EXTENSION_OID, null);
boolean criticial = extensionNode.getBoolean(Template.KEY_EXTENSION_CRITICAL, false);
@Nullable byte[] data = extensionNode.getByteArray(Template.KEY_EXTENSION_DATA, null);
if (Strings.notEmpty(oid) && data != null) {
assert oid != null;
template.addExtension(X509ExtensionData.decode(oid, criticial, data));
} else {
LOG.warning("Ignoring incomplete extension node ''{0}''", extensionNode.absolutePath());
}
}
} catch (BackingStoreException | IOException e) {
LOG.warning(e, "Ignoring inaccessible extension data for template node ''{0}''", templateNode.absolutePath());
}
} else {
LOG.warning("Ignoring incomplete template node ''{0}''", templateNode.absolutePath());
}
return template;
}
use of java.util.prefs.BackingStoreException in project gephi by gephi.
the class RecentPalettes method store.
private void store() {
Preferences prefs = getPreferences();
// clear the backing store
try {
prefs.clear();
} catch (BackingStoreException ex) {
}
int i = 0;
for (LinearGradient gradient : gradients) {
try {
prefs.putByteArray(COLORS + i, serializeColors(gradient.getColors()));
prefs.putByteArray(POSITIONS + i, serializePositions(gradient.getPositions()));
} catch (Exception e) {
Exceptions.printStackTrace(e);
}
i++;
}
}
use of java.util.prefs.BackingStoreException in project pivot by apache.
the class DesktopApplicationContext method exit.
/**
* Terminates the application context.
*
* @param optional If <tt>true</tt>, shutdown is optional and may be
* cancelled. If <tt>false</tt>, shutdown cannot be cancelled.
* @return Whether shutdown was canceled by the application.
*/
public static boolean exit(boolean optional) {
boolean cancelShutdown = false;
if (application != null) {
try {
cancelShutdown = application.shutdown(optional);
} catch (Throwable exception) {
handleUncaughtException(exception);
} finally {
if (!cancelShutdown) {
// Remove the application from the application list
applications.remove(application);
}
}
}
if (!cancelShutdown) {
try {
Preferences preferences = Preferences.userNodeForPackage(DesktopApplicationContext.class);
preferences = preferences.node(applicationClassName);
boolean maximized = (windowedHostFrame.getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH;
if (!maximized) {
preferences.putInt(X_ARGUMENT, windowedHostFrame.getX());
preferences.putInt(Y_ARGUMENT, windowedHostFrame.getY());
preferences.putInt(WIDTH_ARGUMENT, windowedHostFrame.getWidth());
preferences.putInt(HEIGHT_ARGUMENT, windowedHostFrame.getHeight());
}
preferences.putBoolean(MAXIMIZED_ARGUMENT, maximized);
preferences.flush();
} catch (SecurityException exception) {
// No-op
} catch (BackingStoreException exception) {
// No-op
}
windowedHostFrame.dispose();
fullScreenHostFrame.dispose();
}
return cancelShutdown;
}
use of java.util.prefs.BackingStoreException in project blue by kunstmusik.
the class FileManagerRoots method saveCustomRoots.
private void saveCustomRoots() {
Preferences p = NbPreferences.forModule(FileManagerRoots.class);
try {
p.clear();
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
int i = 0;
for (File f : customRoots) {
p.put("customRoot" + i, f.getAbsolutePath());
i++;
}
try {
p.flush();
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
}
Aggregations