public void addRole(Role role)
throws JetspeedSecurityException
{
if(roleExists(role.getName()))
{
throw new RoleException("The role '" +
role.getName() + "' already exists");
}
try
{
TurbineRole trole = new TurbineRole();
trole.setRoleName(role.getName());
Criteria criteria = TurbineRolePeer.buildCriteria(trole);
NumberKey key = (NumberKey)TurbineRolePeer.doInsert(criteria);
role.setId(key.toString());
}
catch(Exception e)
{
throw new RoleException("Failed to create role '" +
role.getName() + "'", e);
}
if (cachingEnable)
{
JetspeedSecurityCache.addRole(role);
}
try
{
addDefaultRolePSML(role);
}
catch (Exception e)
{
try
{
removeRole(role.getName());
}
catch (Exception e2)
{
}
throw new RoleException("failed to add default PSML for Role resource", e);
}
}