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:edu.ku.brc.specify.Specify.java

/**
 * Restarts the app with a new or old database and user name and creates the core app UI.
 * @param window the login window//from   ww w . j  av a  2  s .c o  m
 * @param databaseNameArg the database name
 * @param userNameArg the user name
 * @param startOver tells the AppContext to start over
 * @param firstTime indicates this is the first time in the app and it should create all the UI for the core app
 */
public void restartApp(final Window window, final String databaseNameArg, final String userNameArg,
        final boolean startOver, final boolean firstTime) {
    log.debug("restartApp"); //$NON-NLS-1$
    if (dbLoginPanel != null) {
        dbLoginPanel.getStatusBar().setText(getResourceString("Specify.INITIALIZING_APP")); //$NON-NLS-1$
    }

    if (!firstTime) {
        checkAndSendStats();
    }

    UIRegistry.dumpPaths();

    try {
        AppPreferences.getLocalPrefs().flush();
    } catch (BackingStoreException ex) {
    }

    AppPreferences.shutdownRemotePrefs();
    AppPreferences.shutdownPrefs();
    AppPreferences.setConnectedToDB(false);

    // Moved here because context needs to be set before loading prefs, we need to know the SpecifyUser
    //
    // NOTE: AppPreferences.startup(); is called inside setContext's implementation.
    //
    AppContextMgr.reset();
    AppContextMgr.CONTEXT_STATUS status = AppContextMgr.getInstance().setContext(databaseNameArg, userNameArg,
            startOver, firstTime, !firstTime);
    if (status == AppContextMgr.CONTEXT_STATUS.OK) {
        // XXX Temporary Fix!
        SpecifyUser spUser = AppContextMgr.getInstance().getClassObject(SpecifyUser.class);

        if (spUser != null) {
            String dbPassword = spUser.getPassword();

            if (StringUtils.isNotEmpty(dbPassword) && (!StringUtils.isAlphanumeric(dbPassword)
                    || !UIHelper.isAllCaps(dbPassword) || dbPassword.length() < 25)) {
                String encryptedPassword = Encryption.encrypt(spUser.getPassword(), spUser.getPassword());
                spUser.setPassword(encryptedPassword);
                DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
                try {
                    session.beginTransaction();
                    session.saveOrUpdate(session.merge(spUser));
                    session.commit();

                } catch (Exception ex) {
                    session.rollback();
                    ex.printStackTrace();
                } finally {
                    session.close();
                }
            }
        }
    }

    UsageTracker.setUserInfo(databaseNameArg, userNameArg);

    SpecifyAppPrefs.initialPrefs();

    // Check Stats (this is mostly for the first time in.
    AppPreferences appPrefs = AppPreferences.getRemote();
    Boolean canSendStats = appPrefs.getBoolean(sendStatsPrefName, null); //$NON-NLS-1$
    Boolean canSendISAStats = appPrefs.getBoolean(sendISAStatsPrefName, null); //$NON-NLS-1$

    // Make sure we have the proper defaults
    if (canSendStats == null) {
        canSendStats = true;
        appPrefs.putBoolean("usage_tracking.send_stats", canSendStats); //$NON-NLS-1$
    }

    if (canSendISAStats == null) {
        canSendISAStats = true;
        appPrefs.putBoolean(sendISAStatsPrefName, canSendISAStats); //$NON-NLS-1$
    }

    if (status == AppContextMgr.CONTEXT_STATUS.OK) {
        // XXX Get the current locale from prefs PREF

        if (AppContextMgr.getInstance().getClassObject(Discipline.class) == null) {
            return;
        }

        // "false" means that it should use any cached values it can find to automatically initialize itself
        if (firstTime) {
            GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()
                    .getDefaultScreenDevice().getDefaultConfiguration();

            initialize(gc);

            topFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
            UIRegistry.register(UIRegistry.FRAME, topFrame);
        } else {
            SubPaneMgr.getInstance().closeAll();
        }

        preInitializePrefs();

        initStartUpPanels(databaseNameArg, userNameArg);

        AppPrefsCache.addChangeListener("ui.formatting.scrdateformat", UIFieldFormatterMgr.getInstance());

        if (changeCollectionMenuItem != null) {
            changeCollectionMenuItem.setEnabled(
                    ((SpecifyAppContextMgr) AppContextMgr.getInstance()).getNumOfCollectionsForUser() > 1);
        }

        if (window != null) {
            window.setVisible(false);
        }

        // General DB Fixes independent of a release.
        if (!AppPreferences.getGlobalPrefs().getBoolean("CollectingEventsAndAttrsMaint1", false)) {
            // Temp Code to Fix issues with Release 6.0.9 and below
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    CollectingEventsAndAttrsMaint dbMaint = new CollectingEventsAndAttrsMaint();
                    dbMaint.performMaint();
                }
            });
        }

        /*if (!AppPreferences.getGlobalPrefs().getBoolean("FixAgentToDisciplinesV2", false))
        {
        // Temp Code to Fix issues with Release 6.0.9 and below
        SwingUtilities.invokeLater(new Runnable() 
        {
            @Override
            public void run()
            {
                FixDBAfterLogin fixer = new FixDBAfterLogin();
                fixer.fixAgentToDisciplines();
            }
        });
        }*/

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                performManualDBUdpatesAfterLogin();
            }
        });

        DataBuilder.mergeStandardGroups(AppContextMgr.getInstance().getClassObject(Collection.class));

    } else if (status == AppContextMgr.CONTEXT_STATUS.Error) {

        if (dbLoginPanel != null) {
            dbLoginPanel.getWindow().setVisible(false);
        }

        if (AppContextMgr.getInstance().getClassObject(Collection.class) == null) {

            // TODO This is really bad because there is a Database Login with no Specify login
            JOptionPane.showMessageDialog(null, getResourceString("Specify.LOGIN_USER_MISMATCH"), //$NON-NLS-1$
                    getResourceString("Specify.LOGIN_USER_MISMATCH_TITLE"), //$NON-NLS-1$
                    JOptionPane.ERROR_MESSAGE);
            System.exit(0);
        }

    }

    CommandDispatcher.dispatch(new CommandAction("App", firstTime ? "StartUp" : "AppRestart", null)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    TaskMgr.requestInitalContext();

    if (!UIRegistry.isRelease()) {
        DebugLoggerDialog dialog = new DebugLoggerDialog(null);
        dialog.configureLoggers();
    }

    showApp();

    if (dbLoginPanel != null) {
        dbLoginPanel.getWindow().setVisible(false);
        dbLoginPanel = null;
    }
    setDatabaseNameAndCollection();
}

From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java

private void exitFrame() {
    // TODO save or confirm exit
    try {/*  w ww  . j  a v a2s  .  c  o  m*/
        Global.PREFERENCES.clear();
    } catch (BackingStoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    System.exit(0);
}

From source file:org.pentaho.reporting.designer.core.settings.ProxySettings.java

public void flush() {
    try {/* ww w.j av  a2  s.c  o m*/
        preferences.flush();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
}

From source file:verdandi.ui.common.WidthStoringTable.java

/**
 * Stores thw width of the columns to a preference. The preference is stored
 * beneath the node for the Package of the implementing class. Preferences are
 * named {@link #PREFIX_COL_WIDTH} plus the column index.
 * /*www  .j  a v  a 2s.  c  om*/
 * @see #PREFIX_COL_WIDTH
 */
public void storeWidths() {
    Preferences prefs = Preferences.userNodeForPackage(getClass());
    LOG.debug("Storing widths to " + prefs.absolutePath() + "; " + getModel().getClass().getSimpleName());
    for (int i = 0; i < getModel().getColumnCount(); i++) {
        int width = getColumnModel().getColumn(i).getWidth();
        LOG.debug("Store  " + widthPref + i + "=" + width);
        prefs.putInt(widthPref + i, width);
    }
    try {
        prefs.flush();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
}