tri.close();
    public void removeBundle(Bundle b) throws SQLException, AuthorizeException,            IOException    {        // Check authorisation        AuthorizeManager.authorizeAction(ourContext, this, Constants.REMOVE);        log.info(LogManager.getHeader(ourContext, "remove_bundle", "item_id="                + getID() + ",bundle_id=" + b.getID()));        // Remove from internal list of bundles        ListIterator li = bundles.listIterator();        while (li.hasNext())        {            Bundle existing = (Bundle) li.next();            if (b.getID() == existing.getID())            {                // We've found the bundle to remove                li.remove();            }        }        // Remove mapping from DB        DatabaseManager.updateQuery(ourContext,                "DELETE FROM item2bundle WHERE item_id=" + getID()                        + " AND bundle_id=" + b.getID());        // If the bundle is orphaned, it's removed        TableRowIterator tri = DatabaseManager.query(ourContext,                "SELECT * FROM item2bundle WHERE bundle_id=" + b.getID());        if (!tri.hasNext())        {            //make the right to remove the bundle explicit because the implicit            // relation            //has been removed. This only has to concern the currentUser            // because            //he started the removal process and he will end it too.            //also add right to remove from the bundle to remove it's            // bitstreams.            AuthorizeManager.addPolicy(ourContext, b, Constants.DELETE,                    ourContext.getCurrentUser());            AuthorizeManager.addPolicy(ourContext, b, Constants.REMOVE,                    ourContext.getCurrentUser());            // The bundle is an orphan, delete it            b.delete();        }    }