String spec = "<set><setSpec>hdl_" + allCols[i].getHandle().replace('/', '_') + "</setSpec><setName>" + Utils.addEntities(allCols[i].getMetadata("name")) + "</setName></set>";  sets.add(spec);
spec = new StringBuffer("<set><setSpec>hdl_"); spec.append(allCols[i].getHandle().replace('/', '_')); spec.append("</setSpec>"); String collName = allCols[i].getMetadata("name"); if(collName != null) { spec.append("<setName>"); spec.append(Utils.addEntities(collName)); spec.append("</setName>"); } else { spec.append("<setName />");  log.info(LogManager.getHeader(null, "oai_error", "null_set_name_for_set_id_" + allCols[i].getHandle())); } spec.append("</set>"); sets.add(spec.toString());
    public Map listSets() throws NoSetHierarchyException,            OAIInternalServerError    {        log.info(LogManager.getHeader(null, "oai_request", "verb=listSets"));        Context context = null;        // List to put results in        List sets = new LinkedList();        try        {            context = new Context();            Collection[] allCols = Collection.findAll(context);            for (int i = 0; i < allCols.length; i++)            {                String spec = "<set><setSpec>hdl_"                        + allCols[i].getHandle().replace('/', '_')                        + "</setSpec><setName>"                        + Utils.addEntities(allCols[i].getMetadata("name"))                        + "</setName></set>";                sets.add(spec);            }        }        catch (SQLException se)        {            // Log the error            log.warn(LogManager.getHeader(context, "database_error", ""), se);            throw new OAIInternalServerError(se.toString());        }        finally        {            if (context != null)            {                context.abort();            }        }        // Put results in form needed to return        Map results = new HashMap();        results.put("sets", sets.iterator());        return results;    }