Example usage for java.util.prefs BackingStoreException printStackTrace

List of usage examples for java.util.prefs BackingStoreException printStackTrace

Introduction

In this page you can find the example usage for java.util.prefs BackingStoreException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:PreferenceExample.java

public static void main(String args[]) {
    PreferenceExample pe = new PreferenceExample();
    Preferences prefsRoot = Preferences.userRoot();
    Preferences myPrefs = prefsRoot.node("PreferenceExample");

    try {/*w  w  w  . ja  v a  2  s .co m*/
        pe.setSomeProperties(myPrefs);
        pe.printInformation(myPrefs);
        pe.exportToFile(myPrefs, "prefs.xml");
    } catch (BackingStoreException bse) {
        System.out.println("Problem with accessing the backing store\n" + bse);
        bse.printStackTrace();
    }
}

From source file:PrefsUtil.java

/**
 * Clear all the node//from   ww w. ja  v a 2  s.co  m
 */
public static void clear(Preferences preferences, String key) {
    try {
        if (preferences.nodeExists(key)) {
            preferences.node(key).clear();
        }
    } catch (BackingStoreException bse) {
        bse.printStackTrace();
    }
}

From source file:PrefsUtil.java

/**
 * Remove the node/*from  w ww  . jav a 2  s. c o m*/
 */
public static void remove(Preferences preferences, String key) {
    try {
        if (preferences.nodeExists(key)) {
            preferences.node(key).removeNode();
        }
    } catch (BackingStoreException bse) {
        bse.printStackTrace();
    }
}

From source file:PrefsUtil.java

/**
 * Gets a Map from the preferences.//w  w w .  ja  v a  2  s.com
 */
public static Map getMap(Preferences preferences) {
    if (preferences == null) {
        throw new IllegalArgumentException("Preferences not set.");
    }

    Map map = new HashMap();

    try {
        String[] keys = preferences.keys();

        for (int index = 0; index < keys.length; index++) {
            map.put(keys[index], preferences.get(keys[index], null));
        }
    } catch (BackingStoreException bse) {
        bse.printStackTrace();
    }

    return map;
}

From source file:com.projity.util.VersionUtils.java

public static boolean versionCheck(boolean warnIfBad) {
    String version = VersionUtils.getVersion();
    if (version == null) // for running in debugger
        version = "0";
    Preferences pref = Preferences.userNodeForPackage(VersionUtils.class);
    String localVersion = pref.get("Angel Falls Version", "unknown");
    boolean updated = !localVersion.equals(version);
    String javaVersion = System.getProperty("java.version");
    log.info("Angel Falls Version: " + version + " local version " + localVersion + " updated=" + updated
            + " java version=" + javaVersion);

    pref.put("JavaVersion", javaVersion);

    if (updated) {
        Environment.setUpdated(true);
        pref.put("PODVersion", version);
        try {/*from w  w w .ja  v a 2  s  .com*/
            pref.flush();
        } catch (BackingStoreException e) {
            e.printStackTrace();
        }

        if (warnIfBad && Environment.isApplet()) {
            if (javaVersion.equals("1.6.0_09") || javaVersion.equals("1.6.0_08")
                    || javaVersion.equals("1.6.0_07") || javaVersion.equals("1.6.0_06")
                    || javaVersion.equals("1.6.0_05") || javaVersion.equals("1.6.0_04")) {
                Environment.setNeedToRestart(true);
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        Alert.error(Messages.getString("Error.restart"));
                    }
                });
            }
        }
    } else {
        try {
            pref.flush();
        } catch (BackingStoreException e) {
            e.printStackTrace();
        }
    }
    return updated;
}

From source file:edu.ku.brc.af.prefs.AppPreferences.java

/**
 * Saves the prefs/*  w  w w  .  j  a v  a 2 s  .  com*/
 */
protected static void syncPrefs() {
    /*
     * Synchronization necessary because userRoot and systemRoot are
     * lazily initialized.
     */
    AppPreferences prefsLocal;
    AppPreferences prefsRemote;

    synchronized (AppPreferences.class) {
        prefsLocal = instanceLocal;
        prefsRemote = instanceRemote;
    }

    try {
        if (prefsLocal != null) {
            prefsLocal.flush();
        }

    } catch (BackingStoreException e) {
        log.error("Couldn't flush the local prefs: " + e); //$NON-NLS-1$
        e.printStackTrace();
    }

    try {
        if (connectedToDB && prefsRemote != null) {
            prefsRemote.flush();
        }
    } catch (BackingStoreException e) {
        log.error("Couldn't flush the remote prefs: " + e); //$NON-NLS-1$
        e.printStackTrace();
    }
}

From source file:com.tag.FramePreferences.java

public boolean isFirst() {
    Preferences prefs = getPreferences();
    try {//from w ww.  ja v a2 s.  c om
        List<String> pref = Arrays.asList(prefs.keys());
        for (String key : keys()) {
            if (pref.contains(key)) {
                return false;
            }
        }
    } catch (BackingStoreException ex) {
        ex.printStackTrace();
    }
    return true;
}

From source file:gov.bnl.channelfinder.api.ChannelFinderClientImpl.java

@Deprecated
public static void resetPreferences() {
    try {/*from   w w w. ja v a  2s .  c o  m*/
        Preferences.userNodeForPackage(ChannelFinderClientImpl.class).clear();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
}

From source file:de.ingrid.usermanagement.jetspeed.IngridRoleManager.java

/**
 * @see org.apache.jetspeed.security.RoleManager#addRole(java.lang.String)
 *//*w w w  .  j  a v a  2 s  . c o m*/
public void addRole(String roleFullPathName) throws SecurityException {
    ArgUtil.notNull(new Object[] { roleFullPathName }, new String[] { "roleFullPathName" },
            "addRole(java.lang.String)");

    // Check if role already exists.
    if (roleExists(roleFullPathName)) {
        throw new SecurityException(SecurityException.ROLE_ALREADY_EXISTS.create(roleFullPathName));
    }

    RolePrincipal rolePrincipal = new RolePrincipalImpl(roleFullPathName);
    String fullPath = rolePrincipal.getFullPath();
    // Add the preferences.
    Preferences preferences = Preferences.userRoot().node(fullPath);
    if (log.isDebugEnabled()) {
        log.debug("Added role preferences node: " + fullPath);
    }
    try {
        if ((null != preferences) && preferences.absolutePath().equals(fullPath)) {
            // Add role principal.
            roleSecurityHandler.setRolePrincipal(rolePrincipal);
            if (log.isDebugEnabled()) {
                log.debug("Added role: " + fullPath);
            }
        }
    } catch (SecurityException se) {
        KeyedMessage msg = SecurityException.UNEXPECTED.create("RoleManager.addRole",
                "RoleSecurityHandler.setRolePrincipal(" + rolePrincipal.getName() + ")", se.getMessage());
        log.error(msg, se);

        // Remove the preferences node.
        try {
            preferences.removeNode();
        } catch (BackingStoreException bse) {
            bse.printStackTrace();
        }
        throw new SecurityException(msg, se);
    }
}

From source file:com.ethanruffing.preferenceabstraction.AutoPreferences.java

/**
 * Deletes all preferences stored for the class.
 *///from  ww  w. ja  va2s  .c  om
@Override
public void clear() {
    if (configType == ConfigurationType.SYSTEM) {
        try {
            prefs.clear();
        } catch (BackingStoreException e) {
            e.printStackTrace();
        }
    } else {
        fileConfig.clear();
        fileConfig.getFile().delete();
    }
}