Connection conn = null;
try
{
if (systemRoles.contains(rolename))
{
throw new RoleException("[" + rolename + "] is a system role and cannot be removed");
}
conn = Torque.getConnection();
Role role = this.getRole(rolename);
Criteria criteria = new Criteria();
criteria.add(TurbineRolePeer.ROLE_NAME, rolename);
if(cascadeDelete)
{
// CASCADE TURBINE_USER_GROUP_ROLE, TURBINE_ROLE_PERMISSION
Criteria criteria1 = new Criteria();
criteria1.add(TurbineUserGroupRolePeer.ROLE_ID, role.getId());
TurbineUserGroupRolePeer.doDelete(criteria1, conn);
Criteria criteria2 = new Criteria();
criteria2.add(TurbineRolePermissionPeer.ROLE_ID, role.getId());
TurbineRolePermissionPeer.doDelete(criteria2, conn);
}
TurbineRolePeer.doDelete(criteria, conn);
PsmlManager.removeRoleDocuments(role);
conn.commit();
if (cachingEnable)
{
JetspeedSecurityCache.removeAllRoles(rolename);
}
}
catch(Exception e)
{
try
{
conn.rollback();
}
catch (java.sql.SQLException sqle)
{
logger.error("SQLException", sqle);
}
String message = "Failed to remove role '" + rolename + "'";
logger.error( message, e );
throw new RoleException( message, e );
}
finally
{
try
{