try
{
if (systemPermissions.contains(permissionName))
{
throw new PermissionException("[" + permissionName + "] is a system permission and cannot be removed");
}
conn = Torque.getConnection();
Permission permission = this.getPermission(permissionName);
Criteria criteria = new Criteria();
criteria.add(TurbinePermissionPeer.PERMISSION_NAME, permissionName);
if(cascadeDelete)
{
// CASCADE to TURBINE_ROLE_PERMISSION
Criteria critRolePerm = new Criteria();
critRolePerm.add(TurbineRolePermissionPeer.PERMISSION_ID, permission.getId());
TurbineRolePermissionPeer.doDelete(critRolePerm, conn);
}
TurbinePermissionPeer.doDelete(criteria, conn);
if(!conn.getAutoCommit())
{
conn.commit();
}
if (cachingEnable)
{
JetspeedSecurityCache.removeAllPermissions(permissionName);
}
}
catch(Exception e)
{
try
{
conn.rollback();
}
catch (java.sql.SQLException sqle)
{
logger.error("SQLException", sqle);
}
String message = "Failed to remove permission '" + permissionName + "'";
logger.error( message, e );
throw new PermissionException( message, e );
}
finally
{
try
{