@@ -0,0 +1,2612 @@
+/**%0A * The contents of this file are subject to the license and copyright%0A * detailed in the LICENSE and NOTICE files at the root of the source%0A * tree and available online at%0A *%0A * http://www.dspace.org/license/%0A */%0Apackage org.dspace.curate;%0A%0Aimport java.io.IOException;%0Aimport java.sql.SQLException;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport org.dspace.content.Bitstream;%0Aimport org.dspace.content.BitstreamFormat;%0Aimport org.dspace.content.Bundle;%0Aimport org.dspace.content.DSpaceObject;%0Aimport org.dspace.content.Item;%0Aimport org.dspace.core.Context;%0A%0A/**%0A * ProfileFormats is a task that creates a distribution table of Bitstream %0A * formats for it's passed object. Primarily a curation task demonstrator.%0A *%0A * @author richardrodgers%0A */%0A@Distributive%0Apublic class ProfileFormats extends AbstractCurationTask%0A%7B%0A    // map of formats to occurrences%0A    private Map%3CString, Integer%3E fmtTable = new HashMap%3CString, Integer%3E();%0A%0A    /**%0A     * Perform the curation task upon passed DSO%0A     *%0A     * @param dso the DSpace object%0A     * @throws IOException%0A     */%0A    @Override%0A    public int perform(DSpaceObject dso) throws IOException%0A    %7B%0A        fmtTable.clear();%0A        distribute(dso);%0A        formatResults();%0A        return Curator.CURATE_SUCCESS;%0A    %7D%0A    %0A    @Override%0A    protected void performItem(Item item) throws SQLException, IOException%0A    %7B%0A        for (Bundle bundle : item.getBundles())%0A        %7B%0A            for (Bitstream bs : bundle.getBitstreams())%0A            %7B%0A                String fmt = bs.getFormat().getShortDescription();%0A                Integer count = fmtTable.get(fmt);%0A                if (count == null)%0A                %7B%0A                    count = 1;%0A                %7D%0A                else%0A                %7B%0A                    count += 1;%0A                %7D%0A                fmtTable.put(fmt, count);%0A            %7D           %0A        %7D%0A    %7D%0A    %0A    private void formatResults() throws IOException%0A    %7B%0A        try%0A        %7B%0A            Context c = new Context();%0A            StringBuilder sb = new StringBuilder();%0A            for (String fmt : fmtTable.keySet())%0A            %7B%0A                BitstreamFormat bsf = BitstreamFormat.findByShortDescription(c, fmt);%0A                sb.append(String.format(%22%256d%22, fmtTable.get(fmt))).append(%22, %22).%0A                append(bsf.getDescription()).append(%22%5Cn%22);%0A            %7D%0A            report(sb.toString());%0A            setResult(sb.toString());%0A            c.complete();%0A        %7D%0A        catch (SQLException sqlE)%0A        %7B%0A            throw new IOException(sqlE.getMessage(), sqlE);%0A        %7D%0A    %7D%0A%7D%0A

Make profileformats more palatable