Example usage for java.util.prefs BackingStoreException getMessage

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

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

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

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

    // Resolve the role hierarchy.
    Preferences prefs = Preferences.userRoot()
            .node(RolePrincipalImpl.getFullPathFromPrincipalName(roleFullPathName));
    String[] roles = securityMappingHandler.getRoleHierarchyResolver().resolveChildren(prefs);
    for (int i = 0; i < roles.length; i++) {
        try {
            roleSecurityHandler.removeRolePrincipal(
                    new RolePrincipalImpl(RolePrincipalImpl.getPrincipalNameFromFullPath((String) roles[i])));
        } catch (Exception e) {
            KeyedMessage msg = SecurityException.UNEXPECTED.create("RoleManager.removeRole",
                    "RoleSecurityHandler.removeRolePrincipal("
                            + RolePrincipalImpl.getPrincipalNameFromFullPath((String) roles[i]) + ")",
                    e.getMessage());
            log.error(msg, e);
            throw new SecurityException(msg, e);
        }
        // Remove preferences
        Preferences rolePref = Preferences.userRoot().node((String) roles[i]);
        try {
            rolePref.removeNode();
        } catch (BackingStoreException bse) {
            KeyedMessage msg = SecurityException.UNEXPECTED.create("RoleManager.removeRole",
                    "Preferences.removeNode(" + roles[i] + ")", bse.getMessage());
            log.error(msg, bse);
            throw new SecurityException(msg, bse);
        }
    }
}

From source file:com.symbian.utils.config.ConfigUtils.java

/**
 * completeConfigFromStore// w w  w  . j a  v a 2s  .co m
 * add any extra elements from the store. For example, if the plugins have been activated before, there settings 
 * would have been loaded by their activators.
 *
 */
protected void completeConfigFromStore() {
    try {
        TreeSet<String> storeKeys = new TreeSet<String>();
        storeKeys.addAll(Arrays.asList(iPrefrences.keys()));
        TreeSet<String> localKeys = new TreeSet<String>();
        localKeys.addAll(Arrays.asList(iPreferenceLiterals));

        for (String key : storeKeys) {
            if (!localKeys.contains(key)) {
                addConfig(key, iPrefrences.get(key, ""), new CheckGetConfig(), new CheckSetConfig(),
                        String.class);
            }
        }
    } catch (BackingStoreException e) {
        LOGGER.log(Level.SEVERE, "Could not initialise the config " + e.getMessage());
    }
}

From source file:com.symbian.utils.config.ConfigUtils.java

/**
 * Clear user prefrences from the configuration
 * /*from  w ww. j  av a2 s  .co  m*/
 * @throws IOException
 *             If the operation fails.
 */
public void clearConfig() throws IOException {
    try {
        iPrefrences.clear();
        iSavedConfig.clear();
    } catch (BackingStoreException lBSE) {
        throw new IOException("Can not clear user prefs from configuration" + lBSE.getMessage());
    }
}

From source file:com.symbian.utils.config.ConfigUtils.java

/**
 * @param aConfigMap/*from w ww .java  2 s . com*/
 * @param aPreferenceAddress
 * @param aPreferenceLiterals
 * @throws IOException
 */
protected ConfigUtils(String aPreferenceAddress, String[] aPreferenceLiterals) throws IOException {
    iNodeName = aPreferenceAddress;
    iConfigMap = new HashMap();
    iSavedConfig = new HashMap();
    iPreferenceLiterals = aPreferenceLiterals;

    iPrefrences = Preferences.userRoot().node(iNodeName);
    // if created for the first time, it needs to be flushed.
    try {
        iPrefrences.flush();
    } catch (BackingStoreException lBackingStoreException) {
        LOGGER.warning("Failed to flush the configuration: " + lBackingStoreException.getMessage());
    }
    // Register the listener for prefs changes
    iPrefrences.addPreferenceChangeListener(new PreferenceChangeListener() {
        public void preferenceChange(PreferenceChangeEvent evt) {
            try {
                iPrefrences.flush();
            } catch (BackingStoreException lBackingStoreException) {
                LOGGER.warning("Failed to flush the configuration: " + lBackingStoreException.getMessage());
            }
        }
    });
}

From source file:com.symbian.utils.config.ConfigUtils.java

/**
 * Save the Configuration settings to files.
 * /*from  w  ww .j a va  2  s  .co  m*/
 * @param aPrefFile
 *            The Java Preference file to export/save.
 * 
 * @throws IOException
 *             If the saving doesn't work.
 */
public void exportConfig(final File aPrefFile) throws IOException {
    try {
        iPrefrences.exportNode(new FileOutputStream(aPrefFile));
    } catch (FileNotFoundException lFileNotFoundException) {
        throw new IOException("Cannot create new properties file: " + aPrefFile.getPath() + ": "
                + lFileNotFoundException.getMessage());
    } catch (IOException lIOException) {
        throw new IOException(
                "Properties file I/O error: " + aPrefFile.getPath() + ": " + lIOException.getMessage());
    } catch (BackingStoreException lBackingStoreException) {
        throw new IOException(
                "Backing Store error: " + aPrefFile.getPath() + ": " + lBackingStoreException.getMessage());
    }
}

From source file:org.intermine.modelviewer.store.MineManagerBackingStore.java

/**
 * Attempt to write the preferences to the backing store. Any exception thrown
 * is logged (at warning level) but otherwise ignored.
 */// ww  w . j  av  a  2  s  .c  o  m
protected void flush() {
    try {
        prefs.flush();
    } catch (BackingStoreException e) {
        logger.warn("Failed to write values to backing store: " + e.getMessage());
    }
}