"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);
}
}