final User user = getUser();
final Locale locale = getLocale();
if ( user == null ) throw new BadRequestException( locale.getString("www.json.error.notLoggedIn"), 403 );
final Database db = getDatabase();
final int id = Integer.parseInt( req.getUrlParam(2) );
final String sql = " select 1 " +
" from playlists p " +
" where p.id = ? " +
" and p.user_id = ? ";
ResultSet rs = null;
PreparedStatement st = null;
try {
// check user owns playlist before deleting it
st = db.prepare( sql );
st.setInt( 1, id );
st.setInt( 2, user.getId() );
rs = st.executeQuery();
if ( !rs.next() )
throw new BadRequestException( "You don't own that playlist", 403 );